Skip to content

快速开始

10 分钟跑起来。

前置条件

  • Node.js 18+
  • Docker(跑 Memgraph)
  • Joern安装指南
  • Claude CLIclaude -p,需要 Claude Max 订阅)

1. 克隆安装

bash
git clone https://github.com/Tommylilinfeng/context-chain.git
cd context-chain && npm install

2. 启动 Memgraph

bash
docker compose up -d

Memgraph 跑在 7687 端口,Memgraph Lab 跑在 3000 端口(http://localhost:3000)。

3. 启动 Dashboard

bash
npm run dashboard
# → http://localhost:3001

4. 通过 Dashboard 设置

  1. System → 添加你的 repo(名称、路径、语言)
  2. System → 生成 CPG(Joern 代码分析)
  3. System → Full Setup(初始化 schema + 导入代码结构)
  4. Quick Scan → 选一个 repo,点 Scan → 决策就出来了

或者通过 CLI

bash
npm run db:schema                                         # 初始化 schema
npm run ingest:cpg -- --file data/your-repo.json          # 导入代码结构
npm run analyze -- --repo my-repo                         # 全量扫描
npm run mcp                                               # 启动 MCP server

TIP

全量扫描支持中断恢复:按 Ctrl+C 停止,npm run analyze -- --repo my-repo --continue 继续。

5. 连接 Claude Code

在你项目的 .mcp.json 中添加:

json
{
  "mcpServers": {
    "context-chain": {
      "command": "/bin/bash",
      "args": ["/path/to/context-chain/mcp-start.sh"]
    }
  }
}

之后 Claude Code 在你的代码库工作时,就能查询"这个函数为什么这样写?"并得到真实答案。

下一步

基于 Apache 2.0 协议发布