You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MCP client: let a call pass per-call state to the request customizer #1770
A client that sends credentials computed per call (for example a token rendered from the call's own parameters, or a token exchanged for the caller's identity) cannot do it with McpClientAdapter.setRequestCustomizer. The customizer is one Consumer<Request> for the whole adapter, and the 2026-07-28 HTTP transport runs it on a worker thread of its own (McpModernHttpTransport.exchange), so neither a ThreadLocal set by the caller nor anything else of the calling thread is visible there. A client with per-call state has to create one adapter per call, which loses the connection and limits.
Found while migrating the consumed MCP client of Ikanos to org.restlet.ext.mcp (naftiko/ikanos#1256).
Proposed fix
Add McpClientAdapter.setCallCustomizer(BiConsumer<Request, ContextView>): for a 2026-07-28 call over HTTP, it runs after the request customizer and gets the Reactor context the call was subscribed with, so the caller passes its state with contextWrite on the call (client.tool("x").call().contextWrite(Context.of(key, value))). The context is read with FluxSink.contextView(), which the SDK client already propagates into the transport's exchange, as the test of the fix shows.
Out of scope: the 2025-11-25 transport, which has no per-call hook either; it can follow once this is agreed.
Activity
Give the request customizer of an MCP call its Reactor context (#1770)
Give the request customizer of an MCP call its Reactor context (#1770)
jlouvel commentedon Nov 30, 2026
Delivered by #1771 (merged to 3.0): McpClientAdapter.setCallCustomizer. Closing by hand because 3.0 merges don't auto-close.