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

github.com/CodeGraphContext/CodeGraphContext

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.5.5 ↗ · + Follow · compare 3 versions
5,883 symbols 19,601 edges 608 files ⚖ MIT 1,909 documented · 32% updated 1d agov0.5.5 · 2026-08-02★ 4,034129 open issues

Browse by type

Functions 4,949 Types & classes 906 Endpoints 28
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 Overview

CodeGraphContext transforms source code into a queryable knowledge graph that can be explored through the CLI or AI assistants via MCP.

flowchart TD
    A[Code Repository] --> B[Tree-sitter / SCIP Indexing]
    B --> C[Knowledge Graph]
    C --> D[Graph Database]
    D --> E[CLI Toolkit]
    D --> F[MCP Server]
    F --> G[AI Assistant]

Workflow

  1. Source code is parsed using Tree-sitter or SCIP indexers.
  2. Relationships between functions, classes, imports, and calls are extracted.
  3. A knowledge graph is generated and stored in a graph database.
  4. Users can query the graph through the CLI or AI assistants using MCP.

🏗️ 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

🏗️ 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 ⛓️ Solidity

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

Solidity notes: .sol uses Tree-sitter via tree-sitter-language-pack (no SCIP). Supports Foundry remappings, modifier invocations, using Lib for T, and emit / custom-error revert as CALLS. See docs/docs/contributing_languages.md § Solidity.


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 a

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,736
Function 2,213
Class 693
Interface 133
Struct 54
Route 28
Enum 18
TypeAlias 7
FuncType 1

Languages

Python56%
TypeScript26%
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.py92 symbols
src/codegraphcontext/cli/main.py87 symbols
tests/unit/parsers/test_kotlin_parser.py85 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