Package io.vertx.ext.mcp.transport
Class VertxMcpSseServerTransportProvider
java.lang.Object
io.vertx.ext.mcp.transport.VertxMcpSseServerTransportProvider
- All Implemented Interfaces:
io.modelcontextprotocol.spec.McpServerTransportProvider,io.modelcontextprotocol.spec.McpServerTransportProviderBase,VertxMcpTransport
public class VertxMcpSseServerTransportProvider
extends Object
implements io.modelcontextprotocol.spec.McpServerTransportProvider, VertxMcpTransport
Server-side implementation of the MCP (Model Context Protocol) HTTP transport using
Vert.x and Server-Sent Events (SSE). This implementation provides a bidirectional communication
channel between MCP clients and servers using HTTP POST for client-to-server messages
and SSE for server-to-client messages.
Key features:
- Implements the
McpServerTransportProviderinterface that allows managingMcpServerSessioninstances and enabling their communication with theMcpServerTransportabstraction. - Uses Vert.x for non-blocking request handling and SSE support
- Maintains client sessions for reliable message delivery
- Supports graceful shutdown with session cleanup
- Thread-safe message broadcasting to multiple clients
The transport sets up two main endpoints:
- SSE endpoint (/sse) - For establishing SSE connections with clients
- Message endpoint (configurable) - For receiving JSON-RPC messages from clients
This implementation is thread-safe and can handle multiple concurrent client
connections. It uses ConcurrentHashMap for session management and Vert.x's
non-blocking APIs for message processing and delivery.
Created By Navíd Mitchell 🤪on 8/10/25
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DurationDefault keep alive interval as specified by the MCP transport specification.static final StringDefault message endpoint path as specified by the MCP transport specification.static final StringDefault SSE endpoint path as specified by the MCP transport specification.static final StringEvent type for sending the message endpoint URI to clients.static final StringEvent type for JSON-RPC messages sent through the SSE connection. -
Constructor Summary
ConstructorsConstructorDescriptionVertxMcpSseServerTransportProvider(String baseUrl, String messageEndpoint, String sseEndpoint, Duration keepAliveInterval, com.fasterxml.jackson.databind.ObjectMapper objectMapper, io.vertx.core.Vertx vertx) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()reactor.core.publisher.Mono<Void> Close the Vert.x MCP transport gracefully.io.vertx.ext.web.RouterReturns the Router that can be mounted into a Vert.x application.reactor.core.publisher.Mono<Void> notifyClients(String method, Object params) voidsetSessionFactory(io.modelcontextprotocol.spec.McpServerSession.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.McpServerTransportProviderBase
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_SSE_ENDPOINT
Default SSE endpoint path as specified by the MCP transport specification.- See Also:
-
DEFAULT_MESSAGE_ENDPOINT
Default message endpoint path as specified by the MCP transport specification.- See Also:
-
DEFAULT_KEEP_ALIVE_INTERVAL
Default keep alive interval as specified by the MCP transport specification.
-
-
Constructor Details
-
VertxMcpSseServerTransportProvider
-
-
Method Details
-
getRouter
public io.vertx.ext.web.Router getRouter()Returns the Router that can be mounted into a Vert.x application. This router contains all the MCP transport endpoints.- Specified by:
getRouterin interfaceVertxMcpTransport- Returns:
- The configured Router for handling MCP HTTP requests
-
protocolVersions
- Specified by:
protocolVersionsin interfaceio.modelcontextprotocol.spec.McpServerTransportProviderBase
-
setSessionFactory
public void setSessionFactory(io.modelcontextprotocol.spec.McpServerSession.Factory sessionFactory) - Specified by:
setSessionFactoryin interfaceio.modelcontextprotocol.spec.McpServerTransportProvider
-
notifyClients
- Specified by:
notifyClientsin interfaceio.modelcontextprotocol.spec.McpServerTransportProviderBase
-
closeGracefully
Description copied from interface:VertxMcpTransportClose the Vert.x MCP transport gracefully.- Specified by:
closeGracefullyin interfaceio.modelcontextprotocol.spec.McpServerTransportProviderBase- Specified by:
closeGracefullyin interfaceVertxMcpTransport- Returns:
- A Mono that completes when the transport is closed.
-
builder
public static VertxMcpSseServerTransportProvider.VertxMcpSseServerTransportProviderBuilder builder()
-