Skip to content

Name a resources/read request by its URI alone - #719

Merged
koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:name_a_resources_read_request_by_its_uri_alone
Nov 27, 2026
Merged

koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:name_a_resources_read_request_by_its_uri_alone

Conversation

@koic

@koic koic commented Nov 26, 2026

Copy link
Copy Markdown
Member

Motivation and Context

Two checks identify the target of a request by params.name, falling back to params.uri, whatever the method. A resources/read is named by its uri and has no name member, so a client that added one replaced the URI in both:

  • The Mcp-Name header of a modern request was compared with the added name. A request could carry a header naming one resource and read another, although the header exists so that an intermediary can route or filter on it without reading the body.
  • A sealed requestState was bound to the added name in place of the URI. With the same name on both requests, a state issued for one resource was accepted on a retry for another, although RequestStateSecurity documents the state as bound to the resource URI.

The member is now fixed per method: uri for resources/read, name for tools/call and prompts/get. MCP::Client::HTTP builds the Mcp-Name header of a resources/read from the uri in the same way, so the client and the server agree.

How Has This Been Tested?

test/mcp/server_test.rb, test/mcp/server/transports/streamable_http_transport_test.rb and test/mcp/client/http_test.rb. Against the previous library the state follows the added name across resources, and the header that names the read URI is refused as a mismatch.

Breaking Changes

None for a client that sends resources/read as specified. One that added a name to it has Mcp-Name checked against the uri, and a state sealed for such a request before this change keeps the binding it was sealed with until its TTL runs out.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

## Motivation and Context

Two checks identify the target of a request by `params.name`, falling back to `params.uri`, whatever the method.
A `resources/read` is named by its `uri` and has no `name` member, so a client that added one replaced the URI in both:

- The `Mcp-Name` header of a modern request was compared with the added `name`. A request could carry a header naming
  one resource and read another, although the header exists so that an intermediary can route or filter on it without reading the body.
- A sealed `requestState` was bound to the added `name` in place of the URI. With the same `name` on both requests, a state issued for
  one resource was accepted on a retry for another, although `RequestStateSecurity` documents the state as bound to the resource URI.

The member is now fixed per method: `uri` for `resources/read`, `name` for `tools/call` and `prompts/get`.
`MCP::Client::HTTP` builds the `Mcp-Name` header of a `resources/read` from the `uri` in the same way, so the client and the server agree.

## How Has This Been Tested?

`test/mcp/server_test.rb`, `test/mcp/server/transports/streamable_http_transport_test.rb` and `test/mcp/client/http_test.rb`. Against the previous library
the state follows the added `name` across resources, and the header that names the read URI is refused as a mismatch.

## Breaking Changes

None for a client that sends `resources/read` as specified. One that added a `name` to it has `Mcp-Name` checked against the `uri`,
and a state sealed for such a request before this change keeps the binding it was sealed with until its TTL runs out.
@koic
koic force-pushed the name_a_resources_read_request_by_its_uri_alone branch from e627204 to 8c5ad4f Compare November 27, 2026 02:25
@koic
koic merged commit 614e1be into modelcontextprotocol:main Nov 27, 2026
13 checks passed
@koic
koic deleted the name_a_resources_read_request_by_its_uri_alone branch November 27, 2026 02:26
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.

1 participant