Skip to content

feat: graph-insight MCP tools (impact_of, file_summary, path_between, import_cycles) + role/layer filters#68

Merged
joy-software merged 1 commit into
developfrom
feat/query-tools
Jun 7, 2026
Merged

feat: graph-insight MCP tools (impact_of, file_summary, path_between, import_cycles) + role/layer filters#68
joy-software merged 1 commit into
developfrom
feat/query-tools

Conversation

@joy-software

Copy link
Copy Markdown
Contributor

Batch A from the roadmap (FEAT-1, 2, 4, 6). Four new read-only, federated MCP tools over the existing graph, plus role/layer search filters. No new ingestion.

New tools (server/tools_insight.py)

  • file_summary(file_path) — one-shot orientation: role/layer/lang/module_doc + functions/classes (name, lines, doc head) + imports + importers. Replaces "read the whole file to orient."
  • impact_of(symbol_or_file, max_depth=3) — reverse blast radius via bounded reverse-BFS over CALLS (callers) or IMPORTS (importers), grouped by role/layer, with reaching endpoints. Carries the name-matched-CALLS over-count caveat.
  • path_between(src, dst, edge="CALLS") — shortest path over CALLS/IMPORTS (bounded BFS).
  • import_cycles(limit=50) — Tarjan SCC over the IMPORTS file graph.

FEAT-6

search_symbols / symbol_lookup gain optional role= / layer= filters (backward compatible).

Notes

  • Backend-neutral (GraphDB protocol only, no raw SQL).
  • impact_of/path_between over CALLS traverse intra-file chains today because _resolve_calls is same-file-scoped (BUG-2); IMPORTS traversal is cross-file. Documented in the tool notes.

Test plan

  • tests/test_server/test_insight_tools.py (8 tests): file_summary, 2-file cycle, impact_of importer+caller, path_between, role filter
  • full suite green; ruff + no-ai-tells clean

Add four read-only, federated graph-insight tools in
codegraph/server/tools_insight.py:

- file_summary: one-shot file orientation (role/layer/lang/module_doc,
  defined functions and classes, resolved imports, and importers).
- impact_of: reverse blast radius via bounded reverse-BFS over CALLS
  (callers) or IMPORTS (importers), grouped by role/layer with reaching
  endpoints. Carries the name-matched CALLS over-count caveat.
- path_between: shortest path over CALLS or IMPORTS via forward BFS,
  reported per scope so it never crosses repo boundaries.
- import_cycles: SCC detection (iterative Tarjan) over the IMPORTS graph.

Register the module in server/__init__.py. Add role/layer filters to
search_symbols and symbol_lookup in tools_query.py (backward compatible,
empty = no filter).

Tools are tested via a fake mcp whose .tool() decorator captures the
closures unchanged, then calling them against a tiny indexed tmp repo.
@joy-software joy-software merged commit 9b4e17e into develop Jun 7, 2026
8 checks passed
@joy-software joy-software deleted the feat/query-tools branch June 7, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant