by Shashankss1205
Indexes local codebases into a Neo4j graph, providing AI assistants with rich context for code queries and analysis.
Indexes source code, builds a knowledge graph of functions, classes, and their relationships, and serves this information through an MCP server so AI assistants can answer code‑related questions with up‑to‑date context.
pip install codegraphcontext
cgc setup
The wizard can set up a local Docker Neo4j instance, install Neo4j on Linux, or connect to a remote AuraDB. It also configures supported IDEs/CLIs (VS Code, Cursor, Claude, etc.) and creates the necessary mcp.json and environment files.cgc start
process_payment function” or “Watch the /my/project directory for changes.”add_code_to_graph, find_dead_code, calculate_cyclomatic_complexity, etc.Q: Do I need Docker to run the server? A: Docker is the recommended way for a quick local Neo4j instance, but the wizard also supports a Linux binary installation or connecting to an existing remote Neo4j database.
Q: Which IDEs are automatically configured? A: VS Code, Cursor, Windsurf, Claude, Gemini CLI, ChatGPT Codex, Cline, RooCode, and Amazon Q Developer are supported out of the box.
Q: How does the “watch directory” command work? A: It triggers a full initial scan (running as a background job) and then starts a file‑system watcher to keep the graph synchronized with any changes.
Q: Can I add custom tools or disable existing ones?
A: Yes. The generated mcp.json allows you to edit the tools.alwaysAllow and tools.disabled lists.
Q: Is the project open source? A: Yes, it is released under the MIT License.
An MCP server that indexes local code into a graph database to provide context to AI assistants.


CodeGraphContext is already being explored by developers and projects for:
If you’re using CodeGraphContext in your project, feel free to open a PR and add it here! 🚀
neo4j>=5.15.0watchdog>=3.0.0requests>=2.31.0stdlibs>=2023.11.18typer[all]>=0.9.0rich>=13.7.0inquirerpy>=0.3.4python-dotenv>=1.0.0tree-sitter==0.20.4tree-sitter-languages==1.10.2Install: pip install codegraphcontext
Setup: cgc setup
This interactive command guides you through configuring your Neo4j database connection and automatically setting up your IDE.
Database Configuration:
cgc setup can automate the installation of Neo4j. Requires sudo privileges.IDE/CLI Configuration: After setting up your database, the wizard will ask to configure your development environment. It can automatically detect and configure the following:
Upon successful configuration, cgc setup will generate and place the necessary configuration files:
mcp.json file in your current directory for reference.~/.codegraphcontext/.env..claude.json or VS Code's settings.json).Start: cgc start
The cgc setup command attempts to automatically configure your IDE/CLI. If you choose not to use the automatic setup, or if your tool is not supported, you can configure it manually.
Add the following server configuration to your client's settings file (e.g., VS Code's settings.json or .claude.json):
{
"mcpServers": {
"CodeGraphContext": {
"command": "cgc",
"args": [
"start"
],
"env": {
"NEO4J_URI": "YOUR_NEO4J_URI",
"NEO4J_USERNAME": "YOUR_NEO4J_USERNAME",
"NEO4J_PASSWORD": "YOUR_NEO4J_PASSWORD"
},
"tools": {
"alwaysAllow": [
"add_code_to_graph",
"add_package_to_graph",
"check_job_status",
"list_jobs",
"find_code",
"analyze_code_relationships",
"watch_directory",
"find_dead_code",
"execute_cypher_query",
"calculate_cyclomatic_complexity",
"find_most_complex_functions",
"list_indexed_repositories",
"delete_repository",
"visualize_graph_query",
"list_watched_paths",
"unwatch_directory"
],
"disabled": false
},
"disabled": false,
"alwaysAllow": []
}
}
}
Once the server is running, you can interact with it through your AI assistant using plain English. Here are some examples of what you can say:
To index a new project:
/path/to/my-project directory."
OR~/dev/my-other-project to the code graph."To start watching a directory for live changes:
/path/to/my-active-project directory for changes."
OR~/dev/main-app."When you ask to watch a directory, the system performs two actions at once:
job_id to track its progress.This means you can start by simply telling the system to watch a directory, and it will handle both the initial indexing and the continuous updates automatically.
Finding where code is defined:
process_payment function?"User class for me."Analyzing relationships and impact:
get_user_by_id function?"calculate_tax function, what other parts of the code will be affected?"BaseController class."Order class have?"Exploring dependencies:
requests library?"render method."Advanced Call Chain and Dependency Tracking (Spanning Hundreds of Files): The CodeGraphContext excels at tracing complex execution flows and dependencies across vast codebases. Leveraging the power of graph databases, it can identify direct and indirect callers and callees, even when a function is called through multiple layers of abstraction or across numerous files. This is invaluable for:
Impact Analysis: Understand the full ripple effect of a change to a core function.
Debugging: Trace the path of execution from an entry point to a specific bug.
Code Comprehension: Grasp how different parts of a large system interact.
"Show me the full call chain from the main function to process_data."
"Find all functions that directly or indirectly call validate_input."
"What are all the functions that initialize_system eventually calls?"
"Trace the dependencies of the DatabaseManager module."
Code Quality and Maintenance:
process_data function in src/utils.py."Repository Management:
/path/to/old-project."Contributions are welcome! 🎉
Please see our CONTRIBUTING.md for detailed guidelines.
If you have ideas for new features, integrations, or improvements, open an issue or submit a Pull Request.
Join discussions and help shape the future of CodeGraphContext.
Please log in to share your review and rating for this MCP.
{
"mcpServers": {
"codegraphcontext": {
"command": "cgc",
"args": [
"start"
],
"env": {}
}
}
}claude mcp add codegraphcontext cgc startExplore related MCPs that share similar capabilities and solve comparable challenges
by zed-industries
A high‑performance, multiplayer code editor designed for speed and collaboration.
by modelcontextprotocol
Model Context Protocol Servers
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
by modelcontextprotocol
A Model Context Protocol server that provides time and timezone conversion capabilities.
by cline
An autonomous coding assistant that can create and edit files, execute terminal commands, and interact with a browser directly from your IDE, operating step‑by‑step with explicit user permission.
by continuedev
Enables faster shipping of code by integrating continuous AI agents across IDEs, terminals, and CI pipelines, offering chat, edit, autocomplete, and customizable agent workflows.
by upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
by github
Connects AI tools directly to GitHub, enabling natural‑language interactions for repository browsing, issue and pull‑request management, CI/CD monitoring, code‑security analysis, and team collaboration.
by daytonaio
Provides a secure, elastic infrastructure that creates isolated sandboxes for running AI‑generated code with sub‑90 ms startup, unlimited persistence, and OCI/Docker compatibility.