Serveur MCP code-context-graph
Commit 21 août 2026Permet aux agents de codage IA de rechercher dans des bases de code par intention métier et d'inspecter des graphes d'appels grâce à un graphe de connaissances propulsé par Tree-sitter.
Aussi connu sous tae2089/code-context-graph
- Étoiles
- 18
- Outils
- —
- Téléchargements, 30 jours
- —
- Dernière version
- —
- Dernier commit
- 21 août 2026
- Licence
- MIT
Qu'est-ce que code-context-graph MCP ?
code-context-graph est un serveur MCP. Permet aux agents de codage IA de rechercher dans des bases de code par intention métier et d'inspecter des graphes d'appels grâce à un graphe de connaissances propulsé par Tree-sitter.
Résumé généré à partir du README du projet
À propos du MCP server code-context-graph
code-context-graph permet de fournir une intelligence approfondie des bases de code aux agents de codage IA. En analysant le code source via Tree-sitter, il construit un graphe de connaissances détaillé qui permet aux LLM de comprendre l'intention métier et les relations structurelles sans avoir à lire l'intégralité des dépôts. Cet outil est conçu pour les développeurs et les agents de codage utilisant des clients comme Claude ou Codex, offrant un moyen de limiter la taille des fenêtres de contexte tout en maintenant une haute précision.
Les utilisateurs peuvent exécuter le serveur localement via stdio ou l'héberger à distance en utilisant une connexion streamable HTTP. Il prend en charge 12 langages de programmation différents, dont Go, Python, TypeScript et Rust. Le système utilise SQLite ou PostgreSQL pour le stockage des données et fournit 18 outils MCP spécifiques pour des tâches telles que l'analyse d'impact, le traçage de flux et la découverte de documentation. Les développeurs peuvent également interagir avec les données via une interface Wiki dans le navigateur, dotée d'un visualiseur de graphes de style Obsidian et d'une navigation par arbre.
Ce que vous pouvez faire avec
- 1Tracer les flux d'exécutionUn agent IA peut suivre le chemin d'un appel de fonction spécifique à travers la base de code pour en comprendre la logique.
- 2Rechercher par intention métierLes développeurs peuvent trouver du code lié à des règles métier ou à une logique métier spécifique en utilisant des annotations personnalisées.
- 3Analyser l'impact du codeUn agent peut déterminer comment une modification dans une partie du système affectera les autres composants.
- 4Automatiser les mises à jour de la base de codeLe système peut cloner et compiler automatiquement de nouvelles versions du code lorsqu'il est déclenché par des événements GitHub ou Gitea.
Extrait du README du projet. Chaque cas d'utilisation est vérifié par rapport à une citation du document.
Configuration
CGO_ENABLED
| Nom | Description | Type |
|---|---|---|
| CGO_ENABLED | — |
Vérifications automatisées
Exécuté le 14 nov. 2026Rapport complet →Pas encore vérifié. Un serveur nécessite un score de 80, aucune faille sérieuse et suffisamment de données pour que nous puissions effectuer les vérifications. Fonctionnement des vérifications · Ce qu'il faut corriger pour gagner des points
- Dépôt source lié et accessibletae2089/code-context-graph is public and reachablegithub.com/tae2089/code-context-graph ↗Réussi
- Le nom du package correspond au dépôt sourceNon vérifié
- Provenance du build (attestation Sigstore)Non vérifié
- Licence open source (OSI)MITspdx.org/licenses/MIT.html ↗Réussi
- Commit ou version publiée au cours de l'année écouléeLast commit or release 2026-08-21github.com/tae2089/code-context-graph ↗Réussi
- OpenSSF ScorecardNon vérifié
- Nom du package non proche d'un package populaireNon vérifié
- Aucun avis critique dans le package ou ses dépendancesNon vérifié
- Aucune instruction cachée destinée au modèle0 tool descriptions and the README read; no override phrases, credential paths or hidden charactersRéussi
- Les outils destructifs sont étiquetésNon vérifié
- Le point de terminaison distant répond à la poignée de main MCPNon vérifié
README
Voir sur GitHubcode-context-graph
Local code analysis tool that parses codebases via Tree-sitter into a knowledge graph. Supports 12 languages, 18 MCP tools, and custom annotation search.
CCG is built primarily for GPT, Claude, Codex, and other LLM-based coding agents. It acts as local or self-hosted context infrastructure: agents can search code by intent, inspect call graphs, trace impact, retrieve docs, and keep responses bounded instead of reading entire repositories into context.
This is a developer-operated tool, not a general SaaS admin product. The expected users are coding agents and developers who can run CLI commands, configure MCP, read logs, and use the generated graph/docs to guide code changes.
Inspired by code-review-graph — a Python-based code analysis tool. This project reimplements and extends the concept in Go with multi-DB support, custom annotation system, and MCP integration for AI-powered code understanding.
Features
- 12 languages: Go, Python, TypeScript, Java, Ruby, JavaScript, C, C++, Rust, Kotlin, PHP, Lua/Luau
- 18 MCP tools: parse, search, graph queries, impact analysis, flow tracing, change detection, documentation discovery, and more
- Evidence-driven code exploration: DB-backed retrieval returns small file-level candidates with matched fields, evidence nodes, and optional docs before agents drill into exact graph nodes
- Browser Wiki UI:
ccg-servercan serve generated docs, tree search, DB-backed retrieval, Context Tray copying, and an Obsidian-style graph viewer - Custom annotations:
@intent,@domainRule,@sideEffect,@mutates,@index— search code by business context (details) - Webhook sync: GitHub / Gitea push events → auto clone + build with per-repo branch filtering and
.ccg.yamlbuild-scope (include_paths/exclude) auto-loading (details) - Multi-DB: SQLite (local), PostgreSQL
- Full-text search: FTS5 (SQLite), tsvector+GIN (PostgreSQL)
Installation
npm / bun (recommended)
npm install -g code-context-graph
# or
bun install -g code-context-graph
The npm package installs both ccg and ccg-server.
go install
go install github.com/tae2089/code-context-graph/cmd/ccg@latest
go install github.com/tae2089/code-context-graph/cmd/ccg-server@latest
Build from source
CGO_ENABLED=1 go build -tags "fts5" -o ccg ./cmd/ccg/
CGO_ENABLED=1 go build -tags "fts5" -o ccg-server ./cmd/ccg-server/
# Or use Makefile (injects version from git tag automatically)
make build
# Local stripped release-style build
make release
Quick Start
# Parse your project. For the default local SQLite database (ccg.db), runtime
# commands create and migrate the database automatically on first use only when
# the schema is missing.
ccg build .
# Build complete: 70 files, 749 nodes, 7387 edges
# Search (includes annotations)
ccg search "authentication"
# Search by business context
ccg search "payment" # finds functions with @intent/@domainRule about payments
# Build generated docs and the browser Wiki compatibility index
ccg docs --out docs
# Serve the browser Wiki UI from built assets; builds the graph for DB-backed APIs
make wiki-run
# Graph statistics
ccg status
# Version info
ccg version
# Namespace isolation (MSA)
ccg build ./backend --namespace backend
ccg search --namespace backend "auth"
ccg docs writes generated Markdown plus .ccg/wiki-index.json as a browser
Wiki compatibility snapshot. The Wiki prefers the graph database for tree
navigation and search, then uses wiki-index.json only when DB-backed
navigation is unavailable. The Wiki's own search box uses DB-backed graph and
annotation evidence; it does not depend on a separately generated retrieval index.
For LLM agents, use search as the first stop for both identifier lookups
("WebhookHandler") and broad natural-language questions such as "how does
webhook sync work?". One query searches both the identifier index and the
reasons authors recorded (@intent, @domainRule), and answers with a small
set of files, each carrying the node_id of every declaration that answered.
Walk from those IDs with get_node, query_graph, trace_flow, and the
impact tools. The same answers are identical on SQLite and PostgreSQL — a
backend parity test in the repository asserts it.
If you use PostgreSQL, a custom SQLite DSN, an existing schema, or a controlled
upgrade workflow, run ccg migrate explicitly before runtime commands. This
also applies when upgrading CCG against an existing default ccg.db created by
an older version. See the CLI Reference for the full
migration contract.
Browser Wiki
ccg-server can serve a React-based Wiki UI at /wiki when --wiki-dir points
at a built web/wiki/dist directory. Docker images include that built UI at
/usr/share/ccg/wiki; standalone binaries keep the assets separate so binary
size stays small.
The Wiki is meant for developers and agents inspecting a generated codebase:
- Tree navigation over folders, packages, files, and annotated symbols
- Keyword search with matched evidence and small file-level result sets
- Rich symbol detail cards from CCG annotations even when a symbol has no generated Markdown file
- Context Tray for collecting files and doc-less symbols into one Markdown bundle that can be copied into another LLM tool
- Graph tab backed by
/wiki/api/graph, showing namespace nodes and edges with filters for structure, calls, imports, types, and symbols
Local development shortcut:
make wiki-run
Use make wiki-run-indexed when you also want generated Markdown and the
wiki-index.json compatibility snapshot before starting the server.
For self-hosted deployments, run ccg-server --wiki-dir <dist-dir> and protect
/wiki/api/* with the same bearer token policy used for /mcp. See
Docker and Runtime Layout
for deployment details.
Demo
Actual output from CCG parsing its own codebase.
1. Parse the Codebase
$ ccg build .
Build complete: 145 files, 1654 nodes, 10489 edges
2. Graph Statistics
$ ccg status
Nodes: 1654
Edges: 3767
Files: 192
Node kinds:
class: 253
file: 145
function: 1111
package: 47
type: 98
Edge kinds:
calls: 1822
contains: 1597
imports_from: 278
implements: 66
inherits: 4
Fallback call analysis:
calls: 1823
fallback_calls: 0
fallback_ratio: 0.00%
3. Code Search
$ ccg search "impact analysis"
internal/app/analyze/impact/impact.go file internal/app/analyze/impact/impact.go:1
mcp.impactRadiusResponse class internal/adapters/inbound/mcp/handler_analysis.go:36
internal/adapters/inbound/mcp/handler_analysis.go file internal/adapters/inbound/mcp/handler_analysis.go:1
mcp.ImpactAnalyzer type internal/adapters/inbound/mcp/deps.go:40
mcp.impactRadiusMetadata class internal/adapters/inbound/mcp/handler_analysis.go:27
mcp.handlers.getImpactRadius function internal/adapters/inbound/mcp/handler_analysis.go:109
$ ccg search "repository sync"
reposync.Service.Sync function internal/app/reposync/service.go:27
remote.buildRepoSyncHTTP function internal/runtime/remote/http.go:88
reposync.syncPayload class internal/app/reposync/queue.go:94
reposync.SyncHandlerFunc type internal/app/reposync/queue.go:21
reposync.SyncQueue class internal/app/reposync/queue.go:118
webhook.SyncFunc type internal/adapters/inbound/webhook/handler.go:22
4. Agent Integration via MCP
After configuring .mcp.json, you can ask an MCP-capable coding agent directly:
"Explain the webhook sync flow in this project"
The agent calls CCG MCP tools and answers directly from the graph:
trace_flow(qualified_name: "webhook.WebhookHandler.ServeHTTP")
→ WebhookHandler.ServeHTTP
→ SyncQueue.Add
→ safeHandle (retry loop: max 3 attempts, exponential backoff 1s→30s)
→ clone (git clone, 15min timeout)
→ build (ccg build, same context)
"Where is the authentication-related code?"
search(query: "authentication")
→ internal/adapters/inbound/webhook/handler.go (HMAC signature validation)
→ cmd/ccg-server/main.go (CCG_WEBHOOK_SECRET / --webhook-secret)
MCP Server
Add .mcp.json to your project:
{
"mcpServers": {
"ccg": {
"command": "ccg",
"args": ["serve", "--db-driver", "sqlite", "--db-dsn", "ccg.db"]
}
}
}
For remote HTTP mode:
Run the self-hosted server with ccg-server and connect to /mcp. The same
server can also expose /wiki when --wiki-dir is configured:
{
"mcpServers": {
"ccg": {
"type": "streamable-http",
"url": "http://your-server:8080/mcp"
}
}
}
MCP-capable clients such as Codex or Claude Code can connect and get access to 18 MCP tools. See MCP Tools Reference for the full list.
Architecture
Source Code → Tree-sitter Parser → Nodes + Edges + Annotations
↓
SQLite / PostgreSQL (GORM)
↓
FTS Search
↓
ccg serve ccg-server
stdio MCP Streamable HTTP + Wiki UI
↓ ↓ ↓ ↑
Coding Agents Remote Clients Browser GitHub / Gitea Webhook
Wiki push → clone → build → DB
See Architecture Details for component breakdown and DB schema.
Documentation
| Guide | Description |
|---|---|
| Korean Guide | 한국어 문서 인덱스 (Korean Documentation Index) |
| CLI Reference | All commands, flags, and config file (.ccg.yaml) |
| Lint | Detailed ccg lint category reference, interpretation guide, and CI usage |
| MCP Tools | 18 MCP tools, agent skills, AI-Driven Annotation |
| Annotations | Annotation system — tags, examples, search |
| Webhook | Webhook sync, branch filtering, HMAC, graceful shutdown |
| Docker | Docker build, MCP server, Wiki UI, PostgreSQL deployment |
| Operations | Deployment profiles, database choice, readiness, webhook operations |
| Runtime Layout | ccg, ccg-server, Wiki serving, and shared ccg-core ownership boundaries |
| Development | Dev guide, integration test, project structure |
| Namespace Migration | Default namespace change and migration guide |
| Architecture | Data flow, components, DB schema |
| CLAUDE.md Guide | Template for projects using CCG |
License
MIT
Questions sur code-context-graph MCP
Comment puis-je rechercher du code en utilisant le contexte métier ?
Vous pouvez utiliser des annotations personnalisées telles que @intent et @domainRule pour rechercher du code basé sur la logique métier plutôt que sur de simples identifiants.
Puis-je utiliser cet outil avec un serveur distant ?
Oui, vous pouvez exécuter le ccg-server pour exposer un endpoint MCP via streamable HTTP et une interface Wiki basée sur React.