Class McpStreamableServer

java.lang.Object
com.github.thought2code.mcp.annotated.server.McpServerBase
com.github.thought2code.mcp.annotated.server.McpStreamableServer
All Implemented Interfaces:
McpServer

public class McpStreamableServer extends McpServerBase
An MCP server implementation that operates in Streamable HTTP mode.

This class extends McpServerBase and provides functionality for creating and managing MCP servers that use HTTP streaming for communication. The streamable mode is designed for web applications that require real-time, bidirectional communication with the MCP server.

The server uses Jetty as the underlying HTTP server and supports various configuration options including:

  • Custom port binding
  • Configurable MCP endpoint path
  • Keep-alive interval management
  • Delete operation control

This server mode is particularly suitable for:

  • Web applications requiring real-time communication
  • Browser-based MCP client integrations
  • Scenarios needing HTTP-based streaming communication
Author:
codeboyzhou
See Also:
  • Constructor Details

    • McpStreamableServer

      public McpStreamableServer(McpServerConfiguration configuration)
      Constructs a new McpStreamableServer with the specified configuration.

      The constructor initializes the server with the provided configuration, which contains all necessary settings for the streamable HTTP server including port number, endpoint path, keep-alive interval, and other transport options.

      Parameters:
      configuration - the server configuration containing streamable settings
      Throws:
      NullPointerException - if the configuration is null
      See Also:
  • Method Details

    • createSyncSpecification

      public io.modelcontextprotocol.server.McpServer.SyncSpecification<?> createSyncSpecification()
      Creates and returns a synchronization specification for Streamable HTTP mode.

      This method creates an McpServer.SyncSpecification that uses HTTP streaming transport provider for communication. The transport provider is configured with the following settings from the configuration:

      • Port number for binding the HTTP server
      • MCP endpoint path for the streaming API
      • Whether to disallow delete operations
      • Keep-alive interval for maintaining connections

      The method also stores the port number and transport provider instance for later use when starting the HTTP server.

      Returns:
      a synchronization specification configured for HTTP streaming transport
      See Also:
    • startHttpServer

      public void startHttpServer()
      Starts the Jetty HTTP server with the configured transport provider.

      This method creates a new JettyHttpServer instance, configures it with the transport provider created by createSyncSpecification(), binds it to the configured port, and starts the server. The server will begin accepting incoming HTTP connections for MCP streaming communication.

      This method should be called after createSyncSpecification() has been invoked to ensure the transport provider is properly initialized.

      See Also: