-
Notifications
You must be signed in to change notification settings - Fork 1.8k
refactor: restructure MCP server auto-configuraitons, adding streamable-http support #4179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
tzolov
commented
Aug 18, 2025
- Extract MCP server functionality into specialized modules:
- STDIO/SSE servers (existing functionality)
- Streamable-HTTP servers with change notifications
- Stateless servers for simplified deployments
- Add new auto-configuration modules:
- spring-ai-autoconfigure-mcp-streamable-server-common
- spring-ai-autoconfigure-mcp-streamable-server-webflux/webmvc
- spring-ai-autoconfigure-mcp-stateless-server-common
- spring-ai-autoconfigure-mcp-stateless-server-webflux/webmvc
- Add server-specific property prefixes for different server types
- Extract ToolCallbackConverter into separate auto-configuration with conditional enablement via tool-callback-converter property
- Enhance transport providers with builder patterns and new features:
- Keep-alive interval support for connection health
- Add keep-alive-interval and other transport-specific options
- Add comprehensive integration tests for all server types
- Update documentation to reflect new architecture and server options
…le-http support - Extract MCP server functionality into specialized modules: * STDIO/SSE servers (existing functionality) * Streamable-HTTP servers with change notifications * Stateless servers for simplified deployments - Add new auto-configuration modules: * spring-ai-autoconfigure-mcp-streamable-server-common * spring-ai-autoconfigure-mcp-streamable-server-webflux/webmvc * spring-ai-autoconfigure-mcp-stateless-server-common * spring-ai-autoconfigure-mcp-stateless-server-webflux/webmvc * Add server-specific property prefixes for different server types - Extract ToolCallbackConverter into separate auto-configuration with conditional enablement via tool-callback-converter property - Enhance transport providers with builder patterns and new features: * Keep-alive interval support for connection health * Add keep-alive-interval and other transport-specific options - Add comprehensive integration tests for all server types - Update documentation to reflect new architecture and server options Signed-off-by: Christian Tzolov <[email protected]>
This looks great. I did some similar things for the IT testing in the integration tests for spring-ai-examples. i think there are some reusable patterns we can discuss. |
// De-duplicate tools by their name, keeping the first occurrence of each tool | ||
// name | ||
return tools.stream() // Key: tool name | ||
.collect(Collectors.toMap(tool -> tool.getToolDefinition().name(), tool -> tool, // Value: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logic is duplicated in the sync version, can share a utility method
.withConfiguration(AutoConfigurations.of(McpToolCallbackAutoConfiguration.class, | ||
McpClientAutoConfiguration.class, SseWebFluxTransportAutoConfiguration.class)); | ||
|
||
static AtomicReference<LoggingMessageNotification> loggingNotificationRef = new AtomicReference<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static
can introduce side effects, make them instance vars and reset state in @beforeeach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As those are shared between the test and the spring configuration beens we can't use the beforeeach but we can make them a special TestContext been as part for the client test configuration.
I will fix it for the Sse and the Streamable its
Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
Thanks @markpollack I've addressed the above recomendations |
Hi tzolov, I noticed that PR #4179 was merged recently to add streamable support for MCP server. Looking at the current implementation, I do have some concerns: Module proliferation – introducing 10+ modules mainly for configuration variations feels like overhead. Maintainability – each new mode could add more modules in the future, which might lead to unnecessary growth. Complexity – this design seems to increase cognitive load for both users and maintainers. In my PR, I tried a different approach: Using configuration properties to switch between modes Keeping everything in a single autoconfigure module with conditional beans Preserving backward compatibility while reducing module sprawl I think this configuration-driven approach might be more sustainable in the long run. Thanks! |
rebased and merged at 0b96f4c |
Hi @tzolov, |
Hi @Fottas, Thank you for reaching out, I missed your PR while on PTO and rushed to provide auto-configurations for the MCP 0.11.x (i've released recently). I appreciate your points but disagree about module count and complexity. Better separation of concerns actually reduces complexity. Unlike MCP client side (where one host may have multiple clients for different server types), server side always has a single server type. We already have 3 separate boot starters: spring-ai-starter-mcp-server (stdio), spring-ai-starter-mcp-server-webmvc (sse/webmvc), spring-ai-starter-mcp-server-webflux (sse/webflux) Reducing modules isn't the goal - reducing overall complexity and simplifying user-facing configuration is. Let me submit the new PR and we can continue the conversation there. I'll make you co-author due to your #4053 work and improvement suggestions. P.S. #4053 lacks stateless server support. These are different beasts with their own spec and transport APIs. Spring AI doesn't support HttpServletStreamableServerTransportProvider - use WebMvc instead. Also your PR lacked any tests |
Hi @tzolov, |
Here's a streamlined version: Hi @Fottas, After further exploration, I've decided to keep boot starter choices simple: webmvc vs. webflux. As you pointed out, having separate starters for sse, streamable, and stateless would be involving for the end users. PR #4211 consolidates everything into 3 boot starters:
It adds However I've managed to refactor the auto-configuraiton modules to 3 common, webmvc and webflux (similar to the client) and so resolve the existing issue of bundling mvc and flux in single auto-conf. You're co-author on the new PR. Thanks again for your contribution. |