Skip to main content
Glama
ArcherLin13

cpp-coro-graph

by ArcherLin13

cpp-coro-graph (V1)

语法层面的 C++17 协程 + 设备域 图。
主要目标平台:Linux。 仅依赖标准库的 Python 3.9+(运行无需 pip 依赖)。

V1 能做什么:

  • 所有函数作为节点:定义 {...} 以及声明 Foo(); / = default / = delete(包含头文件)

  • 类/结构体成员限定为 Class::Method(含构造函数/析构函数)

  • 查找 exec::task<…> Name / 含 co_await / co_return 的函数

  • co_await Foo(…) 绘制 await 边,外加普通 calls

  • 成员管道SosModel::Call 内部的 co_await m.Init() 解析为 SosModel::Init(外围类 + 局部变量 SosModel m

  • 通过 rules/devices.json 标记设备域cpu / gpu / npu / dsp

  • SQLite 数据库 + HTML 可视化 + CLI(query / callers / callees / explore)+ MCP

V1 不能做什么:

  • 模板 / 宏 / 重载解析(后续需要 compile_commands)

  • 跨线程恢复 / 基于时间的真实并行边

  • 完美的 C++ 解析(正则 + 花括号匹配,并非编译器)

在 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

仅需 python3(3.9+)。使用标准库 sqlite3 模块。

Related MCP server: cpp-semantic-graph

索引你的 Linux 代码树

# 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

输出:

  • /path/to/your/linux/repo/.cpp-coro-graph/graph.db

  • /path/to/your/linux/repo/.cpp-coro-graph/graph.html(在浏览器中打开)

在持有源码的 Linux 机器(或 WSL2 Linux 文件系统) 上运行该工具。避免从 WSL 通过 /mnt/c/... 进行索引。

冒烟测试:

./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

可视化(模块主干,而非完整全量)

默认 HTML 为 模块 → 入口 → await 主干 → 双击展开

# 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

在浏览器中:选择模块,点击入口标签,双击节点以展开下一层 await。如需可切换 calls。此模式下不显示文件/contains 边。

查询图(codegraph 风格)

大型图(1 万+ 节点)——优先使用这些而非 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

如果你 cd 到已索引的仓库中,可省略 --db(会向上查找 .cpp-coro-graph/graph.db)。

Cursor MCP(可选)

{
  "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"
    }
  }
}

工具:coro_explorecoro_stats

自定义设备规则

编辑 rules/devices.json 或传入 --rules your.json

{
  "patterns": [
    {"match": "RunOnNpu", "domain": "npu", "backend": "custom"},
    {"match": "clEnqueue", "domain": "gpu", "backend": "opencl"}
  ]
}

首个匹配生效。将更长 / 更具体的字符串放在前面。

边的类型(仅四种)

kind

viz

meaning

calls

solid

直接 / 同步调用(含线程辅助函数)

await

dashed

co_await / CO_AWAIT

contains

gray

文件拥有函数/类

inherits

green dashed

class Child : public Base

callers / callees 默认使用控制流 = 仅 calls+await(不含文件/继承),因此两个方向保持区分。

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"

跳过的目录

.gitbuildoutthird_partynode_modules.codegraphbazel-*.repoprebuilts、……

A
license - permissive license
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    Not graded
    quality
    F
    maintenance
    Provides a local code knowledge graph for Java projects, enabling querying of classes, methods, fields, calls, inheritance, and imports via MCP tools like query, context, impact, and cypher.
    1
  • F
    license
    Not graded
    quality
    B
    maintenance
    Builds a semantic knowledge graph of C++ code and exposes 9 MCP tools for AI assistants to search classes, functions, inheritance, callers, callees, overrides, and more.
    3
  • F
    license
    Not graded
    quality
    A
    maintenance
    CodeGraph MCP is a powerful standalone tool that parses your entire C/C++ codebase into a semantic knowledge graph and seamlessly exposes it to AI coding assistants via the Model Context Protocol (MCP). By providing AI (like Claude Desktop, Cursor, or Google Antigravity) with a structural map of your project—including caller/callee relationships, file dependencies, and dynamic function definition

View all related MCP servers

Related MCP Connectors

  • Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.

  • MCP server for static security analysis of Android source code

  • Persistent memory and cross-session learning for AI coding assistants (hosted remote MCP).

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ArcherLin13/cpp-coro-graph'

If you have feedback or need assistance with the MCP directory API, please join our Discord server