Skip to content

Load the context registry for modern MCP clients - #7493

Merged
tzolov merged 1 commit into
spring-projects:mainfrom
tzolov:mcp-modern-context-registry
Nov 27, 2026
Merged

tzolov merged 1 commit into
spring-projects:mainfrom
tzolov:mcp-modern-context-registry

Conversation

@tzolov

@tzolov tzolov commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

In an executable jar, a modern MCP connection whose first request runs on a thread of the common ForkJoinPool fails with No ContextAccessor for contextType: class reactor.util.context.Context1, and so does every later request, on any thread.
The registry of the context-propagation library is created once, with the accessors that the context class loader of the first thread sees, and that thread does not see the accessor of the Reactor context.
A legacy connection sends initialize at startup; a modern connection sends nothing, so the application decides which thread comes first.

When the modern connections are configured, the registry is now created with the class loader of the application.
A registry that exists already and does not read the Reactor context is loaded again.
Nothing is done when context-propagation is not on the class path.

The tests remove the accessor of the Reactor context from the registry and check that it is back: for the loader itself, on a thread that sees no service, and for the connection beans of both client types.

Fixes #7489

A modern connection sends nothing at startup, so its first request
can be the first use of the context-propagation registry. On a thread
of the common ForkJoinPool of an executable jar the registry is then
created without the accessor of the Reactor context, and every later
request fails, on any thread.

The registry is now created with the class loader of the application
when the modern connections are configured, and loaded again if it
does not read the Reactor context.

Fixes spring-projects#7489

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
@tzolov tzolov added this to the 2.1.1 milestone Nov 27, 2026
@tzolov tzolov added bug Something isn't working mcp labels Nov 27, 2026
@tzolov
tzolov merged commit ea0cc8c into spring-projects:main Nov 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mcp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modern MCP client fails for good after a first request on the common ForkJoinPool

1 participant