Class WebMvcStreamableServerTransportProvider
java.lang.Object
io.modelcontextprotocol.server.transport.WebMvcStreamableServerTransportProvider
- All Implemented Interfaces:
io.modelcontextprotocol.spec.McpServerTransportProviderBase,io.modelcontextprotocol.spec.McpStreamableServerTransportProvider
public class WebMvcStreamableServerTransportProvider
extends Object
implements io.modelcontextprotocol.spec.McpStreamableServerTransportProvider
Server-side implementation of the Model Context Protocol (MCP) streamable transport
layer using HTTP with Server-Sent Events (SSE) through Spring WebMVC. This
implementation provides a bridge between synchronous WebMVC operations and reactive
programming patterns to maintain compatibility with the reactive transport interface.
This is the non-reactive version of
io.modelcontextprotocol.server.transport.WebFluxStreamableServerTransportProvider
- Author:
- Christian Tzolov, Dariusz Jędrzejczyk
- See Also:
-
McpStreamableServerTransportProviderRouterFunction
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating instances ofWebMvcStreamableServerTransportProvider. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbuilder()reactor.core.publisher.Mono<Void>Initiates a graceful shutdown of the transport.org.springframework.web.servlet.function.RouterFunction<org.springframework.web.servlet.function.ServerResponse>Returns the RouterFunction that defines the HTTP endpoints for this transport.reactor.core.publisher.Mono<Void>notifyClients(String method, Object params) Broadcasts a notification to all connected clients through their SSE connections.voidsetSessionFactory(io.modelcontextprotocol.spec.McpStreamableServerSession.Factory sessionFactory) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.modelcontextprotocol.spec.McpStreamableServerTransportProvider
close
-
Field Details
-
MESSAGE_EVENT_TYPE
Event type for JSON-RPC messages sent through the SSE connection.- See Also:
-
ENDPOINT_EVENT_TYPE
Event type for sending the message endpoint URI to clients.- See Also:
-
DEFAULT_BASE_URL
Default base URL for the message endpoint.- See Also:
-
-
Method Details
-
protocolVersions
- Specified by:
protocolVersionsin interfaceio.modelcontextprotocol.spec.McpServerTransportProviderBase
-
setSessionFactory
public void setSessionFactory(io.modelcontextprotocol.spec.McpStreamableServerSession.Factory sessionFactory) - Specified by:
setSessionFactoryin interfaceio.modelcontextprotocol.spec.McpStreamableServerTransportProvider
-
notifyClients
Broadcasts a notification to all connected clients through their SSE connections. If any errors occur during sending to a particular client, they are logged but don't prevent sending to other clients.- Specified by:
notifyClientsin interfaceio.modelcontextprotocol.spec.McpServerTransportProviderBase- Specified by:
notifyClientsin interfaceio.modelcontextprotocol.spec.McpStreamableServerTransportProvider- Parameters:
method- The method name for the notificationparams- The parameters for the notification- Returns:
- A Mono that completes when the broadcast attempt is finished
-
closeGracefully
Initiates a graceful shutdown of the transport.- Specified by:
closeGracefullyin interfaceio.modelcontextprotocol.spec.McpServerTransportProviderBase- Specified by:
closeGracefullyin interfaceio.modelcontextprotocol.spec.McpStreamableServerTransportProvider- Returns:
- A Mono that completes when all cleanup operations are finished
-
getRouterFunction
public org.springframework.web.servlet.function.RouterFunction<org.springframework.web.servlet.function.ServerResponse> getRouterFunction()Returns the RouterFunction that defines the HTTP endpoints for this transport. The router function handles three endpoints:- GET [mcpEndpoint] - For establishing SSE connections and message replay
- POST [mcpEndpoint] - For receiving JSON-RPC messages from clients
- DELETE [mcpEndpoint] - For session deletion (if enabled)
- Returns:
- The configured RouterFunction for handling HTTP requests
-
builder
-