
Code-Graph-RAG
io.github.vitali87由 GitHub 账号 vitali87 发布v0.5.0更新于 Nov 3, 2026
面向多语言代码库的知识图谱RAG:用自然语言索引、查询和编辑代码。
AI 翻译由 AI 模型根据下方的原文描述翻译,可能有误。
原文描述
Knowledge-graph RAG for multi-language codebases: index, query and edit code in natural language.
概览
Code-Graph-RAG 的本地 MCP 服务;无需登录;STDIO。
暂无 AI 概览:以下信息来自注册中心条目和服务本身。
安装
在 SourceWeft 中
- 打开 控制台中的 Code-Graph-RAG,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
[vitali87/code-graph-rag | Trendshift]
[CI] [Codecov] [Quality Gate Status] [Enterprise Support] [PyPI Version] [PyPI Downloads] [SkillsLLM Security Check] [OpenSSF Scorecard] [OpenSSF Best Practices]
Code-Graph-RAG
Code-Graph-RAG parses a multi-language codebase with Tree-sitter, sharpened by compiler-grade frontends and runtime traces where available, builds a knowledge graph of its structure in an embedded graph database that needs no server, and lets you query, edit, and optimise that code in plain English. It works across a monorepo of mixed languages under one unified graph schema.
1. Index: cgr start --update-graph parses a repository into a knowledge graph (sped up)
2. Ask: cgr start answers questions and edits code, grounded in that graph
[cgr agent answering questions about the indexed repository]
Latest News 🔥
- Rust Upgrade: Updated Rust to version 1.99.1-slim-trixie.
- Signature Functionality: Added support for reading and writing JavaScript headers for change signatures, including the ability to change the signature of JavaScript functions or methods.
- macOS Compatibility: The build now leaves macOS-14 support.
See NEWS.md for the full history.
What It Does
Point Code-Graph-RAG at a repository and it reads every source file, extracts functions, classes, methods, modules, and the relationships between them, and stores the result as an interconnected graph. Once the graph exists you can:
- Ask questions about the codebase in natural language and get answers grounded in the real structure.
- Retrieve the actual source of any function, class, or method by name or by intent.
- Edit code through the agent with AST-based surgical patching and a diff preview before anything changes.
- Optimise code against language best practices or your own coding standards.
- Find dead code by walking call and reference edges from entry points.
- Search and rewrite structurally by AST pattern with ast-grep.
- Overlay runtime behaviour: trace a test run (or pull production eBPF profiles) with
cgr traceand merge the calls that actually happened into the graph, exposing dispatch that static analysis cannot see.
How It Works
The system has two components:
- Multi-language parser. A Tree-sitter based parser reads the codebase and ingests functions, classes, methods, modules, and their relationships into the graph under a single language-agnostic schema. Where a toolchain is available, compiler-grade frontends layer exact facts on top (libclang for C/C++,
go/typesfor Go, and opt-in Roslyn,javacand Jedi for C#, Java and Python), and dynamic tracing merges calls observed at runtime. Tree-sitter stays the backbone: a trace only sees code that ran, and a compiler frontend only covers what its toolchain can build. - RAG system (
codebase_rag/). An interactive CLI that turns natural language into Cypher queries, retrieves matching code, and drives AI-powered editing and optimisation.
The graph is stored in an embedded SQLite file by default. Memgraph and Neo4j are opt-in backends that run the same Cypher; Graph Backends compares them.
See the Architecture Overview and Graph Schema for the full picture.
Supported Languages
Python, TypeScript, TSX, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua, Dart, and Julia are fully supported. Scala is in development, and Ruby, Kotlin, Swift, Elixir, Haskell, Solidity, Bash, and Nix have structural support (modules, functions, classes where the language has them, and imports) through the pluggable ast-grep tier. See the Language Support matrix for per-language capabilities.
Installation
cgr is published to PyPI. Install it system-wide with the treesitter-full (tree-sitter grammars), ast-grep (Ruby, Kotlin, Swift, Elixir, Haskell, Solidity, Bash, Nix) and semantic (vector search) extras:
Which version am I getting?
Three version lines exist and they intentionally differ:
So the newest tag on main usually runs ahead of the newest release, often by
tens of patch versions; they coincide only just after a release. Nothing is
stuck, the cadences differ by design. A security fix, a breaking change or a
merge a maintainer labels release now does NOT wait for the cadence: each ships
a release and a PyPI upload immediately.
uv tool install and pipx install give you the newest PyPI version, which is the
newest RELEASE, not the newest tag. Interim tags exist so every merge is
addressable; binaries and PyPI uploads follow the cadence above.
To run code newer than the latest release, install from git:
To upgrade an existing install, run uv tool upgrade code-graph-rag (with pipx, pipx upgrade code-graph-rag, or pipx reinstall code-graph-rag for a git install). Upgrade covers the other install methods.
You also need Python 3.12+ and ripgrep. The graph lives in an embedded SQLite file by default, so there is no database server to run: no Docker and no cmake. Memgraph and Neo4j remain available as opt-in backends (Graph Backends). Full prerequisites, source installs, and environment setup are in the Installation guide.
[!NOTE] The wheel is pure Python (
py3-none-any), so it installs on any platform with Python 3.12 or newer. Older system interpreters (Debian Bookworm ships 3.11) need the interpreter pinned explicitly; see Installation for the commands.
Quick Start
The graph is written to ~/.cgr/graph.sqlite (set SQLITE_GRAPH_PATH to move it).
To use Memgraph instead, install the driver with the memgraph extra, set
GRAPH_BACKEND=memgraph, and start the packaged Memgraph + Qdrant stack with
cgr daemon up.
Repeat the first command for each repository you want indexed; the graph is
shared, and syncing one project leaves the others alone. To start over from an
empty graph, add --clean — it deletes every project in the shared graph,
not just this one, and asks for confirmation first when other
projects would be destroyed.
A default index leaves out the opt-in capture groups; add them with --capture or CGR_CAPTURE.
The Quick Start guide walks through parsing, querying, and exporting in five minutes.
MCP Server
Code-Graph-RAG runs as an MCP server so Claude Code and other MCP clients can query and edit your codebase directly. See the MCP Server guide for setup.
Documentation
Getting Started
User Guide
- CLI Reference
- Interactive Querying
- Code Optimisation
- Dead Code Detection
- Dynamic Call Tracing
- Graph Export
- Real-Time Updates
- C/C++ Semantic Mode
- MCP Server
- Porting Between Languages
Architecture
Python SDK
Advanced
Enterprise Services
Code-Graph-RAG is open source and free to use. For organisations that need more, we offer fully managed cloud-hosted solutions and on-premise deployments:
- Cloud-Hosted Deployment: Managed cloud infrastructure for both the graph database and the AI agent connection. Zero infrastructure overhead, so we handle scaling, updates, and availability while your team focuses on building.
- On-Premise & Air-Gapped Deployment: Deploy Code-Graph-RAG entirely within your own environment, including air-gapped networks. Full data sovereignty for regulated industries and security-sensitive organisations.
We also offer custom development, integration consulting, technical support contracts, and team training.
View plans & pricing at code-graph-rag.com
Contributing
Please see CONTRIBUTING.md for contribution guidelines. Good first PRs come from the TODO issues.
Support
For issues or questions, check the Troubleshooting guide first, then open an issue.
If cgr is useful to you, please consider pledging support on GitHub Sponsors. cgr links the page under cgr --version and, in a terminal, after most commands finish; set CGR_SPONSOR_PLEDGE=false to hide that line.
Accessibility
ACCESSIBILITY.md describes what cgr and its documentation support for people using assistive technology or alternative settings, the known limitations and their workarounds, and how to report a barrier.
License
MIT. See LICENSE.
Third-party components and their licences are credited on the Credits page.
来源:README.md,提交 a785348
工具
0版本历史
1- v0.5.0最新Nov 3, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分