This version is still in development and is not considered stable yet. For the latest snapshot version, please use Spring AI 1.0.1!spring-doc.cn

MCP Server Boot Starter

Model Context Protocol (MCP) Servers are programs that expose specific capabilities to AI applications through standardized protocol interfaces. Each server provides focused functionality for a particular domain.spring-doc.cn

The Spring AI MCP Server Boot Starters provide auto-configuration for setting up MCP Servers in Spring Boot applications. They enable seamless integration of MCP server capabilities with Spring Boot’s auto-configuration system.spring-doc.cn

The MCP Server Boot Starters offer:spring-doc.cn

  • Automatic configuration of MCP server components, including tools, resources, and promptsspring-doc.cn

  • Support for different MCP protocol versions, including STDIO, SSE, Streamable-HTTP, and stateless serversspring-doc.cn

  • Support for both synchronous and asynchronous operation modesspring-doc.cn

  • Multiple transport layer optionsspring-doc.cn

  • Flexible tool, resource, and prompt specificationspring-doc.cn

  • Change notification capabilitiesspring-doc.cn

MCP Server Boot Starters

MCP Servers support multiple protocol and transport mechanisms. Use the dedicated starter and the correct spring.ai.mcp.server.protocol property to configure your server:spring-doc.cn

STDIO

Server Type Dependency Property

Standard Input/Output (STDIO)spring-doc.cn

spring-ai-starter-mcp-serverspring-doc.cn

spring.ai.mcp.server.stdio=truespring-doc.cn

WebMVC

Server Typespring-doc.cn

Dependencyspring-doc.cn

Propertyspring-doc.cn

SSE WebMVCspring-doc.cn

spring-ai-starter-mcp-server-webmvcspring-doc.cn

spring.ai.mcp.server.protocol=SSE or emptyspring-doc.cn

Streamable-HTTP WebMVCspring-doc.cn

spring-ai-starter-mcp-server-webmvcspring-doc.cn

spring.ai.mcp.server.protocol=STREAMABLEspring-doc.cn

Stateless WebMVCspring-doc.cn

spring-ai-starter-mcp-server-webmvcspring-doc.cn

spring.ai.mcp.server.protocol=STATLESSspring-doc.cn

WebMVC (Reactive)

Server Typespring-doc.cn

Dependencyspring-doc.cn

Propertyspring-doc.cn

SSE WebFluxspring-doc.cn

spring-ai-starter-mcp-server-webfluxspring-doc.cn

spring.ai.mcp.server.protocol=SSE or emptyspring-doc.cn

Streamable-HTTP WebFluxspring-doc.cn

spring-ai-starter-mcp-server-webfluxspring-doc.cn

spring.ai.mcp.server.protocol=STREAMABLEspring-doc.cn

Stateless WebFluxspring-doc.cn

spring-ai-starter-mcp-server-webfluxspring-doc.cn

spring.ai.mcp.server.protocol=STATLESSspring-doc.cn

Server Capabilities

Depending on the server and transport types, MCP Servers can support various capabilities, such as:spring-doc.cn

  • Tools - Allows servers to expose tools that can be invoked by language modelsspring-doc.cn

  • Resources - Provides a standardized way for servers to expose resources to clientsspring-doc.cn

  • Prompts - Provides a standardized way for servers to expose prompt templates to clientsspring-doc.cn

  • Utility/Completions - Provides a standardized way for servers to offer argument autocompletion suggestions for prompts and resource URIsspring-doc.cn

  • Utility/Logging - Provides a standardized way for servers to send structured log messages to clientsspring-doc.cn

  • Utility/Progress - Optional progress tracking for long-running operations through notification messagesspring-doc.cn

  • Utility/Ping - Optional health check mechanism for the server to report its statusspring-doc.cn

All capabilities are enabled by default. Disabling a capability will prevent the server from registering and exposing the corresponding features to clients.spring-doc.cn

Server Protocols

MCP provides several protocol types including:spring-doc.cn

  • STDIO - In process (e.g. server runs inside the host application) protocol. Communication is over standard in and standard out. To enable the STDIO set spring.ai.mcp.server.stdio=true.spring-doc.cn

  • SSE - Server-sent events protocol for real-time updates. The server operates as an independent process that can handle multiple client connections.spring-doc.cn

  • Streamable-HTTP - The Streamable HTTP transport allows MCP servers to operate as independent processes that can handle multiple client connections using HTTP POST and GET requests, with optional Server-Sent Events (SSE) streaming for multiple server messages. It replaces the SSE transport. To enable the STREAMABLE protocol, set spring.ai.mcp.server.protocol=STREAMABLE.spring-doc.cn

  • Stateless - Stateless MCP servers are designed for simplified deployments where session state is not maintained between requests. They are ideal for microservices architectures and cloud-native deployments. To enable the STATELESS protocol, set spring.ai.mcp.server.protocol=STATELESS.spring-doc.cn

Sync/Async Server API Options

The MCP Server API supports imperative (e.g. synchronous) and reactive (e.g. asynchronous) programming models.spring-doc.cn

  • Synchronous Server - The default server type implemented using McpSyncServer. It is designed for straightforward request-response patterns in your applications. To enable this server type, set spring.ai.mcp.server.type=SYNC in your configuration. When activated, it automatically handles the configuration of synchronous tool specifications.spring-doc.cn

  • Asynchronous Server - The asynchronous server implementation uses McpAsyncServer and is optimized for non-blocking operations. To enable this server type, configure your application with spring.ai.mcp.server.type=ASYNC. This server type automatically sets up asynchronous tool specifications with built-in Project Reactor support.spring-doc.cn

Example Applications