Package org.springframework.ai.mcp
@NonNullApi
@NonNullFields
package org.springframework.ai.mcp
Core support for Model Context Protocol (MCP) integration in Spring AI.
This package provides the foundational classes and utilities for integrating MCP with Spring AI's tool system. It includes:
- Tool callback implementations for both synchronous and asynchronous MCP operations
- Tool callback providers that discover and expose MCP tools
- Utility classes for converting between Spring AI and MCP tool representations
- Support for customizing MCP client behavior
The classes in this package enable seamless integration between Spring AI applications and MCP servers, allowing language models to discover and invoke tools through a standardized protocol.
- Since:
- 1.0.0
- Author:
- Christian Tzolov
-
ClassDescriptionAdapts MCP tools to Spring AI's
ToolCallback
interface with asynchronous execution.Builder for constructing AsyncMcpToolCallback instances.Provides MCP tools asynchronously from multiple MCP servers as Spring AI tool callbacks.Builder forAsyncMcpToolCallbackProvider
configuration.Default implementation ofMcpToolNamePrefixGenerator
that ensures unique tool names for all client/server connections.MCP connection info record containing the client and server related metadata.Builder class for constructing McpConnectionInfo instances.ABiPredicate
forSyncMcpToolCallbackProvider
and theAsyncMcpToolCallbackProvider
to filter the discovered tool for the givenMcpConnectionInfo
.Strategy interface for generating prefixed tool name based on MCP client/server and Tool information.Utility class that provides helper methods for working with Model Context Protocol (MCP) tools in a Spring AI environment.Synchronous adapter bridging MCP tools to Spring AI'sToolCallback
interface.Builder forSyncMcpToolCallback
instances.Provides Spring AI tool callbacks by discovering tools from MCP servers.Builder forSyncMcpToolCallbackProvider
.Strategy interface for converting aToolContext
to a map of metadata to be sent as part of an MCP tool call.