Add MCP readOnlyHint/destructiveHint annotations to all tools - #40
Open
jmprathab wants to merge 1 commit into
Open
Add MCP readOnlyHint/destructiveHint annotations to all tools#40jmprathab wants to merge 1 commit into
jmprathab wants to merge 1 commit into
Conversation
Query tools carried no MCP tool annotations, only internal FastMCP tags. MCP clients had no standard signal that query_* tools are read-only, causing unnecessary permission prompts (e.g. query_shelves, query_changelists) even though sibling read tools behave identically.
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.
Summary
query_shelves,query_changelists, and siblings) carried no standard MCP tool annotations — only internal FastMCPtagsused byCheckPermissionMiddleware. MCP clients (e.g. Claude Code) had no standard signal that these are read-only, causing unnecessary repeated permission prompts even though the tools never mutate P4 state.annotations={"readOnlyHint": True}to all 8query_*tools andannotations={"readOnlyHint": False, "destructiveHint": True}to all 7modify_*tools, using the standardmcp.types.ToolAnnotationsfields supported by FastMCP's@mcp.tool(...)decorator.tags, handlers, models, and services are untouched.Verification
query_*tool's full call chain (tool → params model → handler → service → p4/Swarm call) and confirmed no write/mutating P4 or Swarm calls occur in any query path — including actions that sound mutating but aren't (validate_submit,check_resolveuse p4's-npreview flag;query_reviewsonly issues SwarmGET).@mcp.tool(annotations={...})against installedfastmcp==3.3.1: confirmed the dict is accepted and coerced intoToolAnnotationswith the expected field values.Notes / tradeoffs
modify_jobsonly supportslink_job/unlink_job(no delete), yet getsdestructiveHint: Truelike its delete-capable siblings. Chose uniformity across allmodify_*tools over per-action fidelity — a false-positive caution prompt on a reversible op, not a false negative.Test plan
query_*tool's implementation never calls a P4 write command (submit/shelve/delete/add/edit/sync-non-preview) or a Swarm POST/PUT/DELETE.annotations=as a plain dict via decorator smoke test.query_shelves/query_changelistsno longer prompt repeatedly for permission.