Code Graph MCP Server for Safer AI Code Changes
Part of the Code Knowledge Graphs guide. Start with Knowledge Graph for Code Explained: A Practical Guide
Before I trust a code graph MCP server with a refactor, I want to know which checkout it indexed, whether it can follow calls outside the edited file, and how it catches up after a save.
A caller graph from the default branch can be useful. So can a language server reading your working tree. They answer questions about different versions of your code.
The comparison includes graph servers, repository research tools, generated documentation, and context packing.
I build Pharaoh, which is marked as ours in the table.
What the MCP connection tells you
MCP gives a client access to tools a server exposes. The MCP tools specification defines that interface.
It doesn't establish the quality of a caller graph. When evaluating a server, ask what it parsed, which references it resolved, how the index updates, and whether the returned paths belong to the revision you're editing.
For the underlying model, read what a code knowledge graph represents.
I care about the evidence attached to an answer. A useful result should let me open the affected file, inspect the caller, follow an indirect path, and decide what to test before changing shared code.
Compare the graph servers first
These projects all provide MCP access to repository graphs. Language examples below are selected from their documentation; inspect the linked language pages for the constructs your repository uses.
| Server | Indexing method | Hosting and storage | Refresh model | Language scope |
|---|---|---|---|---|
| GitNexus | Tree-sitter extraction with language-aware resolution | Local CLI; LadybugDB in .gitnexus/ by default; MCP over stdio or one shared HTTP server |
Explicit analysis or local watch mode; watch doesn't pull remotes, while gitnexus auto-sync clones or pulls configured repositories and analyzes new commits on an interval |
Examples: TypeScript, JavaScript, Python, Go, Rust, Java and C/C++; construct coverage varies |
| CodeGraphContext | Tree-sitter by default; optional SCIP indexes add compiler-produced definitions and references | Embedded local databases or a remote backend | Explicit indexing or watcher, or a Git commit hook (cgc hook install); watcher startup reconciliation is opt-in |
Examples: Python, JavaScript, TypeScript, Java, Go, Rust and C/C++ |
| code-graph-rag | Tree-sitter, with compiler frontends where available | Embedded SQLite by default; Memgraph or Neo4j are alternatives | Explicit cgr start --update-graph, or a watcher that updates changed files and their dependents |
Examples with full support: Python, TypeScript, JavaScript, Go, Rust, Java and C/C++; other tiers differ |
| Pharaoh (ours) | Tree-sitter-based parser | Hosted MCP service; metadata retained, source-file bodies discarded | Default-branch pushes remap a live repository; account tool can request refresh | TypeScript, JavaScript, Python, C and C++ |
I wouldn't select a parser from its name alone. Pick a relationship you know exists, include a re-export or a workspace boundary if your project uses them, ask the tool to trace it, and inspect the result in your editor.
SCIP and LSP deserve separate labels here. CodeGraphContext documents compiler indexes through SCIP, Octocode documents navigation through installed language servers, and those integrations need different setup, so check which one you're actually configuring.
Search, documentation and packed context are different options
These belong on the shortlist because you may need repository discovery or a compact overview before you need a persistent graph. Their MCP support and refresh behavior differ.
| Tool | How it supplies context | Where it runs | Refresh model | Language scope |
|---|---|---|---|---|
| Octocode | GitHub and local research, Tree-sitter structural queries, navigation through installed language servers; stdio MCP | Local MCP process querying files and remote sources | On-demand reads, with caches for cloned repositories; explicit refresh is available | LSP configurations include JS/TS, Python, Go, Rust, Java and C/C++; installed servers and feature scope matter |
| DeepWiki MCP | Generated documentation and repository Q&A; parser method isn't documented | Hosted remote MCP for public repositories, without authentication | Badge-bearing repositories get automatic wiki refresh; no interval is specified | No parser language matrix documented |
| Aider repo map | Tree-sitter symbols and graph ranking select repository context; built into Aider rather than a standalone MCP graph server | Local repository in an Aider session | Configurable map refresh, defaulting to auto |
Repo-map support includes Python, JS/TS, Go, Rust, Java and C/C++; use the map-support column |
| Repomix | Packages local or remote repositories; experimental MCP mode; optional Tree-sitter compression | Local CLI or stdio MCP process | Pack again on demand; CLI watch mode repacks local changes | Packing accepts any programming language; compression depends on parser support |
For an unfamiliar public dependency, I'd try DeepWiki's explanation and inspect the referenced code. For a local symbol lookup, I'd consider Octocode's language-server tools, check that the server for my language is installed, enable the local tools, and verify which checkout they read.
aider --show-repo-map prints the map and exits. If you already use Aider, inspect that output before adding another context service.
Repomix is worth evaluating when the immediate job is to hand an assistant a repository snapshot. Its packing workflow can be enough for an overview, but I'd test caller questions separately, inspect what compression removes, and regenerate the package after relevant changes.
repomix --mcp starts its experimental MCP server. For a continuously updated local package, use the CLI watcher instead.
repomix --watch keeps a local CLI package updated. The documented watch mode doesn't support remote repositories; don't assume it runs inside an MCP packing request.
Check what happens after the first index
The first successful query is only part of the evaluation. Change a caller, save the file, run the same query again, and check whether the server sees the edit without starting a new session.
gitnexus analyze --watch watches local files and serializes incremental refreshes. It doesn't pull remotes.
gitnexus auto-sync clones or pulls configured repositories and analyzes new commits on an interval.
gitnexus analyze indexes once, or updates a stale index, when you don't need the watcher. By default, it also installs agent skills, registers Claude Code hooks, and writes AGENTS.md and CLAUDE.md. Use gitnexus analyze --index-only to index without those files.
cgc watch monitors changes while it runs. Its docs warn that edits made while the watcher was stopped aren't picked up by default; run cgc watch --sync-on-start when you need that reconciliation.
cgc index is the explicit indexing command.
cgr watch --repo-path /path/to/your/repo starts the documented watcher for code-graph-rag. Its update process reparses changed files and dependents.
For Octocode, check whether an answer came from the working files or a cached clone, confirm which remote revision you need, request a refresh when appropriate, and repeat the lookup. Octocode's site says “No indexing”, which describes its research workflow; cloned repositories are still cached.
Pharaoh answers from the default branch. A default-branch push remaps a live repository, or you can request a refresh through pharaoh_account, but uncommitted local edits remain outside that graph, so keep your editor's branch view alongside it.
A real caller query, with its revision attached
Here's the kind of result I'd inspect before changing shared authorization logic. Ask the agent to call get_blast_radius for checkAdminOrOwner with depth 3.
The excerpt was captured from Pharaoh-so/cal.diy, revision 54343aa6. It's trimmed to one module; the lines are unchanged.
### api/v2
- apps/api/v2/src/modules/atoms/controllers/atoms.conferencing-apps.controller.ts: AtomsConferencingAppsController.listUserInstalledConferencingApps (3 hops)
- apps/api/v2/src/modules/atoms/controllers/atoms.event-types.controller.ts: AtomsEventTypesController.getAtomEventTypeApp (2 hops)
- apps/api/v2/src/modules/atoms/services/conferencing-atom.service.ts: ConferencingAtomsService.getUserConferencingApps (2 hops)
- apps/api/v2/src/modules/atoms/services/event-types-atom.service.ts: EventTypesAtomService.getEventTypesAppIntegration
One service method, EventTypesAtomService.getEventTypesAppIntegration, calls it directly. The conferencing service method is two hops away and the controller methods are two or three, so I'd open both layers, inspect how they use the result, and choose tests for the proposed behavior change. The output identifies places to investigate; it doesn't say every caller will break.
Pharaoh's blast-radius tool excludes test-file callers. Use your test runner and editor to inspect tests separately, check the branch you're editing against the mapped revision, review dynamic wiring, and rerun the relevant checks after the edit.
For a fuller workflow, see checking a change's blast radius.
Match the question to the tool
Within Pharaoh, get_codebase_map provides module orientation and dependencies, get_module_context shows exports and incoming relationships, search_functions locates existing implementations, and pharaoh_recon combines several lookups. The tool overview describes the current surface.
For cleanup, get_unused_code distinguishes Dead from Possibly unused and Used only by tests. A Dead result means entry points don't reach the function, other files don't name it, production files don't import its file, and every signal agrees. Inspect uncertain results before deleting code.
A dependency question can need a different starting point from a caller question. Our dependency graph guide goes into that distinction.
Try one repository before choosing
Use a change you understand well enough to grade. I'd compare the tools on these checks:
-
Find an existing helper and open the reported definition. Verify its signature against the actual file.
-
Trace a shared function through a caller outside its module. Include an indirect caller you can confirm manually.
-
Add or remove a caller on a disposable branch. Check when each tool sees it and which revision it reports.
-
Inspect an unused export and a dynamically loaded function. Look for uncertainty in the result before treating either as removable.
Record omissions as well as correct hits, keep the task identical across tools, inspect any unresolved references, and make the selection from those results.
To include Pharaoh, install its GitHub App on the repository owner's account or organization, authorize the repositories you want it to read, connect your client, and sign in with GitHub. The App's only write permission publishes check results.
In a Claude Code terminal, run:
npx @pharaoh-so/mcp
Then complete the GitHub sign-in. In other clients, add https://mcp.pharaoh.so/mcp as a remote MCP server and sign in with GitHub.
Mapping uses a temporary clone, deletes it when the job ends, retains structural metadata, and doesn't keep source-file bodies. Read the security documentation if that distinction affects your choice.
Every repository is live during the trial and on Pro.
Pick a known caller chain, connect a repository, check its mapped revision, inspect the returned files, and compare it with your own trace.
Article Record
ReferencesPrimary sources used for this article
- Introduction to CodeGraphContext
- How Ingestion Works
- Indexing Source Code
- CLI Command Reference
- Tools
- Tree-sitter Documentation
- Language Server Protocol
- Building a better repository map with tree sitter
- Repository map
- Real-Time Graph Updates¶
- GitNexus
- ARCHITECTURE.md
- README.md
- Graph Backends - Code-Graph-RAG
- MCP Server
Update HistoryMeaningful revisions to this article
- Linked the existing “Pharaoh” mention to help readers learn more about the product.