Repository navigation
feat(serve): add MCP tool annotations and server instructions - #5300
debojyoti10CC wants to merge 2 commits into
Conversation
tools/list returned annotations=null for every tool and initialize sent no instructions. Mark all tools readOnlyHint=True with a title, and the three gh-backed PR tools openWorldHint=True, via one table applied where project_path is injected so new tools stay in lockstep. Pass a short usage guide as Server(instructions=...) on both mcp 1.x and 2.x paths. Fixes Graphify-Labs#5208 Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks for the pull request, @debojyoti10CC. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify code review 
Review incomplete · dcb8bb7e959d
Note
Merge confidence: 4/5 · Partly reviewed · 🟠 High impact
No issues reported · 3 of 3 files inspected
The review stopped before it finished; nothing it found blocks this PR.
1 not re-checked
What this review covered
- The first review pass ran out of time.
- 3 of 3 changed files inspected. This is scope, not a correctness guarantee.
Code graph and static checks · 896 functions depend on this change
Impact & health
Impact — 896 functions depend on the 225 functions this change touches.
Health — grade B; 10 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):
dispatch_command()— 8 callers, 156 callees (high)_query_graph_text()— 55 callers, 7 callees (high)main()— 128 callers, 3 callees (high)_score_query()— 24 callers, 8 callees (high)_shortest_path_text()— 27 callers, 7 callees (high)resolve_seed()— 30 callers, 5 callees (high)_resolve_path_endpoint()— 14 callers, 7 callees (high)_find_node_tiers()— 10 callers, 9 callees (high)- …and 2 more
Formal checks — 896 functions this change can affect weren't formally checked in this review. Formal checks are informational only.
Gate & verification
✅ PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 665 function(s) in the blast radius were not formally verified this run
Test selection
30 of 594 test file(s) selected (5%) via static blast radius.
tests/test_4874_jvm_resolution.py— impacttests/test_affected_cli.py— impacttests/test_affected_path_file_node.py— impacttests/test_affected_seed_reference_forms.py— impacttests/test_benchmark.py— impacttests/test_benchmark_raw_graph.py— impacttests/test_benchmark_real_query.py— impacttests/test_confidence_score_output.py— impacttests/test_edge_also_seen.py— impacttests/test_explain_same_file_tie.py— impacttests/test_extract.py— impacttests/test_file_label_disambiguation.py— impacttests/test_graph_context_cache_reload.py— impacttests/test_markdown_sections.py— impacttests/test_mcp_annotations.py— impact, changed-testtests/test_mcp_graph_view_cache.py— impacttests/test_path_cli.py— impacttests/test_path_confidence.py— impacttests/test_path_type_member.py— impacttests/test_query_induced_edges.py— impacttests/test_query_mcp_direction.py— impacttests/test_query_names_its_graph.py— impacttests/test_query_seed_order.py— impacttests/test_query_seeds.py— impacttests/test_query_source_first.py— impacttests/test_querylog.py— impacttests/test_serve.py— impacttests/test_serve_http.py— impacttests/test_terraform.py— impacttests/test_truncation_full_answer.py— impact
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Docs that may be stale (advisory)
CHANGELOG.md§ 0.9.19 (2026-07-18) (lines 1418-1428): references changed symbolssessionCHANGELOG.md§ 0.8.34 (2026-06-07) (lines 1941-1958): references changed symbolssessionREADME.md§ Install (lines 188-302): references changed symbolssessiongraphify/skills/agents/references/extraction-spec.md§ graphify reference: extraction subagent prompt (lines 1-91): references changed symbolssessiongraphify/skills/amp/references/extraction-spec.md§ graphify reference: extraction subagent prompt (lines 1-91): references changed symbolssessiongraphify/skills/claude/references/extraction-spec.md§ graphify reference: extraction subagent prompt (lines 1-91): references changed symbolssessiongraphify/skills/claw/references/extraction-spec.md§ graphify reference: extraction subagent prompt (compact) (lines 1-44): references changed symbolssessiongraphify/skills/codex/references/extraction-spec.md§ graphify reference: extraction subagent prompt (compact) (lines 1-41): references changed symbolssessiongraphify/skills/copilot/references/extraction-spec.md§ graphify reference: extraction subagent prompt (lines 1-91): references changed symbolssessiongraphify/skills/droid/references/extraction-spec.md§ graphify reference: extraction subagent prompt (lines 1-91): references changed symbolssession
…and 10 more.
query_graph appends to the query log when GRAPHIFY_QUERY_LOG (or GRAPHIFY_QUERY_LOG_ENABLE) is set, so advertising readOnlyHint=True is only accurate when logging is disabled. Add querylog.is_enabled(), derive query_graph's readOnlyHint from it, and mention the exception in the server instructions. Addresses the review on this PR. Co-Authored-By: Claude <noreply@anthropic.com>
|
lgtm |
|
Thanks @LukeMel! |
What does this PR do?
graphify-mcpsentannotations: nullfor every tool and noinstructionsoninitialize. Clients that gate calls onreadOnlyHinttherefore asked for approval on read-only tools such asgraph_stats, and models got no hint about when the graph beats grep.This PR:
_TOOL_ANNOTATIONStable (title plusopenWorldHint) and appliesToolAnnotations(title, readOnlyHint=True, openWorldHint=...)to every tool whereproject_pathis already injected, so a new tool can't miss it. The table has one entry per tool, includingget_section, which the issue's list didn't mention.list_prs,get_pr_impactandtriage_prsgetopenWorldHint=Truebecause they call GitHub throughgh; the rest getFalse._SERVER_INSTRUCTIONSstring and passes it asServer(..., instructions=...)in both the mcp 1.x and 2.x branches.Both fields are optional in the spec, so clients that ignore them see no change. I only ran the suite against mcp 2.x. The 1.x branch passes the same constructor argument, but I did not run it.
Fixes #5208
Type of change
Verification & Invariants
Invariant: every tool returned by
tools/listis annotated read-only, and only thegh-backed ones are open-world.tests/test_mcp_annotations.py: initialize instructions, per-tool annotations, open-world set, table covers all tools)How was this tested?
Graphify-specific checklist
Co-Authored-By: Claude <noreply@anthropic.com>