Skip to content

fix: stamp server info on graceful subscription results - #1078

Merged
DaleSeo merged 2 commits into
modelcontextprotocol:mainfrom
mrcs64:fix/listen-server-info
Jul 29, 2026
Merged

fix: stamp server info on graceful subscription results#1078
DaleSeo merged 2 commits into
modelcontextprotocol:mainfrom
mrcs64:fix/listen-server-info

Conversation

@mrcs64

@mrcs64 mrcs64 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Stamp the server implementation identity into the final result produced when a
subscriptions/listen handler completes gracefully.

Motivation and Context

The MCP 2026-07-28 specification says servers SHOULD include
io.modelcontextprotocol/serverInfo in every result's _meta.
ServerHandler::listen returns Result<(), McpError>, and rmcp constructs the
final SubscriptionsListenResult only after the handler returns. Applications
therefore cannot add this metadata themselves.

This PR intentionally covers only the graceful subscriptions/listen result
synthesized by rmcp after the application handler returns. SDK-wide stamping of
application-produced results is a separate concern.

How Has This Been Tested?

  • Added a stdio regression test that asserts the graceful final result contains
    the server implementation identity.
  • Added the same assertion to the real Streamable HTTP/SSE graceful-close test.
  • Ran the full repository test recipe, including the all-features and
    non-local-feature passes.
  • Ran cargo clippy --all-targets --all-features -- -D warnings.
  • Ran cargo +nightly fmt --all -- --check.

Breaking Changes

None. This adds missing response metadata without changing the handler API.

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

Additional context

The request path captures ServerInfo once before establishing the
subscription, so capability filtering and the eventual server identity come
from the same snapshot. Cancellation, abrupt transport closure, and handler
errors keep their existing behavior.

@github-actions github-actions Bot added T-test Testing related changes T-core Core library changes T-handler Handler implementation changes labels Jul 29, 2026
@github-actions github-actions Bot added the T-config Configuration file changes label Jul 29, 2026
@mrcs64
mrcs64 marked this pull request as ready for review July 29, 2026 11:09
@mrcs64
mrcs64 requested a review from a team as a code owner July 29, 2026 11:09

@DaleSeo DaleSeo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, @mrcs64!

@DaleSeo
DaleSeo merged commit cb50ae7 into modelcontextprotocol:main Jul 29, 2026
22 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 29, 2026
@DaleSeo

DaleSeo commented Jul 29, 2026

Copy link
Copy Markdown
Member

Just for context, I initially implemented the shape documented in SEP-2575 in #1000. However, the final spec added a graceful result for subscriptions/listen and made serverInfo optional in the result metadata. Since the SEP page was not updated, those changes were easy to miss, so I opened modelcontextprotocol/modelcontextprotocol#3159 to document these post-final SEP changes for future implementers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-config Configuration file changes T-core Core library changes T-handler Handler implementation changes T-test Testing related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants