Skip to content
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

feat: Add Spring AI MCP Integration #2157

Closed
wants to merge 2 commits into from

Conversation

tzolov
Copy link
Contributor

@tzolov tzolov commented Feb 1, 2025

Adds comprehensive Model Context Protocol (MCP) integration to Spring AI, including:

Core Features:

  • MCP client implementation with Spring AI function calling capabilities
  • Spring-friendly abstractions for MCP clients and servers
  • Both synchronous and asynchronous MCP server operation modes
  • Spring Boot starter (spring-ai-starter-mcp-server) with WebFlux and WebMVC support
  • Auto-configuration for MCP server components
  • MCP dependency management with BOM

Technical Improvements:

  • Split WebMvc and WebFlux configurations into separate auto-configuration classes
  • Server type configurable via 'spring.ai.mcp.server.type' property (SYNC/ASYNC)
  • Comprehensive test coverage including McpServerAutoConfigurationIT
  • Utility classes for converting between Spring AI tools and MCP tools
  • MCP SDK version management in parent pom

@tzolov tzolov added this to the 1.0.0-M6 milestone Feb 1, 2025
@tzolov tzolov added the MCP label Feb 1, 2025
*
* @author Christian Tzolov
*/
public final class ToolHelper {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToolUtils instead? We have adopted the Utils suffix over time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@tzolov tzolov marked this pull request as ready for review February 5, 2025 09:57
Adds comprehensive Model Context Protocol (MCP) integration to Spring AI, including:

Core Features:
- MCP client implementation with Spring AI tool calling capabilities
- Spring-friendly abstractions for MCP clients and servers
- Both synchronous and asynchronous MCP server operation modes
- Add MCP client autoconfiguration with support for STDIO, WebMVC and WebFlux transports
- Auto-configuration for MCP server components
- Spring Boot starter (spring-ai-starter-mcp) with WebFlux and WebMVC support
- MCP dependency management with BOM
- Add close() method to McpToolCallback for proper resource cleanup
- Add initialize flag to control MCP client initialization
- Add comprehensive integration tests and documentation for MCP client configuration

Technical Improvements:
- Split WebMvc and WebFlux configurations into separate auto-configuration classes
- Server type configurable via 'spring.ai.mcp.server.type' property (SYNC/ASYNC)
- Comprehensive test coverage including McpServerAutoConfigurationIT
- Utility classes for converting between Spring AI tools and MCP tools
- MCP SDK version management in parent pom

refactor(mcp): reorganize MCP tool utilities and client configuration

- Rename ToolUtils to McpToolUtils for better MCP-specific naming
- Rename McpToolCallbackProvider to SyncMcpToolCallbackProvider
- Add utility methods for handling tool callbacks in McpToolUtils
- Extract client configuration logic into new McpClientDefinitions class
- Add tool callback support to ChatClient interface and implementations
- Remove redundant integration test

refactor: introduce MCP client customization support

Add McpSyncClientCustomizer interface for customizing MCP sync clients
Replace McpClientDefinitions with McpSyncClientConfigurer
Refactor MCP client initialization to support customization
Remove redundant close() method from McpToolCallback
Fix conditional class dependencies in WebMvc/Flux configurations

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
@markpollack
Copy link
Member

merged with minor checkstyle cleanup as f40945b

@markpollack markpollack closed this Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants