feat: graph-insight MCP tools (impact_of, file_summary, path_between, import_cycles) + role/layer filters#68
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_lookupgain optionalrole=/layer=filters (backward compatible).Notes
impact_of/path_betweenover CALLS traverse intra-file chains today because_resolve_callsis 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