Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tzolov
Copy link
Contributor

@tzolov 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]>
@markpollack
Copy link
Member

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:
Copy link
Member

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<>();
Copy link
Member

@markpollack markpollack Aug 19, 2025

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.

Copy link
Contributor Author

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

tzolov added 2 commits August 19, 2025 07:48
Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
@tzolov
Copy link
Contributor Author

tzolov commented Aug 19, 2025

Thanks @markpollack I've addressed the above recomendations

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