CodeGraphContext/CodeGraphContext
An MCP server plus a CLI tool that indexes local code into a graph database to provide context to AI assistants.
CodeGraphContext (CGC)
What it is
CodeGraphContext (CGC) is a Python‑based tool that turns a local code base into a graph database of symbols, calls, imports, inheritance, and other relationships. The graph can be queried from the command line or served over the MCP (Model‑Control‑Protocol) so that AI assistants (e.g., chat‑based code‑helpers) can retrieve precise, symbol‑level context instead of just doing a text search.
Core features
| Feature | What you get |
|---|---|
| Code indexing | Parses source files with tree‑sitter (and optional SCIP indexers) and builds a knowledge graph. |
| Multi‑language support | 23 languages out‑of‑the‑box (Python, JS/TS, Java, C/C++, Go, Rust, Solidity, etc.). |
| CLI toolkit | Commands such as cgc index, cgc analyze callers <sym>, cgc watch, cgc list, etc., for local, interactive analysis. |
| MCP server mode | Runs a FastAPI‑based server (cgc mcp start) that answers natural‑language queries from AI IDE extensions. |
| Database back‑ends | Embedded FalkorDB Lite (default on Unix), KuzuDB, LadybugDB, or external Neo4j/Nornic – selectable via cgc config db. |
| Live updating | cgc watch watches a directory and updates the graph as files change. |
| Pre‑indexed bundles | Ready‑made .cgc bundles for popular repos, so you can skip the indexing step. |
| Docker support | Official Docker image and compose profiles for quick, language‑agnostic execution. |
| Visualization (premium) | Web UI that renders an interactive, force‑directed graph of the code base. |
How it works (high‑level workflow)
- Parse – Tree‑sitter (and optionally SCIP) extracts symbols, calls, imports, etc.
- Build graph – The extracted data is turned into nodes/edges and stored in the chosen graph DB.
- Query – Either the CLI or the MCP server runs Cypher‑like queries against the graph.
- Consume – AI agents or developers receive structured answers such as call‑chains, class hierarchies, dead‑code lists, etc.
Typical use‑cases
- Trace call chains across files and packages.
- Understand class hierarchies and module boundaries.
- Detect dead code, hotspots, or unexpected dependencies.
- Provide AI assistants with the same structural context a human maintainer would use.
- Generate visual graphs for project documentation or onboarding.
Getting started (quick‑start)
# Install the package
pip install codegraphcontext
# Index the current repository
cgc index .
# Query something simple, e.g. callers of a function
cgc analyze callers my_function
# Run the MCP server for an AI IDE integration
cgc mcp setup # one‑time config
cgc mcp start # starts the FastAPI server
For Docker users:
docker pull codegraphcontext/codegraphcontext:latest
docker run --rm -v "$(pwd):/workspace" codegraphcontext/codegraphcontext cgc index .
Who maintains it
Created and maintained by Shashank Shekhar Singh (MIT‑licensed). The project is open‑source, has CI badges, a Discord community, and a public website.
All information above is taken directly from the repository’s README; no external assumptions are added.
Related
- Project
- Project
- Project
- Project
- Project