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

To keep the knowledge graph private, set up authentication. The search MCP server then requires each user to log in.

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, and 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

Connect your source repositories

Install the Mintlify GitHub App on each source repository you want to document. See Connect repositories as context.
2

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.
3

Repeat for each repository

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

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

Under Show advanced options on each repository card, set Listening to changes in to source paths such as src/**, and use Excluding PRs from to skip bots. 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

Start with Modify and wait for review, which opens a pull request and assigns the source change’s authors as reviewers. Switch to Update and merge changes once results are consistent. With 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 at the /mcp path of your site URL. With authentication, use /authed/mcp and enable authenticated MCP first.
See Use your MCP server for other clients. To make agents check it without being asked, 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 a wrong page, it can report it 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.