CodeGraphContext
CodeGraphContext · CodeGraphContext/CodeGraphContext
Indexes local code into a queryable graph to provide AI agents with deep structural context of your codebase.
An MCP server plus a CLI tool that indexes local code into a graph database to provide context to AI assistants.
Preview
What you can do with it
- Help the agent navigate complex dependencies between files and functions
- Generate visual maps or explanations of application logic flows
- Improve code review quality by providing the agent with broader project context
Safety check
Usable, but read the notes first.
- ●Installer downloads a remote script and pipes it to the shell.
README.md
Automated scan of the repo files. Always review code you run.
From the README
🏗️ CodeGraphContext (CGC)
Turn code repositories into a queryable graph for AI agents.
🌐 Languages:
🌍 Help translate CodeGraphContext to your language by raising an issue & PR on GitHub Issues!
Bridge the gap between deep code graphs and AI context.
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.
📍 Quick Navigation
- 🚀 Quick Start
- 📋 Prerequisites
- 🏃 How to Run the Project Locally
- 🌐 Supported Programming Languages
- 🛠️ CLI Toolkit
- 🤖 MCP Server
- 🗄️ Database Options
- 🔬 SCIP indexing (optional)
✨ Experience CGC
👨🏻💻 Installation and CLI
Install in seconds with pip and unlock a powerful CLI for code graph analysis.
🛠️ Indexing in Seconds
The CLI intelligently parses your tree-sitter nodes to build the graph.
🤖 Powering your AI Assistant
Use natural language to query complex call-chains via MCP.
Why CodeGraphContext?
CodeGraphContext is built for the moment when plain text search stops being enough. It turns a repository into a graph of files, symbols, calls, inheritance, imports, and relationships so you can move from "where is this defined?" to "how does this actually connect?" without jumping between tools.
flowchart LR
A[Source code] --> B[Tree-sitter and SCIP indexers]
B --> C[Graph database]
C --> D[CLI queries]
C --> E[MCP server]
D --> F[Direct analysis]
E --> G[AI assistants with repo context]
Comparison at a glance
| Approach | Best for | Tradeoff |
|---|---|---|
grep / file search | Exact string lookup | Misses relationships and code structure |
| RAG over code chunks | Natural-language retrieval | Can lose symbol-level precision |
| CodeGraphContext | Repository-wide reasoning | Requires an indexing step |
Common use cases
- Trace call chains across files and packages.
- Understand class hierarchies, imports, and module boundaries.
- Find dead code, hotspots, and unexpected dependencies.
- Give an AI assistant the same structural context a maintainer would use.
FAQ
- Do I need a remote service? No. CGC works locally with embedded backends or with external graph databases when you want them.
- Is it only for one language? No. It supports a broad mix of mainstream languages and keeps expanding.
- Can I use it with an AI assistant? Yes. That is one of the main reasons the MCP server exists.
Project Details
- Version: 0.5.1
- Authors: Shashank Shekhar Singh shashankshekharsingh1205@gmail.com
- License: MIT License (See LICENSE for details)
- Website: CodeGraphContext
👨💻 Maintainer
CodeGraphContext is created and actively maintained by:
Shashank Shekhar Singh
- 📧 Email: shashankshekharsingh1205@gmail.com
- 🐙 GitHub: @Shashankss1205
- 🔗 LinkedIn: Shashank Shekhar Singh
- 🌐 Website: codegraphcontext.vercel.app
Contributions and feedback are always welcome! Feel free to reach out for questions, suggestions, or collaboration opportunities.
Star History
Features
- Code Indexing: Analyzes code and builds a knowledge graph of its components.
- Relationship Analysis: Query for callers, callees, class hierarchies, call chains and more.
- Pre-indexed Bundles: Load famous repositories instantly with
.cgcbundles - no indexing required! (Learn more) - Live File Watching: Watch directories for changes and automatically update the graph in real-time (
cgc watch). - Interactive Setup: A user-friendly command-line wizard for easy setup.
- Dual Mode: Works as a standalone CLI toolkit for developers and as an MCP server for AI agents.
- Multi-Language Support: Full support for 23 programming languages.
- Flexible Database Backend: FalkorDB Lite (Default), KuzuDB, LadybugDB, FalkorDB Remote, Nornic DB, or Neo4j (all platforms via Docker/native).
🏗️ Architecture & Workflow
CodeGraphContext parses your source code and builds a comprehensive knowledge graph. This graph can be queried directly via the CLI toolkit or exposed to AI assistants through the MCP server.
flowchart TD
A[Code Repository] -->|Parsed by| B[Tree-sitter / SCIP Indexing]
B -->|Generates| C[Knowledge Graph]
C -->|Stored in| D[(Graph Database)]
D -->|Queried via| E[CLI Toolkit]
D -->|Served by| F[MCP Server]
F -->|Provides context to| G[🤖 AI Assistant]
classDef default fill:#1f2937,stroke:#8b5cf6,stroke-width:2px,color:#fff;
classDef db fill:#0f172a,stroke:#3b82f6,stroke-width:2px,color:#fff;
classDef ai fill:#312e81,st