code-graph-context
A Model Context Protocol (MCP) server that builds rich code graphs to provide deep contextual understanding of TypeScript codebases to Large Language Models.
claude mcp add --transport stdio drewdrewh-code-graph-context node /absolute/path/to/code-graph-context/dist/cli/cli.js \ --env NEO4J_URI="bolt://localhost:7687" \ --env NEO4J_USER="neo4j" \ --env NEO4J_PASSWORD="PASSWORD" \ --env OPENAI_API_KEY="sk-your-key-here"
How to use
Code Graph Context is an MCP server that builds a semantic, queryable graph of your TypeScript codebase and exposes it to Claude Code as a knowledge graph. It parses your code (via ts-morph), stores structural relationships in Neo4j, and enriches nodes with vector embeddings from OpenAI to enable semantic search and natural language queries. You can ask questions like which services depend on a particular class, where a function is used across the codebase, or generate refactoring plans with risk analysis. The server is designed to be framework-aware (with built-in NestJS patterns) but also extensible to capture custom framework schemas and patterns you define in configuration files. You can run multi-project graphs, perform incremental parsing, and leverage streaming import for large repositories.
How to install
Prerequisites:
- Node.js v18 or newer
- Docker (optional but recommended for Neo4j) or an existing Neo4j instance
- OpenAI API key for embeddings and NL queries
Installation steps:
- Install the MCP server globally:
npm install -g code-graph-context
- Start Neo4j (using Docker for a quick setup):
docker run -d --name neo4j -p 7687:7687 -p 7474:7474 \
-e NEO4J_AUTH=neo4j/PASSWORD \
neo4j:5.3
- Initialize the MCP environment (sets up Neo4j via Docker if needed):
code-graph-context init
- Configure Claude Code with your OpenAI API key (example shown below). Save a config JSON as ~/.claude.json or project-local .claude.json as described in the docs:
{
"mcpServers": {
"code-graph-context": {
"command": "node",
"args": ["/absolute/path/to/code-graph-context/dist/cli/cli.js"],
"env": {
"OPENAI_API_KEY": "sk-your-key-here"
}
}
}
}
- Point Claude Code at your project and start parsing:
- In Claude Code, add the MCP server and run the parsing command (e.g., parse_typescript_project) to build the initial graph.
Optional: If you prefer not to use Docker, connect the MCP server to an existing Neo4j instance by updating the NEO4J_URI, NEO4J_USER, and NEO4J_PASSWORD environment variables in the mcp config.
Additional notes
Environment variables:
- OPENAI_API_KEY is required for embeddings and NL queries.
- NEO4J_URI, NEO4J_USER, NEO4J_PASSWORD are optional if you have a locally configured Neo4j instance; defaults assume a local bolt URL with neo4j/PASSWORD.
Common issues:
- If embeddings fail due to API limits, adjust request rate or set a higher timeout in the embeddings service.
- Ensure your Node.js version matches the server's requirements and that the dist/cli/cli.js path exists after build (run npm run build if needed).
- For large codebases, enable incremental parsing and streaming imports to avoid timeouts.
- If Claude Code cannot access your OpenAI model, verify API key scope and permissions.
Tips:
- Use the framework-aware features to define or override patterns for NestJS controllers/services, and extend the parser with custom framework schemas.
- Leverage multi-project support to isolate graphs per workspace while retaining the ability to compare across projects.
Related MCP Servers
code-graph-rag
The ultimate RAG for your monorepo. Query, understand, and edit multi-language codebases with the power of AI and knowledge graphs
mem0 -selfhosted
Self-hosted mem0 MCP server for Claude Code. Run a complete memory server against self-hosted Qdrant + Neo4j + Ollama while using Claude as the main LLM.
vibe-workspace
Manage a vibe workspace with many repos
SyberAgent
下一代PC本地自动化多智能体框架
claude-concilium
Multi-agent AI consultation framework for Claude Code via MCP — get second opinions from OpenAI, Gemini, Qwen, DeepSeek
outline-wiki
MCP server for Outline – Create Knowledge-bases while vibe coding.