Skip to content

Add stream, putAll and putAllMap to McpTransportContext - #1285

Open
Kehrlann wants to merge 1 commit into
mainfrom
dgarnier/merge-mcp-transport-contexts
Open

Kehrlann wants to merge 1 commit into
mainfrom
dgarnier/merge-mcp-transport-contexts

Conversation

@Kehrlann

Copy link
Copy Markdown
Contributor
  • Transports need to list a context's entries and combine contexts, for instance to add the decoded Mcp-Param-* headers to a context built by a user-provided extractor.
  • This introduces a way to merge McpTransportContext. To do so, it introduces a way to read entries from the contexts, by key-value.
  • This change is non-breaking but custom implementations of McpTransportContext used in the modern server MUST implement stream().

The implementation is inspired from Reactor's Context.

@Kehrlann
Kehrlann requested a review from chemicL October 26, 2026 17:15
- Transports need to list a context's entries and combine contexts, for
  instance to add the decoded Mcp-Param-* headers to a context built by
  a user-provided extractor.
- This introduces a way to merge McpTransportContext. To do so, it
  introduces a way to read entries from the contexts, by key-value.
- This change is non-breaking but custom implementations of
  McpTransportContext used in the modern server MUST implement stream().

The implementation is inspired from Reactor's Context.

Signed-off-by: Daniel Garnier-Moiroux <[email protected]>
@Kehrlann
Kehrlann force-pushed the dgarnier/merge-mcp-transport-contexts branch from f862bd8 to 7a6a9df Compare October 26, 2026 17:21
@Kehrlann
Kehrlann added this pull request to stack #1287 October 26, 2026 17:26
@chemicL

chemicL commented Oct 27, 2026

Copy link
Copy Markdown
Member

#1288 as an alternative solution to the need.

Reasons:

  • We don't have to create a generic Context-like implementation here.
  • We don't need to iterate at this time as the intended usage is to grab a specific key's value.
  • For the most common case we can just merge two maps, we don't need streaming/iterating over the contents.
  • In case of user implementations of the McpTransportContext implementation we can provide an overlay instead of iterating, too.

Thus, we can avoid the breaking change and just have a default method with a working implementation.

This branch has not been deployed

No deployments
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.

2 participants