Class McpServerShutdownListener

java.lang.Object
io.jenkins.plugins.mcp.server.McpServerShutdownListener

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @Extension public class McpServerShutdownListener extends Object
Listens for Jenkins shutdown events and notifies MCP clients.

This class hooks into Jenkins' termination lifecycle to update the health endpoint status, allowing connected MCP clients to detect when Jenkins is shutting down and prepare for reconnection.

The shutdown sequence:

  1. Jenkins initiates shutdown
  2. This terminator is called, setting the health endpoint to "shutting_down" state
  3. A grace period allows clients to detect the state change via the health endpoint
  4. Jenkins completes shutdown
  • Constructor Details

    • McpServerShutdownListener

      public McpServerShutdownListener()
  • Method Details

    • onShutdown

      @Terminator public void onShutdown() throws InterruptedException
      Called when Jenkins is shutting down.

      Sets the MCP server health endpoint to shutdown state and waits for a brief grace period to allow clients to detect the shutdown.

      Throws:
      InterruptedException - if the grace period sleep is interrupted