Skip to main content
A codebase knowledge graph is a Mintlify project that describes your code: what each repository does, what it exposes, and how repositories depend on each other. Agents query it through MCP before they change code. You don’t need existing docs or a migration. Setup takes three steps:
  1. Generate the initial knowledge graph with the Mintlify agent or your own coding agent.
  2. Set up automations to keep it current.
  3. Use the knowledge graph through MCP.
The repositories, pull requests, and answers in the examples on this page are sample data.

Prerequisites

Plan the structure

Put every repository in one hub project, so agents query one MCP server and pages can link across repositories. Give each repository its own group, plus an overview section.
docs.json
Each repository section should cover what an agent needs before it changes code:
  • What the repository does and who owns it
  • The endpoints or events it exposes
  • What it calls and what calls it
  • Its key data models
  • How to run and test it
Start with a few representative repositories, such as one frontend, one backend, and one shared service, before you add the rest.

Step 1: Generate the initial knowledge graph

Have an agent read your source code and write the first pages into the hub repository. Use the Mintlify agent, or clone the repositories and run your own coding agent.
The Mintlify agent reads any repository with the Mintlify GitHub App installed, so you don’t clone anything.
1

Generate documentation for one repository

Open the agent in your dashboard or Slack and name the source repository, the target folder, and the pages to write.
Example prompt
The agent opens a pull request in the hub repository. Review it and fix anything the agent got wrong.
2

Repeat for each repository

Repeat for your other repositories, then ask the agent for the overview pages.
Example prompt
3

Merge the pull requests

When the pull requests merge, Mintlify deploys the knowledge graph and indexes it for search and MCP.
Save the prompts that worked as a custom skill or an AGENTS.md file in the hub repository. Anyone adding a new repository later gets the same page structure.

Step 2: Keep the knowledge graph current

Create a custom automation with a code change trigger so the agent updates the hub whenever a pull request merges in a source repository.
1

Create the automation

  1. Open your Automations settings.
  2. Click New automation.
  3. Select the Code change trigger.
  4. Click Add repo for each source repository you documented in step 1. One automation can listen to up to 50 repositories.
2

Filter the trigger

On each repository card, click Show advanced options. Set Listening to changes in to source paths such as src/**, and add bot accounts to Exclude author. See Filter code change triggers.
3

Write the instructions

Tell the agent how repositories map to hub pages and what to change.
Example instructions
4

Choose an update mode

Leave Update and merge changes off at first. The agent then opens a pull request and assigns the source change’s authors as reviewers. When the agent’s pull requests stop needing edits, turn on Update and merge changes. If your deploy branch has branch protection, see Configure automerge.
5

Test the automation

Save and run it manually, then check the run history and refine the instructions.
This simulator uses an automation that listens to src/** in the three example repositories and excludes dependabot[bot]. To add a repository later, generate its pages as in step 1, then add it to the trigger. Each run that updates the hub uses credits, and runs that change nothing are free. For busy repositories, a schedule trigger batches many merges into one run. See Control credit usage.
The estimate assumes every merge changes documented code, so actual usage is likely lower.

Step 3: Use the knowledge graph through MCP

Every project has a hosted search MCP server. Because the knowledge graph requires authentication, connect your agents to the /authed/mcp path of your site URL. The first time an agent connects, you sign in with the same credentials you use for the site, and the agent reads only the pages that your user groups can access. See Enable authenticated MCP.
See Use your MCP server for other clients. To check the connection, ask your agent how to run one of your repositories locally. Confirm that the agent searches the knowledge-graph server and answers from its pages. To have agents search the knowledge graph on their own, add a line to the CLAUDE.md, AGENTS.md, or Cursor rules file in each source repository.
AGENTS.md
Here’s how an agent uses the MCP tools to answer questions about your code: When an agent finds an incorrect page, it can report the page with the feedback tool. Reports appear in your feedback dashboard.

Next steps

Automations

Learn about trigger types, update modes, and usage limits.

Search MCP server

Configure indexing, authentication, and client credentials for your MCP server.

Skills

Teach agents how to use your knowledge graph with skill files.

Authentication

Restrict the knowledge graph to your team.