Repository navigation
fix: annotate fetch as read-only and support MCP 2026-07-28 - #184
Merged
Merged
Conversation
The fetch tool had no annotations, so clients applied the spec defaults (readOnlyHint=false, destructiveHint=true) and treated it as a destructive write tool. Mark it read-only, idempotent, and open-world, and give it a title. Bring the server up to date with spec 2026-07-28: - Run Streamable HTTP in stateless mode. The SDK only serves 2026-07-28 to stateless handlers; before this, 2026-07-28 requests were rejected with UnsupportedProtocolVersion. Older clients still work without an Mcp-Session-Id. - Switch FetchParams struct tags from `mcp` to `jsonschema`. The SDK ignores `mcp` tags, so parameter descriptions never reached clients. - Add minimum bounds for max_length and start_index, and clamp negative values in FormatContent, which previously panicked on a negative slice index. - Log a deprecation warning when starting with the SSE transport, which the SDK doesn't serve 2026-07-28 over. - Drop the InitializedHandler, which never fires in stateless mode and only repeated the endpoint already logged at startup. Update USAGE.md, README.md, and CLAUDE.md for the stateless flow and correct the documented max_length default and maximum, which the code never enforced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rdimitrov
approved these changes
Nov 19, 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.
Summary
The
fetchtool shipped without tool annotations, so MCP clients fell back to the spec defaults (readOnlyHint: false,destructiveHint: true) and showed it as a write tool. This PR annotates it correctly. It also brings the server up to date with MCP spec 2026-07-28, which it couldn't serve before.Changes
fetchnow setsreadOnlyHint,idempotentHint, andopenWorldHint, plus atitle.UnsupportedProtocolVersion(-32022). Gofetch keeps no state between calls, so it now runs statelessly. Clients on 2025-11-25 and earlier still work; they just don't receive anMcp-Session-Id, which those spec versions treat as optional.GETandDELETEon/mcpnow return 405.FetchParamsusedmcp:"..."struct tags, which the SDK ignores, so clients never saw any parameter descriptions. They now usejsonschema:"...".start_indexormax_lengthcaused a slice-bounds panic inFormatContent. The schema now setsminimumvalues, so the SDK rejects bad input with a tool error, and the processor also clamps negative values.--transport sse. The SDK doesn't serve 2026-07-28 over that transport.InitializedHandler: It never fires in stateless mode, and the endpoint it logged is already printed at startup.max_lengthdefault of 5000 and max of 1,000,000 that the code never enforced; those are corrected.Testing
TestFetchToolDefinitionchecks the annotations and input schema returned bytools/list, using an in-memory client.TestFormatContentNegativeBounds.task testandtask lintpass.server/discover,tools/list, andtools/call.initialize,tools/list, andtools/call.tools/list.task test-integration) have not been run locally.Behavior change
Deployments or clients that rely on
Mcp-Session-Idor onGET /mcpfor streaming will notice the switch to stateless mode. Gofetch never sent server-initiated messages, so nothing is lost functionally.🤖 Generated with Claude Code