MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext

github.com/CodeGraphContext/CodeGraphContext

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.5.2 ↗ · + Follow · compare 5 versions
5,426 symbols 17,666 edges 563 files ⚖ MIT 1,722 documented · 32% updated 3d agov0.5.7 · 2026-08-08★ 4,063118 open issues

Browse by type

Functions 4,532 Types & classes 871 Endpoints 23
What it actually does AI analysis from the code graph
loading…
README

🏗️ CodeGraphContext (CGC)

Turn code repositories into a queryable graph for AI agents.

🌐 Languages: - 🇬🇧 English - 🇨🇳 中文 - 🇰🇷 한국어 - 🇺🇦 Українська - 🇷🇺 Русский - 🇯🇵 日本語 - 🇪🇸 Español (Soon)

🌍 Help translate CodeGraphContext to your language by raising an issue & PR on GitHub Issues!

Bridge the gap between deep code graphs and AI context.

PyPI Version PyPI Downloads License MCP Compatible

Stars Forks Issues PRs Contributors

Tests E2E Tests Website Docs YouTube Demo

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


✨ Experience CGC

👨🏻‍💻 Installation and CLI

Install in seconds with pip and unlock a powerful CLI for code graph analysis. Install and unlock the CLI instantly

🛠️ Indexing in Seconds

The CLI intelligently parses your tree-sitter nodes to build the graph. Indexing using an MCP client

🤖 Powering your AI Assistant

Use natural language to query complex call-chains via MCP. Using the MCP server


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


👨‍💻 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

Star History Chart


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 .cgc bundles - 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,stroke:#a855f7,stroke-width:2px,color:#fff;

    D:::db
    G:::ai

Supported Programming Languages

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
🌙 Lua 🚀 Scala λ Haskell
💧 Elixir 📜 Emacs Lisp (elisp) 🌐 HTML
🎨 CSS ⚛️ TSX

Each language parser extracts functions, classes, methods, parameters, inheritance relationships, function calls, and imports to build a comprehensive code graph.


Database Options

CodeGraphContext supports multiple graph database backends to suit your environment:

Feature KuzuDB LadybugDB FalkorDB Lite Neo4j / Nornic DB
Typical default Cross-platform fallback when FalkorDB Lite is unavailable Optional embedded backend Default on Unix (Python 3.12+, when falkordblite is installed) When explicitly configured via cgc config db
Setup Zero-config / Embedded Zero-config / Embedded Zero-config / In-process Docker / External
Platform All (Windows Native, macOS, Linux) All (Windows Native, macOS, Linux) Unix-only (Linux/macOS/WSL) All Platforms
Use Case Desktop, IDE, Local development Custom research projects Specialized Unix development Enterprise, Massive graphs
Requirement pip install kuzu pip install ladybug pip install falkordblite Neo4j Server / Docker / Nornic Cloud
Speed ⚡ Extremely Fast ⚡ Fast 🚀 Scalable
Persistence Yes (to disk) Yes (to disk) Yes (to disk)

SCIP indexing (optional)

When SCIP_INDEXER=true in your CGC config (~/.codegraphcontext/.env), some languages use external SCIP indexers for more accurate calls and inheritance than Tree-sitter heuristics alone.

C and C++ use scip-clang, which requires a compile_commands.json file (a JSON compilation database): one entry per translation unit with the real compiler command (include paths, -D defines, -std, etc.). Without it, scip-clang cannot run; CGC logs a warning and falls back to Tree-sitter for that repo. Typical ways to produce the file: CMake with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, or wrap your real build with Bear (e.g. bear -- make). CGC also looks under build/ and cmake-build-*/ for that filename.

C# uses scip-dotnet (Roslyn); you need a normal .csproj / .sln and a successful restore—no compile_commands.json.

SCIP is independent of which graph database you use (Kuzu, Neo4j, etc.); the same flag applies to all backends.


Used By

