Skip to main content
Glama
cpp-coro-graph

cpp-coro-graph

by ArcherLin13

cpp-coro-graph (V1)

구문 수준의 C++17 코루틴 + 디바이스 도메인 그래프.
주요 대상: Linux. 표준 라이브러리만 사용하는 Python 3.9+ (실행에 pip 의존성 불필요).

V1이 할 수 있는 것:

  • 모든 함수를 노드로**: 정의 {...} 및 선언 Foo(); / = default / = delete (헤더 포함)

  • 클래스/구조체 멤버는 Class::Method로 한정 (ctor/dtor 포함)

  • 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 DB + 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: prayog-repo-fleet

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 스타일)

대형 그래프(10k+ 노드) — 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_explore, coro_stats.

사용자 정의 디바이스 규칙

rules/devices.json을 편집하거나 --rules your.json을 전달하세요:

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

첫 번째 일치 항목이 우선합니다. 더 길고 구체적인 문자열을 먼저 배치하세요.

엣지 종류 (4개뿐)

종류

시각화

의미

calls

실선

직접 / 동기 호출 (스레드 헬퍼 포함)

await

점선

co_await / CO_AWAIT

contains

회색

파일이 함수/클래스를 소유함

inherits

녹색 점선

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"

건너뛰는 디렉터리

.git, build, out, third_party, node_modules, .codegraph, bazel-*, .repo, prebuilts, …

Available Tools

11 tools
ccg_calleesB

What this symbol calls / awaits (outgoing). Ordered by source line (#1,#2).

Inputs: query (required), limit, show_unresolved.

ccg_callersB

Who calls / awaits this symbol (incoming control edges).

Inputs: query (required), limit, show_unresolved.

ccg_exploreC

Neighborhood around a symbol: in/out + optional BFS depth (like codegraph explore for coroutines).

Inputs: query (required), depth, limit, edge_kind, +1 more.

ccg_impactC

Incoming blast radius. Symbols: callers. Files (file:… / *.h): importers via #include.

Inputs: query (required), depth, limit.

ccg_nodeC

One symbol or file: location + related edges. Symbols → callers/callees (control). Files → contains (symbols) + includes (headers) + importers.

Inputs: query (required), limit, show_unresolved.

ccg_pathC

Shortest path between two symbols (control) or two files (includes). Use file:path or *.hpp queries for include topology.

Inputs: dst (required), src (required), depth, limit.

ccg_queryB

Search symbols or file nodes by name/qname/path fragment. Use kind=file for files; namespace= for C++ namespace filter (exact or nested prefix). Empty query + namespace lists that module.

Inputs: kind, limit, query, namespace, +1 more.

ccg_seqA

Ordered calls/await sequence inside a function (by source line). Preferred over explore edge_kind=seq for understanding in-function order.

Inputs: query (required), limit, show_unresolved.

ccg_statsA

cpp-coro-graph: node/edge counts by kind and device. Optional by_namespace=true for per-namespace symbol counts. Call first to confirm the graph DB is loaded.

Inputs: limit, namespace, by_namespace.

coro_exploreD

Alias of ccg_explore (legacy).

Inputs: query (required), depth, limit, device.

coro_statsC

Alias of ccg_stats.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.8/5.0

    Scored across 11 tools

    Disambiguation3/5

    Many tools have clear distinct purposes (stats, query, node, callers, callees, seq, path, impact), but ccg_explore and ccg_seq overlap with ccg_node's related edges and callers/callees, creating some ambiguity. The presence of aliases (coro_stats, coro_explore) adds confusion for an agent.

    Naming Consistency4/5

    Most tools follow a consistent ccg_verb or ccg_noun pattern (ccg_stats, ccg_query, ccg_node, ccg_callers, etc.), which is predictable. However, the aliases coro_stats and coro_explore deviate from the ccg_ prefix, slightly breaking consistency.

    Tool Count4/5

    11 tools is a reasonable count for a graph-based code analysis server covering stats, query, traversal, and impact. The two aliases are redundant but don't bloat the count excessively.

    Completeness4/5

    The tool set covers essential operations: graph stats, symbol/file lookup, edge exploration (callers, callees, sequence), path finding, and impact analysis. It lacks explicit filtering or aggregation tools, but the core analysis surface is well-covered for a read-only graph explorer.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      C
      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
      B
      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
      1
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI coding agents to query a local, continuously updated symbol graph of a codebase, providing ranked search, caller/callee exploration, dependency paths, and git-diff impact analysis through MCP tools.
      3 npm
      Apache 2.0