by CodeGraphContext
Indexes local codebases into a graph database, allowing AI assistants and developers to query code relationships and context using natural language.
CodeGraphContext provides a powerful MCP‑compatible server and a command‑line toolkit that parses source code, builds a knowledge graph of functions, classes, imports, and call relationships, and stores it in a graph database. The resulting graph can be queried directly via CLI or through AI assistants that understand natural‑language requests.
pip install codegraphcontext
If the cgc command is not on your PATH, run the one‑line fix script:
curl -sSL https://raw.githubusercontent.com/CodeGraphContext/CodeGraphContext/main/scripts/post_install_fix.sh | bash
cgc index /path/to/project
Additional commands such as cgc list, cgc analyze callers <func>, cgc watch . help explore and keep the graph up‑to‑date.cgc mcp setup # runs an interactive wizard to configure IDE/AI client
cgc mcp start # launches the MCP server
Once the server is running, AI tools can send natural‑language queries like “Where is the process_payment function?” and receive graph‑based answers.cgc watch automatically updates the graph on file changes..cgc bundles for popular repositories without re‑indexing.Q: Which Python versions are supported? A: Python 3.10 through 3.14.
Q: Do I need to run a database server? A: No. KùzuDB runs embedded with zero‑config. FalkorDB Lite and Neo4j are optional for Unix‑only or enterprise scenarios.
Q: How does the MCP server communicate with AI tools?
A: The server follows the Model Context Protocol (MCP). After running cgc mcp start, the wizard creates the necessary configuration (e.g., mcp.json and environment files) for supported IDEs and AI CLIs.
Q: Can I ignore certain files or directories?
A: Yes. Add a .cgcignore file at the project root using the same syntax as .gitignore.
Q: Is there a GUI for visualizing the graph?
A: The CLI can output interactive HTML visualizations (--viz flag) that run in any modern browser.
Q: How do I contribute?
A: Fork the repository, follow the guidelines in CONTRIBUTING.md, and submit pull requests. Issues and feature requests are welcomed via the GitHub issue tracker.
Turn code repositories into a queryable graph for AI agents.
🌐 Languages:
🌍 Help translate CodeGraphContext to your language by raising an issue & PR on https://github.com/Shashankss1205/CodeGraphContext/issues!
A powerful MCP server and CLI toolkit that indexes local code into a graph database to provide context to AI assistants and developers. Use it as a standalone CLI for comprehensive code analysis or connect it to your favorite AI IDE via MCP for AI-powered code understanding.
Install in seconds with pip and unlock a powerful CLI for code graph analysis.
The CLI intelligently parses your tree-sitter nodes to build the graph.
Use natural language to query complex call-chains via MCP.
CodeGraphContext is created and actively maintained by:
Shashank Shekhar Singh
Contributions and feedback are always welcome! Feel free to reach out for questions, suggestions, or collaboration opportunities.
.cgc bundles - no indexing required! (Learn more)cgc watch).CodeGraphContext provides comprehensive parsing and analysis for the following languages:
| Language | Language | Language | |||
|---|---|---|---|---|---|
| 🐍 | Python | 📜 | JavaScript | 🔷 | TypeScript |
| ☕ | Java | 🏗️ | C / C++ | #️⃣ | C# |
| 🐹 | Go | 🦀 | Rust | 💎 | Ruby |
| 🐘 | PHP | 🍎 | Swift | 🎨 | Kotlin |
| 🎯 | Dart | 🐪 | Perl |
Each language parser extracts functions, classes, methods, parameters, inheritance relationships, function calls, and imports to build a comprehensive code graph.
CodeGraphContext supports multiple graph database backends to suit your environment:
| Feature | KùzuDB (Default) | FalkorDB Lite | Neo4j |
|---|---|---|---|
| Setup | Zero-config / Embedded | Zero-config / In-process | Docker / External |
| Platform | All (Windows Native, macOS, Linux) | Unix-only (Linux/macOS/WSL) | All Platforms |
| Use Case | Desktop, IDE, Local development | Specialized Unix development | Enterprise, Massive graphs |
| Requirement | pip install kuzu |
pip install falkordblite |
Neo4j Server / Docker |
| Speed | ⚡ Extremely Fast | ⚡ Fast | 🚀 Scalable |
| Persistence | Yes (to disk) | Yes (to disk) | Yes (to disk) |
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.0stdlibs>=2023.11.18typer[all]>=0.9.0rich>=13.7.0inquirerpy>=0.3.7python-dotenv>=1.0.0tree-sitter>=0.21.0tree-sitter-language-pack>=0.6.0pyyamlpytestnbformatnbconvert>=7.16.6pathspec>=0.12.1Note: Python 3.10-3.14 is supported.
pip install codegraphcontext
curl -sSL https://raw.githubusercontent.com/CodeGraphContext/CodeGraphContext/main/scripts/post_install_fix.sh | bash
CodeGraphContext operates in two modes, and you can use either or both:
Use CodeGraphContext as a powerful command-line toolkit for code analysis:
Use CodeGraphContext as an MCP server for AI assistants:
You can use both modes! Install once, then use CLI commands directly OR connect to your AI assistant.
Install: pip install codegraphcontext
If you encounter "cgc: command not found" after installation, run the PATH fix script:
Linux/Mac:
# Download the fix script
curl -O https://raw.githubusercontent.com/CodeGraphContext/CodeGraphContext/main/scripts/post_install_fix.sh
# Make it executable
chmod +x post_install_fix.sh
# Run the script
./post_install_fix.sh
# Restart your terminal or reload shell config
source ~/.bashrc # or ~/.zshrc for zsh users
Windows (PowerShell):
# Download the fix script
curl -O https://raw.githubusercontent.com/CodeGraphContext/CodeGraphContext/main/scripts/post_install_fix.sh
# Run with bash (requires Git Bash or WSL)
bash post_install_fix.sh
# Restart PowerShell or reload profile
. $PROFILE
Database Setup (Automatic)
pip install kuzu and you're ready!cgc neo4j setupStart using immediately with CLI commands:
# Index your current directory
cgc index .
# List all indexed repositories
cgc list
# Analyze who calls a function
cgc analyze callers my_function
# Find complex code
cgc analyze complexity --threshold 10
# Find dead code
cgc analyze dead-code
# Watch for live changes (optional)
cgc watch .
# See all commands
cgc help
See the full CLI Commands Guide for all available commands and usage scenarios.
CodeGraphContext can generate stunning, interactive knowledge graphs of your code. Unlike static diagrams, these are premium web-based explorers:
# Visualize function calls
cgc analyze calls my_function --viz
# Explore class hierarchies
cgc analyze tree MyClass --viz
# Visualize search results
cgc find pattern "Auth" --viz
Configure your AI assistant to use CodeGraphContext:
Setup: Run the MCP setup wizard to configure your IDE/AI assistant:
cgc mcp setup
The wizard can automatically detect and configure:
Upon successful configuration, cgc mcp 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: Launch the MCP server:
cgc mcp start
Use: Now interact with your codebase through your AI assistant using natural language! See examples below.
.cgcignore)You can tell CodeGraphContext to ignore specific files and directories by creating a .cgcignore file in the root of your project. This file uses the same syntax as .gitignore.
Example .cgcignore file:
# Ignore build artifacts
/build/
/dist/
# Ignore dependencies
/node_modules/
/vendor/
# Ignore logs
*.log
The cgc mcp 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": [
"mcp",
"start"
],
"env": {
"NEO4J_URI": "YOUR_NEO4J_URI",
"NEO4J_USERNAME": "YOUR_NEO4J_USERNAME",
"NEO4J_PASSWORD": "YOUR_NEO4J_PASSWORD"
},
"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.
Explore related MCPs that share similar capabilities and solve comparable challenges
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
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 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 upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
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.
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 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.