CodeGraphContext is already being explored by developers and projects for:

  • Static code analysis in AI assistants
  • Graph-based visualization of projects
  • Dead code and complexity detection

If you’re using CodeGraphContext in your project, feel free to open a PR and add it here! 🚀


Dependencies

  • neo4j>=5.15.0
  • watchdog>=3.0.0
  • stdlibs>=2023.11.18
  • typer>=0.9.0
  • rich>=13.7.0
  • inquirerpy>=0.3.4
  • python-dotenv>=1.0.0
  • tree-sitter>=0.24.0,<0.26.0
  • tree-sitter-language-pack>=1.6,<2.0
  • pyyaml
  • pathspec>=0.12.1
  • falkordb>=1.0,<1.6
  • falkordblite>=0.7,<0.10 (Unix only, Python 3.12+)
  • kuzu (KuzuDB engine)
  • fastapi>=0.100.0
  • uvicorn>=0.22.0
  • requests>=2.28.0
  • protobuf>=3.20,<3.21

Note: Python 3.10-3.14 is supported.


🚀 Installation & Quick Start

  1. Install the toolkit: bash pip install codegraphcontext

  2. Troubleshooting (Command not found): If the codegraphcontext command is not found, run this one-line fix: bash curl -sSL https://raw.githubusercontent.com/CodeGraphContext/CodeGraphContext/main/scripts/post_install_fix.sh | bash

  3. Database Setup (Automatic): CodeGraphContext uses an embedded graph database by default.

    • FalkorDB Lite: Default backend.
    • KuzuDB: Cross-platform embedded backend.
    • Neo4j: Run codegraphcontext neo4j setup to use an external server.

🧪 Local Development Setup

If you want to run CodeGraphContext from a local clone and contribute changes, use an editable install:

git clone https://github.com/CodeGraphContext/CodeGraphContext.git
cd CodeGraphContext
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

Then verify the install and try the local commands:

```bash cgc --help cgc doctor cgc index . cgc analyze callers

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Method 2,603
Function 1,929
Class 658
Interface 133
Struct 54
Route 23
Enum 18
TypeAlias 7
FuncType 1

Languages

Python53%
TypeScript28%
Rust6%
Go5%
Kotlin1%
PHP1%

Modules by API surface

website/public/wasm/web-tree-sitter.js220 symbols
website/public/wasm/tree-sitter-core.js208 symbols
tests/unit/tools/test_graph_builder_perf_fixes.py90 symbols
tests/unit/parsers/test_kotlin_parser.py85 symbols
src/codegraphcontext/cli/main.py84 symbols
tests/fixtures/sample_projects/sample_project_typescript/src/classes-inheritance.ts78 symbols
tests/fixtures/sample_projects/sample_project_typescript/src/modules-namespaces.ts76 symbols
tests/integration/cli/test_cli_commands.py75 symbols
src/codegraphcontext/tools/languages/kotlin.py67 symbols
src/codegraphcontext/tools/indexing/resolution/calls.py62 symbols
tests/fixtures/sample_projects/sample_project_typescript/src/error-validation.ts56 symbols
tests/fixtures/sample_projects/sample_project_typescript/src/functions-generics.ts55 symbols

Dependencies from manifests, versioned

golang.org/x/expv0.0.0-2023081717370 · 1×
@eslint/js9.32.0 · 1×
@hookform/resolvers3.10.0 · 1×
@radix-ui/react-accordion1.2.11 · 1×
@radix-ui/react-alert-dialog1.1.14 · 1×
@radix-ui/react-aspect-ratio1.1.7 · 1×
@radix-ui/react-checkbox1.3.2 · 1×
@radix-ui/react-collapsible1.1.11 · 1×
@radix-ui/react-context-menu2.2.15 · 1×
@radix-ui/react-dialog1.1.14 · 1×
@radix-ui/react-dropdown-menu2.1.15 · 1×

Datastores touched

(mysql)Database · 1 repos

For agents

$ claude mcp add CodeGraphContext \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page