Annotate all 30 lens tools with ToolAnnotations - #5
Merged
Conversation
Every tool was a bare @mcp.tool(), so the schema carried no annotations and clients had to treat all 30 as potentially write-capable — a permission prompt on every lens call. 27 query tools get readOnlyHint=True. The three download_* tools write files into the scratchpad dir, so they stay readOnlyHint=False (non-destructive, idempotent — a repeat call overwrites the same per-SID paths). openWorldHint is True throughout since every tool hits the remote Lens API. tests/test_annotations.py guards that all tools stay annotated and that only the download_* three are non-read-only. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Problem
All 30 tools in
lens_mcp/server.pywere declared as a bare@mcp.tool(). The wordannotationsdid not appear anywhere in the package, so the advertised tool schemas carried no behavioural hints. A client has to assume an unannotated tool can write, so every lens tool looked write-capable and every lens call stopped to ask permission.Change
Two module-level
ToolAnnotationsconstants next to theFastMCPinstance, applied at each decorator:READ_ONLYTrueFalseTrueTrueWRITES_LOCAL_FILESFalseFalseTrueTrueThe three
download_*tools (download_entity_logs,download_trace_logs,download_prompts) genuinely write.log/.txtfiles into the scratchpad dir, so they cannot claimreadOnlyHint. They are non-destructive and idempotent — a repeat call overwrites the same per-SID paths.openWorldHintisTruethroughout because every tool hits the remote Lens API.No tool bodies, signatures, or docstrings changed — the diff is the import, the two constants, and 30 decorator lines.
Verification
mcp.list_tools()returns 30 tools, all with annotations, and exactly the threedownload_*are non-read-only.New
tests/test_annotations.py(3 tests, same self-running style astest_stats.py) guards this:download_*tests/test_stats.pystill passes (0 failures).🤖 Generated with Claude Code