Repository navigation
Attach tool annotations on mcp 1.x, not just mcp 2.x - #189
Merged
Merged
Conversation
The weekly floor job has been failing on `test_a_pure_query_is_marked_read_only` with `KeyError: 'annotations'`. It was right: at our declared floor of mcp 1.27 the annotation shim attached nothing, so every tool went out with no hints at all. Normal CI resolves to mcp 2.3 and never saw it. The hints a client reads to decide what it may auto-approve were absent exactly where we document them as present, which is the failure direction that matters. Three differences between the SDKs, each of which alone was enough: - mcp 2.x keys the handler dict by method string, `"tools/list"`; mcp 1.x keys it by request type, `ListToolsRequest`. We looked up only the string, found nothing, and returned the server untouched. - mcp 1.x returns a `ServerResult` envelope whose `.root` holds the `ListToolsResult`; mcp 2.x returns the result directly. Iterating `.tools` on the envelope yields nothing, so even once the handler was wrapped it annotated no tool while looking like it had worked. - The attribute holding the dict is public `request_handlers` on 1.x and `_request_handlers` on 2.x. That one was already handled. The regression tests drive the shim with both keying schemes and with an envelope result, so neither branch depends on which SDK happens to be installed; they assert on the by-alias dump because the Python attribute is `readOnlyHint` on one SDK and `read_only_hint` on the other, while the wire name a client sees is the same either way. Reverting any single fix above fails at least one of them. Floor suite, resolved as the workflow does with `--resolution lowest-direct` (mcp 1.27.0, toolregistry 0.18.0): 1508 passed, 1 skipped, 44 deselected, 1 xfailed. Was 1 failed. Current resolve: 1546 passed, 7 skipped, 1 xfailed.
Collaborator
Author
|
Confirmed on CI, not just locally. Dispatched
The mirror run on #188 (39346277461) shows the complement: every So the two PRs fix disjoint halves of the same red workflow and neither is sufficient alone. With both applied, the floor environment resolved as the workflow does (mcp 1.27.0, toolregistry 0.18.0, uxarray 2026.10.0) gives 1508 passed, 1 skipped, 44 deselected, 1 xfailed. |
This was referenced Oct 20, 2026
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.
Fixes the
Upstream Compatibility/declared floor versionsjob, which hasbeen red on
tests/test_mcp_protocol.py::TestToolAnnotations::test_a_pure_query_is_marked_read_onlywith
KeyError: 'annotations'.The test was right. At our declared floor of mcp 1.27, the annotation shim
from #178 attached nothing at all, so every tool was served with no annotations.
Normal CI resolves to mcp 2.3 and never saw it. This is the bad direction for
this particular feature:
readOnlyHintis what a client reads to decide what itcan auto-approve, and it was missing exactly where we document it as present.
Three SDK differences, each independently fatal
ListToolsRequest(the type)"tools/list"(a string)ServerResultenvelope, tools under.rootrequest_handlers_request_handlersWe looked up only the string key, so on the floor the shim found nothing and
returned the server untouched. Fixing just that got the handler wrapped but
still annotated nothing, because iterating
.toolson the envelope yieldsnothing — it looked like it had worked. The third was already handled.
Tests
TestTheShimFindsTheHandlerOnEitherSDKdrives the shim with a string key, atype key, and an envelope result, using stand-in objects so both branches are
exercised whichever SDK is installed — the type-keyed path is otherwise only
reachable in the weekly floor job. They assert on the by-alias dump, since the
Python attribute is
readOnlyHinton one SDK andread_only_hinton the otherwhile the wire name is the same either way.
Reverting any one of the two fixes fails at least one of them (verified).
Results
Floor environment, resolved exactly as the workflow does
(
uv sync --dev --resolution lowest-direct→ mcp 1.27.0, toolregistry 0.18.0):Current resolve:
1546 passed, 7 skipped, 1 xfailed.Branches off
main, independent of #188.