CodeGraph
A code knowledge graph that gives coding assistants searchable context and dependency-aware analysis.
What does this agent do, and when should you use it?
CodeGraph is a Rust implementation of a code knowledge graph that exposes context, impact, architecture, and quality analysis through MCP. It ingests build context, AST and FastML parsing, optional LSP resolution, and enrichment into SurrealDB nodes, edges, and vector chunks. Its MCP server exposes four consolidated tools—agentic_context, agentic_impact, agentic_architecture, and agentic_quality—using Rig, ReAct, or LATS reasoning strategies. The documented indexer covers Rust, Python, TypeScript, JavaScript, Go, Java, C/C++, and several additional languages, with local and cloud provider options for embeddings and reasoning. Its deployment boundary is a local codebase, SurrealDB, and an MCP client; it does not replace an IDE, type checker, or test runner.
After codegraph index runs on a project, CodeGraph creates AST nodes and core relationships according to the chosen indexing tier. The balanced and full tiers additionally invoke language-specific LSP tooling and can add module linking, documentation/contract links, dataflow, and architecture analysis. It persists code nodes, relationships such as calls and imports, plus chunks and embeddings with an HNSW vector index in SurrealDB. An MCP client can call agentic_context to search or assemble context, agentic_impact for dependency and call-chain analysis, agentic_architecture for structure or API surface analysis, and agentic_quality for complexity, coupling, and hotspot assessment. Results can include file paths, line numbers, bounded snippets, highlights, analysis, and next steps; --watch and daemon start support re-indexing after changes.
- A Claude Code user refactoring a Rust service who needs dependency and call-chain evidence before changing a component.
- An engineering team maintaining a mixed-language repository that wants Rust, TypeScript, Python, and Go code indexed in one searchable graph.
- A developer onboarding to a large repository who needs agentic_architecture to inspect package structure, module relationships, and API surface.
- A maintainer planning to split tightly coupled modules who needs agentic_quality to identify complexity hotspots, coupling metrics, and refactoring priorities.
- A local development workflow that needs an index kept current through codegraph start stdio --watch or daemon mode.
What are this agent's strengths and limitations?
- Combines AST data, graph relationships, and vector search instead of returning semantic matches alone.
- Provides four MCP-level tools for context, impact, architecture, and quality work, with locations and bounded snippets in documented outputs.
- Tiered indexing makes it possible to choose between fast AST-only indexing and fuller LSP, dataflow, documentation, and architecture enrichment.
- Documents local Ollama, LM Studio, and ONNX Runtime options alongside OpenAI, Jina AI, Anthropic, and xAI provider paths.
- Requires operating SurrealDB and applying a schema manually, adding deployment and maintenance work.
- Balanced and full indexing depend on language servers and fail fast when required tooling is absent.
- The default fast tier excludes LSP, module linking, dataflow, documentation/contracts, and architecture analysis.
- CODEGRAPH_CONTEXT_WINDOW must be set to match the chosen model's context window, which affects truncation and context-overflow protection.
How do you install or deploy this agent?
Clone and build:
git clone https://github.com/Jakedismo/codegraph-rust
cd codegraph-rust
./install-codegraph-full-features.sh
Start a local database:
surreal start --bind 0.0.0.0:3004 --user root --pass root file://$HOME/.codegraph/surreal.db
Apply the schema:
cd schema && ./apply-schema.sh
Then configure embedding, llm, and database.surrealdb in ~/.codegraph/config.toml. The supplied example uses Ollama with qwen3-embedding:0.6b, Anthropic with claude-sonnet-4, and ws://localhost:3004. Cloud-provider API-key setup is not specified in the supplied documentation.
How do you use this agent?
For an initial project index, run:
codegraph index /path/to/project -r -l rust,typescript,python
The default fast tier creates only AST data and core edges. For LSP-backed and enriched indexing, run:
codegraph index --index-tier balanced
Rust balanced/full indexing requires a runnable rust-analyzer; other languages have their own documented LSP dependencies. Start the MCP server with change watching:
codegraph start stdio --watch
For Claude Code, configure the binary as an MCP server with args ["start", "stdio", "--watch"]. Call agentic_context, agentic_impact, agentic_architecture, or agentic_quality, supplying a query and an optional focus where appropriate.
How does this agent compare with similar options?
Against embedding-only semantic-search tools, CodeGraph uses the matched code together with calls, dependencies, modules, and other graph relationships for analysis. That richer approach comes with database and indexing setup, plus LSP tooling for the more capable tiers.