cpp-coro-graph
Enables exploring a C++17 coroutine and device-domain call graph through MCP tools, providing symbol search, caller/callee queries, and neighborhood exploration of coroutine-aware codebases.
README
cpp-coro-graph (V1)
Syntax-level C++17 coroutine + device-domain graph.
Primary target: Linux. Stdlib-only Python 3.9+ (no pip deps required to run).
What V1 can do:
- All functions as nodes: definitions
{...}and declarationsFoo();/= default/= delete(headers included) - Class/struct members qualified as
Class::Method(incl. ctor/dtor) - Find
exec::task<…> Name/ functions withco_await/co_return - Draw
awaitedges fromco_await Foo(…)plus normalcalls - Member pipeline:
co_await m.Init()insideSosModel::Callresolves toSosModel::Init(enclosing class + localSosModel m) - Tag device domains (
cpu/gpu/npu/dsp) viarules/devices.json - SQLite DB + HTML visualization + CLI (
query/callers/callees/explore) + MCP
What V1 cannot do:
- Template / macro / overload resolution (needs compile_commands later)
- Cross-thread resume / true parallel edges from time
- Perfect C++ parsing (regex + brace matching, not a compiler)
Install on Linux
git clone https://github.com/ArcherLin13/cpp-coro-graph.git
cd cpp-coro-graph
# option A — no install (recommended for a quick try)
chmod +x scripts/cpp-coro-graph scripts/index_repo.sh
./scripts/cpp-coro-graph index /path/to/your/repo
# option B — install CLI on PATH
python3 -m pip install -e .
cpp-coro-graph index /path/to/your/repo
Requires only python3 (3.9+). Uses the stdlib sqlite3 module.
Index your Linux code tree
# one-shot: index + HTML + status
./scripts/index_repo.sh /path/to/your/linux/repo
# or step by step
python3 -m cpp_coro_graph index /path/to/your/linux/repo
python3 -m cpp_coro_graph viz --db /path/to/your/linux/repo/.cpp-coro-graph/graph.db
python3 -m cpp_coro_graph status --db /path/to/your/linux/repo/.cpp-coro-graph/graph.db
Outputs:
/path/to/your/linux/repo/.cpp-coro-graph/graph.db/path/to/your/linux/repo/.cpp-coro-graph/graph.html(open in a browser)
Run the tool on the Linux machine (or WSL2 Linux filesystem) that holds the sources. Avoid indexing via /mnt/c/... from WSL.
Smoke test:
./scripts/cpp-coro-graph index fixtures/sample --db fixtures/sample/.cpp-coro-graph/graph.db
./scripts/cpp-coro-graph viz --db fixtures/sample/.cpp-coro-graph/graph.db
Viz (module trunk, not full universe)
Default HTML is module → entries → await trunk → double-click expand:
# recommended: one module’s entries + main await flow
python3 -u -m cpp_coro_graph -q viz --db "$DB" --module path/to/module --depth 1
# pin one entry
python3 -u -m cpp_coro_graph -q viz --db "$DB" --around Call --depth 1
# legacy full graph (avoid on large trees)
python3 -u -m cpp_coro_graph -q viz --db "$DB" --full
In the browser: pick a module, click an entry chip, double-click a node to expand the next await layer. Toggle calls if needed. File/contains edges are not shown in this mode.
Query the graph (codegraph-style)
Large graphs (10k+ nodes) — prefer these over HTML:
DB=/path/to/repo/.cpp-coro-graph/graph.db
# search symbols
python3 -u -m cpp_coro_graph -q query OnSos --db "$DB"
# who calls / awaits this
python3 -u -m cpp_coro_graph -q callers OnSos --db "$DB"
# what it calls / awaits / spawns
python3 -u -m cpp_coro_graph -q callees OnSos --db "$DB" --edge-kind calls,await,spawns
# neighborhood BFS
python3 -u -m cpp_coro_graph -q explore OnSos --depth 2 --db "$DB"
# incoming blast radius
python3 -u -m cpp_coro_graph -q impact OnSos --depth 2 --db "$DB"
# JSON for scripting
python3 -u -m cpp_coro_graph -q callers OnSos --db "$DB" --json
If you cd into the indexed repo, --db can be omitted (searches upward for .cpp-coro-graph/graph.db).
Cursor MCP (optional)
{
"mcpServers": {
"cpp-coro-graph": {
"command": "python3",
"args": [
"-m", "cpp_coro_graph", "mcp",
"--db", "/path/to/your/linux/repo/.cpp-coro-graph/graph.db"
],
"cwd": "/path/to/cpp-coro-graph"
}
}
}
Tools: coro_explore, coro_stats.
Custom device rules
Edit rules/devices.json or pass --rules your.json:
{
"patterns": [
{"match": "RunOnNpu", "domain": "npu", "backend": "custom"},
{"match": "clEnqueue", "domain": "gpu", "backend": "opencl"}
]
}
First match wins. Put longer / more specific strings first.
Edge kinds (only four)
| kind | viz | meaning |
|---|---|---|
calls |
solid | direct / sync call (incl. thread helpers) |
await |
dashed | co_await / CO_AWAIT |
contains |
gray | file owns function/class |
inherits |
green dashed | class Child : public Base |
callers / callees default to control = calls+await only (not file/inheritance), so the two directions stay distinct.
python3 -u -m cpp_coro_graph -q callees Call --db "$DB" # await+calls
python3 -u -m cpp_coro_graph -q callers Init --db "$DB"
python3 -u -m cpp_coro_graph -q explore SosModel --edge-kind inherits,contains --db "$DB"
Skipped directories
.git, build, out, third_party, node_modules, .codegraph, bazel-*, .repo, prebuilts, …
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。