Skip to main content
Glama

codegraph-mcp

用于 GitHub 仓库的知识图谱 MCP 服务器。将任意 GitHub 仓库的代码导入 Neo4j 图(Repository / File / Function 节点;CONTAINS / DEFINES / IMPORTS / CALLS 边),并将该图作为只读 MCP 工具暴露给任何 MCP 主机——Claude Desktop、opencode、Cursor 或任何支持模型上下文协议的客户端。

状态

v0.1 — stdio 传输,Neo4j 5.x 后端,Python ast + tree-sitter(JS/TS/TSX)解析。

Related MCP server: revibe-mcp

快速开始

git clone <codegraph-mcp> && cd codegraph-mcp
uv sync --extra dev              # all deps pinned via uv.lock
docker compose up -d             # Neo4j on bolt://localhost:7687
cp .env.example .env
uv run pytest -m "not slow and not integration"

导入仓库

uv run codegraph ingest https://github.com/<owner>/<name>
# → {"graph_id": "owner/name", "files": 142, "functions": 880, ...}

连接 MCP 主机

Claude Desktop(claude_desktop_config.json)

{
  "mcpServers": {
    "codegraph": {
      "command": "uv",
      "args": ["run", "--directory", "C:\\path\\to\\codegraph-mcp", "codegraph", "serve"]
    }
  }
}

opencode(在 opencode.json 中)

{
  "mcp": {
    "codegraph": {
      "type": "local",
      "command": ["uv", "run", "--directory", "/path/to/codegraph-mcp", "codegraph", "serve"]
    }
  }
}

Cursor(~/.cursor/mcp.json)

{
  "mcpServers": {
    "codegraph": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/codegraph-mcp", "codegraph", "serve"]
    }
  }
}

MCP Inspector(用于在没有 MCP 主机的情况下测试)

uv run mcp dev src/codegraph/server.py

CLI

命令

用途

codegraph ingest <url> [--branch main] [--force]

克隆、解析并将仓库加载到 Neo4j

codegraph serve

运行 MCP 服务器(stdio)——由 MCP 主机启动

codegraph reset --graph-id <owner/name>

从 Neo4j 中硬删除一个仓库(破坏性操作)

codegraph ls

列出已导入的仓库

工具

工具

用途

list_repos

列出已导入的仓库

init_repository_node

确认仓库的图存在;返回文件/函数计数

get_repo_structure

路径下的分层树视图

find_file_dependencies

旗舰功能: 哪些文件/函数依赖于(或被依赖于)某个文件

search_nodes

按名称查找函数/文件

get_node_detail

单个节点的详细信息(行范围、类型)

技术栈

Python 3.11+、mcp>=1.27,<2(稳定的 v1.x FastMCP)、Neo4j 5.x、pydantic v2、tree-sitter、GitPython、pytest、ruff、mypy、uv。

有关架构、约定和测试策略,请参阅 CONTRIBUTING.md。

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    AI-native code intelligence graph that builds a persistent knowledge graph of your codebase in Neo4j and exposes it to AI assistants via MCP, enabling contextual code analysis, impact analysis, and dependency tracking.
    23
    -
  • A
    license
    A
    quality
    D
    maintenance
    Enables analysis of any GitHub repository to get architecture, file roles, execution flows, system design Q\&A, and structured agent context. Works with MCP-compatible clients like Claude Desktop, Cursor, and Windsurf.
    6
    39 npm
    1
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides code intelligence for AI coding agents by indexing repositories into a hybrid knowledge graph, enabling agents to query dependencies, impact, and context through 28 MCP tools.
    3
    Apache 2.0
  • A
    license
    Not graded
    quality
    C
    maintenance
    Embeds your codebase into a local vector and graph database and exposes it as an MCP tool, enabling AI assistants to perform fast semantic search over your code using Graph RAG.
    4
    MIT