Skip to content

Expose server tool annotations on MCP::Client::Tool#445

Open
rickreyhsig-wealthbox wants to merge 1 commit into
modelcontextprotocol:mainfrom
rickreyhsig-wealthbox:client-tool-annotations
Open

Expose server tool annotations on MCP::Client::Tool#445
rickreyhsig-wealthbox wants to merge 1 commit into
modelcontextprotocol:mainfrom
rickreyhsig-wealthbox:client-tool-annotations

Conversation

@rickreyhsig-wealthbox

@rickreyhsig-wealthbox rickreyhsig-wealthbox commented Jul 10, 2026

Copy link
Copy Markdown

Fixes #446

Summary

Client#tools / Client#list_tools silently drop the server's annotations
field when building MCP::Client::Tool objects, even though the server sends
it in every tools/list response (Tool#as_json includes
annotations: annotations_value&.to_h). Callers have no way to read a tool's
readOnlyHint / destructiveHint / title / etc. from the client side today
— they have to bypass the public API and re-page tools/list via the private
#request method just to get at the raw definition.

Change

  • MCP::Client::Tool gains an annotations reader, populated the same way as
    the existing output_schema (optional kwarg, raw hash passed through as
    received on the wire — no reshaping into MCP::Tool::Annotations, since
    that class's constructor expects snake_case keys and the wire format is
    camelCase).
  • Client#list_tools passes annotations: tool["annotations"] through when
    constructing each Tool.

Test plan

  • Added/updated unit tests in test/mcp/client/tool_test.rb and
    test/mcp/client_test.rb covering: annotations present, annotations absent
    (nil), and the full-parameters constructor case.
  • bundle exec rake test — 1270 runs, 0 failures.
  • bundle exec rubocop — no offenses on changed files.

Client#tools/#list_tools built Tool objects without an annotations
field even though the server includes annotations in every
tools/list response. Add the reader and pass the raw hash through,
mirroring how output_schema is already handled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP::Client::Tool silently drops the server's annotations field

1 participant