跪拜 Guibai
← All articles
AI Programming

Joy-Code-Graph Turns a Million-Line Repo into a Queryable Map for AI Coders

By 京东云开发者 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Code-graph tooling is moving from research demos into self-hosted services that plug directly into AI coding platforms via MCP. The branch-stored graph pattern means teams get persistent, version-aligned context that survives individual sessions, which changes the economics of running graph builders from per-task cost to a one-time build.

Summary

AI coding assistants stumble on large repositories because they cannot see how functions, classes, and modules relate. Joy-Code-Graph solves this by building a full code knowledge graph as a standalone HTTP+MCP service that runs on a company's own infrastructure. Instead of packing heavy parser dependencies into every sandbox, the service exposes 11 MCP tools over a single SSE endpoint, giving AI agents instant, structured context.

The design makes three deliberate trade-offs. Self-deployment keeps source code and graph data inside the organization's boundary, with in-process callbacks locked to 127.0.0.1 and Git host whitelisting. A shared engine with per-task session isolation handles multi-user concurrency without per-sandbox installs. After each build, the graph is pushed to a dedicated `codegraph/<projectId>` branch in the project's own repository, so the graph version stays aligned with the code version and becomes a reusable team asset rather than a throwaway artifact.

Takeaways
CodeGraph pre-parses a repository into a symbol network of functions, classes, interfaces, call chains, and dependency edges so AI can query global context in one shot.
Running CodeGraph inside every sandbox is too heavy; the service is instead deployed as a standalone HTTP+MCP server that sandboxes call remotely.
Self-deployment keeps source code and graph data within the organization's own infrastructure, with callbacks locked to 127.0.0.1 and Bearer Token auth.
Git host whitelisting restricts cloning to trusted repositories, and all artifacts land in a self-managed data directory.
Eleven MCP tools are exposed over a single SSE endpoint, giving Joygen full graph capabilities with zero sandbox dependencies.
A shared engine with independent per-task sessions supports multi-user, multi-task concurrency.
After building, the graph is automatically pushed to a `codegraph/<projectId>` branch in the project's own repo, keeping graph and code versions aligned.
Storing the graph in a branch makes it reusable across tasks and team members, avoiding repeated rebuilds.
Conclusions

The branch-as-storage pattern for code graphs is under-discussed. It sidesteps the need for a separate graph database and ties freshness directly to Git history, which is a pragmatic choice for teams already drowning in infrastructure.

Locking internal callbacks to 127.0.0.1 is a simple but effective security boundary that many AI-tool vendors skip when they default to cloud-only graph construction.

Exposing graph capabilities as MCP tools rather than a custom plugin API bets on the emerging standard for AI-tool integration, which could make the service portable across platforms beyond Joygen.

Concepts & terms
Code Knowledge Graph (CodeGraph)
A pre-built structured representation of a codebase where functions, classes, interfaces, call chains, and dependencies are modeled as a graph. AI assistants query it to understand code relationships without scanning files at runtime.
MCP (Model Context Protocol)
An open protocol for connecting AI models to external tools and data sources. It defines how tools are discovered and invoked, often over HTTP with SSE transport, allowing AI agents to call services like graph queries without custom integrations.
Joygen
JD Cloud's cloud-based AI code generation and deployment platform. It runs AI coding tasks inside sandboxes and can connect to external services like CodeGraph via MCP endpoints.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