Class KeepAliveScheduler

java.lang.Object
io.modelcontextprotocol.util.KeepAliveScheduler

public class KeepAliveScheduler extends Object
A utility class for scheduling regular keep-alive calls to maintain connections. It sends periodic keep-alive, ping, messages to connected mcp clients to prevent idle timeouts. The pings are sent to all active mcp sessions at regular intervals.
Author:
Christian Tzolov
  • Method Details

    • builder

      public static KeepAliveScheduler.Builder builder(Supplier<reactor.core.publisher.Flux<McpSession>> mcpSessions)
      Creates a new Builder instance for constructing KeepAliveScheduler.
      Returns:
      A new Builder instance
    • start

      public reactor.core.Disposable start()
      Starts regular keepAlive calls with sessions supplier.
      Returns:
      Disposable to control the scheduled execution
    • stop

      public void stop()
      Stops the currently running keepAlive scheduler.
    • isRunning

      public boolean isRunning()
      Checks if the scheduler is currently running.
      Returns:
      true if running, false otherwise
    • shutdown

      public void shutdown()
      Shuts down the scheduler and releases resources.