fix(serve): better MCP tool descriptions, depth default 1, filename guard#402
Open
sdeonvacation wants to merge 1 commit intosafishamsi:v4from
Open
fix(serve): better MCP tool descriptions, depth default 1, filename guard#402sdeonvacation wants to merge 1 commit intosafishamsi:v4from
sdeonvacation wants to merge 1 commit intosafishamsi:v4from
Conversation
7e8a495 to
63828a9
Compare
Three improvements to the MCP server (serve.py): 1. Better tool descriptions with usage guidance and anti-patterns. query_graph: explicit 'use for / do NOT use for' guidance. get_node / get_neighbors: note they take symbol names, not filenames. god_nodes: clarify 'orientation only, not during investigations'. 2. query_graph depth default 1 (was 3). Depth 3 on a large code graph can return 500+ nodes, blowing the token budget. Default 1 returns a focused subgraph; users can increase if needed. Description updated to say 'Start with 1'. 3. Filename guard in get_node and get_neighbors. When passed 'auth.py' instead of 'DigestAuth', both tools now return a helpful error and list the top symbols in that file, rather than silently returning 'not found'.
63828a9 to
eace61b
Compare
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.
What this changes
Three improvements to `graphify/serve.py` (the MCP server). All 433 tests pass, ruff clean.
1. Better tool descriptions with usage guidance
Tool descriptions now tell the LLM when to use and when not to:
Without this guidance, LLMs routinely pass filenames to `get_node` and get confusing "not found" errors.
2. `query_graph` depth default: 3 → 1
Depth 3 on a large code graph (400+ files) can return 500+ nodes in a single traversal, blowing the token budget and returning noise. Depth 1 returns a focused subgraph centered on the matching nodes. Users can increase if results are too sparse. Description updated accordingly.
3. Filename guard in `get_node` and `get_neighbors`
Before this change, passing `'auth.py'` to `get_node` returns `"No node matching 'auth.py' found."` — unhelpful.
After:
```
'auth.py' looks like a filename, not a symbol. Pass a class or function name instead. Symbols in that file: DigestAuth, BasicAuth, BearerAuth, NetRCAuth, Auth.
```
Two new helpers added — no new imports, no hardcoded extension lists:
Checklist