Interface McpStreamableServerTransportProvider

All Superinterfaces:
McpServerTransportProviderBase
All Known Implementing Classes:
HttpServletStreamableServerTransportProvider

public interface McpStreamableServerTransportProvider extends McpServerTransportProviderBase
The core building block providing the server-side MCP transport for Streamable HTTP servers. Implement this interface to bridge between a particular server-side technology and the MCP server transport layer.

The lifecycle of the provider dictates that it be created first, upon application startup, and then passed into either McpServer.sync(McpStreamableServerTransportProvider) or McpServer.async(McpStreamableServerTransportProvider). As a result of the MCP server creation, the provider will be notified of a McpStreamableServerSession.Factory which will be used to handle a 1:1 communication between a newly connected client and the server using a session concept. The provider's responsibility is to create instances of McpStreamableServerTransport that the session will utilise during the session lifetime.

Finally, the McpStreamableServerTransports can be closed in bulk when close() or closeGracefully() are called as part of the normal application shutdown event. Individual McpStreamableServerTransports can also be closed on a per-session basis, where the McpServerSession.close() or McpServerSession.closeGracefully() closes the provided transport.

Author:
Dariusz Jędrzejczyk
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Immediately closes all the transports with connected clients and releases any associated resources.
    reactor.core.publisher.Mono<Void>
    Gracefully closes all the transports with connected clients and releases any associated resources asynchronously.
    reactor.core.publisher.Mono<Void>
    notifyClients(String method, Object params)
    Sends a notification to all connected clients.
    void
    Sets the session factory that will be used to create sessions for new clients.

    Methods inherited from interface io.modelcontextprotocol.spec.McpServerTransportProviderBase

    protocolVersions
  • Method Details

    • setSessionFactory

      void setSessionFactory(McpStreamableServerSession.Factory sessionFactory)
      Sets the session factory that will be used to create sessions for new clients. An implementation of the MCP server MUST call this method before any MCP interactions take place.
      Parameters:
      sessionFactory - the session factory to be used for initiating client sessions
    • notifyClients

      reactor.core.publisher.Mono<Void> notifyClients(String method, Object params)
      Sends a notification to all connected clients.
      Specified by:
      notifyClients in interface McpServerTransportProviderBase
      Parameters:
      method - the name of the notification method to be called on the clients
      params - parameters to be sent with the notification
      Returns:
      a Mono that completes when the notification has been broadcast
      See Also:
    • close

      default void close()
      Immediately closes all the transports with connected clients and releases any associated resources.
      Specified by:
      close in interface McpServerTransportProviderBase
    • closeGracefully

      reactor.core.publisher.Mono<Void> closeGracefully()
      Gracefully closes all the transports with connected clients and releases any associated resources asynchronously.
      Specified by:
      closeGracefully in interface McpServerTransportProviderBase
      Returns:
      a Mono that completes when the connections have been closed.