WC

websines/codegraph-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

20 stars 5 forks 质量 52 趋势 10

CodeGraph MCP——为你的编码代理提供跨团队代码库的持续学习,同时为编码代理节省代币提供超能力

概览

一个自用的 Rust MCP 服务器,为 AI 编码代理在会话间持久的代码理解和内存提供。作为个人工具构建,用于探索当你赋予 LLM 对代码库符号图、会话状态和累积项目知识的结构化访问时会发生什么。 Codegraph 作为 MCP 服务器(stdio transport)运行,并公开了 AI 代理可以调用的 26 个工具: - — 用树置图(Rust、TypeScript、JavaScript、Python、Go)解析源代码,提取符号及其关系(调用、导入、继承),并以有向图形式存储。代理可以搜索符号、遍历依赖关系,并理解文件结构而无需读取整个文件。 - — 跟踪代理当前任务、子任务、决策和工作上下文。能够通过上下文窗口压缩,使代理能够从中断处继续。 - — 记录模式(有效的事项)、失败(需避免的陷阱)和解决方案谱系(带结果的尝试链)。

概述(AI 翻译)

一个自用的 Rust MCP 服务器,为 AI 编码代理在会话间持久的代码理解和内存提供。作为个人工具构建,用于探索当你赋予 LLM 对代码库符号图、会话状态和累积项目知识的结构化访问时会发生什么。

它的作用

Codegraph 作为 MCP 服务器(stdio transport)运行,并公开了 AI 代理可以调用的 26 个工具:

  • 代码图 — 用树状分析源代码(Rust、TypeScript、JavaScript、Python、Go),提取符号及其关系(调用、导入、继承),并以有向图形式存储。代理可以搜索符号、遍历依赖关系并理解文件结构,而无需读取整个文件。

  • 会话内存 — 跟踪代理当前任务、子任务、决策和工作上下文。经由上下文窗口压缩保存,代理可以从中断处继续。

  • 学习系统 — 记录模式(有效的方法)、失败(需要避免的陷阱)和解决方案的谱系(尝试链与结果)。一个反映引擎将结果转化为可重复使用的知识。一个建议系统将这三者结合起来,为新任务推荐方法。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Codegraph MCP

A self-use Rust MCP server that gives AI coding agents persistent code understanding and memory across sessions. Built as a personal tool to explore what happens when you give an LLM structured access to a codebase’s symbol graph, session state, and accumulated project knowledge.

What It Does

Codegraph runs as an MCP server (stdio transport) and exposes 26 tools that an AI agent can call:

  • Code Graph — Parses source code with tree-sitter (Rust, TypeScript, JavaScript, Python, Go), extracts symbols and their relationships (calls, imports, inherits), and stores them as a directed graph. The agent can search symbols, traverse dependencies, and understand file structure without reading entire files.

  • Session Memory — Tracks the agent’s current task, subtasks, decisions, and working context. Survives context window compaction so the agent can resume where it left off.

  • Learning System — Records patterns (things that worked), failures (gotchas to avoid), and solution lineage (attempt chains with outcomes). A reflection engine converts outcomes into reusable knowledge. A suggestion system combines all three to recommend approaches for new tasks.

  • Skill Distillation — Generates a SKILL.md from accumulated patterns, failures, and conventions — a machine-readable summary of project-specific knowledge.

  • Cross-Language Inference — Detects REST/GraphQL calls in frontend code and matches them to backend route definitions.

  • Bash Compression — Compresses verbose command output (git status, test results, directory listings) to reduce token usage.

Tech Stack

Component Technology
Language Rust (async, tokio)
Protocol MCP over stdio (JSON-RPC 2.0)
Parsing tree-sitter (5 language grammars)
Graph petgraph (directed graph with BFS traversal)
Storage libSQL / SQLite (two databases: code graph + learning)
Hashing xxh3 (content-based change detection)
Config TOML

Architecture

src/
├── main.rs              # Entry point
├── config.rs            # Project root detection, config.toml
├── mcp/                 # MCP protocol layer
│   ├── protocol.rs      # JSON-RPC 2.0 + MCP types
│   ├── transport.rs     # Stdio transport
│   ├── server.rs        # Request dispatch, lazy init
│   └── tools.rs         # Tool registry (26 tools)
├── store/               # Persistence
│   ├── db.rs            # SQLite CRUD
│   ├── graph.rs         # In-memory petgraph
│   └── migrations.rs    # Schema versioning
├── code/                # Code analysis
│   ├── parser.rs        # tree-sitter symbol extraction
│   ├── indexer.rs       # Incremental indexing + cross-file resolution
│   ├── languages.rs     # Language configs + grammars
│   └── cross_language.rs
├── session/             # Session state machine
│   └── state.rs         # Task, decisions, context tracking
├── learning/            # Learning system
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "codegraph": { "command": "/absolute/path/to/codegraph-mcp/target/release/codegraph", "type": "stdio" } } }