Skip to content

[Server] Send progress with the token of the gateway's own request - #594

Merged
chr-hertel merged 1 commit into
modelcontextprotocol:mainfrom
chr-hertel:fix-progress-token-per-request
Oct 14, 2026
Merged

chr-hertel merged 1 commit into
modelcontextprotocol:mainfrom
chr-hertel:fix-progress-token-per-request

Conversation

@chr-hertel

Copy link
Copy Markdown
Member

ClientGateway::progress() read the progress token from the session, which every call of a session shares. With parallel calls, steps 2..n of one call went out with the token of the call that came last.

  • ClientGateway takes the request it serves as an optional second argument and reads the token from its meta
  • RequestContext, InjectableParameters and ExplicitElementLoader pass the request
  • Without a request the session is still the fallback

Fixes chr-hertel#82
Part of chr-hertel#74 (together with #581)

🤖 Generated with Claude Code

@chr-hertel chr-hertel added this to the 0.9.0 milestone Oct 13, 2026
@chr-hertel chr-hertel added bug Something isn't working Server Issues & PRs related to the Server component labels Oct 13, 2026
@chr-hertel
chr-hertel requested a balanced review from Copilot October 13, 2026 22:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The request-specific token propagation is complete across supported gateway creation paths and has focused regression coverage.

0 open findings

What changed in this PR

Fixes progress-token mix-ups between parallel requests sharing a session by associating each ClientGateway with its current request.

Changes:

  • Reads progress tokens from request metadata, retaining session fallback compatibility.
  • Propagates requests through gateway construction and dependency injection.
  • Adds unit and concurrency regression coverage.
File Description
src/​Server/​ClientGateway.php Uses request-specific progress metadata.
src/​Server/​RequestContext.php Passes the current request to the gateway.
src/​Capability/​Registry/​InjectableParameters.php Injects request-aware gateways.
src/​Capability/​Registry/​Loader/​ExplicitElementLoader.php Passes requests through explicit handlers.
tests/​Unit/​Server/​ClientGatewayTest.php Tests token selection and fallback behavior.
tests/​Unit/​Server/​ProtocolTest.php Tests parallel-call token isolation.
tests/​Unit/​Capability/​Registry/​ReferenceHandlerTest.php Updates request fixtures to valid request objects.
tests/​Unit/​Capability/​Registry/​Loader/​ExplicitElementLoaderTest.php Updates explicit-loader request fixtures.
CHANGELOG.md Documents the concurrency fix.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chr-hertel
chr-hertel merged commit 71ed51d into modelcontextprotocol:main Oct 14, 2026
28 checks passed
@chr-hertel
chr-hertel deleted the fix-progress-token-per-request branch October 14, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Server] Progress sometimes reaches the neighbouring call under sustained load (TS clients)

2 participants