Repository navigation
Annotate vMCP optimizer discovery tool - #6373
Conversation
Mark find_tool as a read-only, idempotent local discovery operation so MCP clients can make safer retry and tool-selection decisions. Keep call_tool unannotated because it proxies arbitrary backend side effects. Signed-off-by: XD <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6373 +/- ##
==========================================
+ Coverage 82.40% 82.44% +0.04%
==========================================
Files 937 937
Lines 95821 95832 +11
==========================================
+ Hits 78958 79013 +55
+ Misses 16858 16814 -44
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The Serve-path optimizer rebuilt find_tool and call_tool as mcp.Tool values with only name, description, and schema, dropping the annotations declared in OptimizerTools. Clients therefore never saw find_tool's read-only/idempotent hints when the optimizer was enabled. Convert the definition's annotations the same way the regular tool path does, and cover the wire output with a tools/list test. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
rdimitrov
left a comment
There was a problem hiding this comment.
The hints themselves look right to me. find_tool only searches the session's own index, so read-only, non-destructive, idempotent and closed-world all hold. Leaving call_tool unannotated is correct: clients fall back to the spec defaults (destructive, open-world). I ran the optimizer, server, sessionmanager, conversion and authz packages with -race and they pass. A raw tools/list on the Serve path shows the four hints on find_tool, and the cross-pod re-injection path goes through the same builder. The Modern path is gated off for the optimizer, so there is nothing to wire there yet.
One interaction with the authz middleware needs addressing before merge (inline).
The authz annotation cache is keyed by bare tool name, and call_tool authorizes its inner tool_name through that cache. Filling it from pass-through meta-tools meant a backend tool sharing a meta-tool's name was evaluated with the meta-tool's hints. Now that find_tool is advertised as read-only, that made hint-based Cedar policies more permissive for such a backend tool. Fill the cache from the regular tools only; the meta-tools are never authorized through it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
rdimitrov
left a comment
There was a problem hiding this comment.
Fix verified. The new test fails without be714ed03 (200 instead of 403) and passes with it, and the authz, optimizer and vMCP server packages pass with -race. Agreed that the shared, bare-name annotation cache is a pre-existing issue and should go in a follow-up issue, not this PR.
Summary
The vMCP optimizer exposes
find_toolas a local tool-discovery operation, but its MCP definition currently carries no behavioral hints. Clients cannot distinguish this safe discovery step from a tool that may mutate external state, which limits safe retry and tool-selection behavior in Agent workflows.find_tool: read-only, non-destructive, idempotent, and closed-world.call_toolunannotated because it can proxy arbitrary backend side effects.Part of #4357
Type of change
Test plan
task -t Taskfile.focused.yml test, using the repository's-raceand linker settings for./pkg/vmcp/session/optimizerdecand./pkg/vmcp/conversion)task test-e2e)task lint-fix)API Compatibility
v1beta1API.Changes
pkg/vmcp/session/optimizerdec/decorator.gofind_tool.pkg/vmcp/session/optimizerdec/decorator_test.gocall_toolcontract.Does this introduce a user-facing change?
Yes. MCP clients that consume tool annotations can now identify
find_toolas a safe, retryable local discovery operation.Special notes for reviewers
The annotation is deliberately limited to
find_tool.call_tooldispatches arbitrary backend tools, so asserting read-only or non-destructive behavior there would be incorrect.