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 McpServerTransportProvider interface that allows managing McpServerSession instances and enabling their communication with the McpServerTransport abstraction.
  • 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

  • Field Details

    • MESSAGE_EVENT_TYPE

      public static final String MESSAGE_EVENT_TYPE
      Event type for JSON-RPC messages sent through the SSE connection.
      See Also:
    • ENDPOINT_EVENT_TYPE

      public static final String ENDPOINT_EVENT_TYPE
      Event type for sending the message endpoint URI to clients.
      See Also:
    • DEFAULT_SSE_ENDPOINT

      public static final String DEFAULT_SSE_ENDPOINT
      Default SSE endpoint path as specified by the MCP transport specification.
      See Also:
    • DEFAULT_MESSAGE_ENDPOINT

      public static final String DEFAULT_MESSAGE_ENDPOINT
      Default message endpoint path as specified by the MCP transport specification.
      See Also:
    • DEFAULT_KEEP_ALIVE_INTERVAL

      public static final Duration DEFAULT_KEEP_ALIVE_INTERVAL
      Default keep alive interval as specified by the MCP transport specification.
  • Constructor Details

    • VertxMcpSseServerTransportProvider

      public VertxMcpSseServerTransportProvider(String baseUrl, String messageEndpoint, String sseEndpoint, Duration keepAliveInterval, com.fasterxml.jackson.databind.ObjectMapper objectMapper, io.vertx.core.Vertx vertx)
  • 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:
      getRouter in interface VertxMcpTransport
      Returns:
      The configured Router for handling MCP HTTP requests
    • protocolVersions

      public List<String> protocolVersions()
      Specified by:
      protocolVersions in interface io.modelcontextprotocol.spec.McpServerTransportProviderBase
    • setSessionFactory

      public void setSessionFactory(io.modelcontextprotocol.spec.McpServerSession.Factory sessionFactory)
      Specified by:
      setSessionFactory in interface io.modelcontextprotocol.spec.McpServerTransportProvider
    • notifyClients

      public reactor.core.publisher.Mono<Void> notifyClients(String method, Object params)
      Specified by:
      notifyClients in interface io.modelcontextprotocol.spec.McpServerTransportProviderBase
    • closeGracefully

      public reactor.core.publisher.Mono<Void> closeGracefully()
      Description copied from interface: VertxMcpTransport
      Close the Vert.x MCP transport gracefully.
      Specified by:
      closeGracefully in interface io.modelcontextprotocol.spec.McpServerTransportProviderBase
      Specified by:
      closeGracefully in interface VertxMcpTransport
      Returns:
      A Mono that completes when the transport is closed.
    • builder