快速开始
10 分钟跑起来。
前置条件
- Node.js 18+
- Docker(跑 Memgraph)
- Joern(安装指南)
- Claude CLI(
claude -p,需要 Claude Max 订阅)
1. 克隆安装
bash
git clone https://github.com/Tommylilinfeng/context-chain.git
cd context-chain && npm install2. 启动 Memgraph
bash
docker compose up -dMemgraph 跑在 7687 端口,Memgraph Lab 跑在 3000 端口(http://localhost:3000)。
3. 启动 Dashboard
bash
npm run dashboard
# → http://localhost:30014. 通过 Dashboard 设置
- System → 添加你的 repo(名称、路径、语言)
- System → 生成 CPG(Joern 代码分析)
- System → Full Setup(初始化 schema + 导入代码结构)
- 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 serverTIP
全量扫描支持中断恢复:按 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 在你的代码库工作时,就能查询"这个函数为什么这样写?"并得到真实答案。
下一步
- 了解五槽位检索——决策如何被索引和找到
- 配置 ckg.config.json 支持多 repo
- 设置 Session 摄入,从 AI 编程对话中持续捕获决策
- 浏览 MCP 工具