Package io.jenkins.plugins.mcp.server
Class HealthEndpoint
java.lang.Object
io.jenkins.plugins.mcp.server.HealthEndpoint
- All Implemented Interfaces:
ExtensionPoint,Action,ModelObject,RootAction,UnprotectedRootAction
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
@Extension
public class HealthEndpoint
extends Object
implements UnprotectedRootAction
Lightweight health endpoint specifically for MCP Server status monitoring.
This endpoint provides MCP clients a quick way to check if the MCP server is available and accepting connections, without the overhead of the full MCP protocol handshake. It's accessible without authentication to enable health checking from load balancers and monitoring systems.
Unlike a generic Jenkins health endpoint, this endpoint returns MCP-specific information such as active connection counts and server shutdown state, allowing MCP clients to make informed decisions about connection management and reconnection.
Endpoint: /mcp-health
Response format:
{
"mcpServerStatus": "ok" | "shutting_down",
"activeConnections": 5,
"shuttingDown": false,
"timestamp": "2025-01-28T10:30:00Z"
}
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intGrace period in seconds for clients to detect shutdown before full termination.static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddoIndex(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) Handles GET requests via Stapler.static voidhandleHealthRequest(jakarta.servlet.http.HttpServletResponse response) Handles GET requests to the MCP health endpoint.static booleanReturns whether the MCP server is in shutdown state.static voidsetShuttingDown(boolean shutdown) Sets the shutdown state of the MCP server.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface hudson.model.RootAction
getBadge, isPrimaryAction
-
Field Details
-
URL_NAME
- See Also:
-
SHUTDOWN_GRACE_PERIOD_SECONDS
public static final int SHUTDOWN_GRACE_PERIOD_SECONDSGrace period in seconds for clients to detect shutdown before full termination.- See Also:
-
-
Constructor Details
-
HealthEndpoint
public HealthEndpoint()
-
-
Method Details
-
getIconFileName
- Specified by:
getIconFileNamein interfaceAction
-
getDisplayName
- Specified by:
getDisplayNamein interfaceAction- Specified by:
getDisplayNamein interfaceModelObject
-
getUrlName
- Specified by:
getUrlNamein interfaceAction
-
doIndex
public void doIndex(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException Handles GET requests via Stapler.- Parameters:
req- the Stapler requestrsp- the Stapler response- Throws:
IOException- if writing the response fails
-
handleHealthRequest
public static void handleHealthRequest(jakarta.servlet.http.HttpServletResponse response) throws IOException Handles GET requests to the MCP health endpoint. Returns MCP-specific status information including active connection counts. This method can be called directly or via Stapler.- Parameters:
response- the HTTP response to send- Throws:
IOException- if writing the response fails
-
setShuttingDown
public static void setShuttingDown(boolean shutdown) Sets the shutdown state of the MCP server. Called byMcpServerShutdownListenerwhen Jenkins begins shutdown.- Parameters:
shutdown- true if Jenkins is shutting down
-
isShuttingDown
public static boolean isShuttingDown()Returns whether the MCP server is in shutdown state.- Returns:
- true if shutting down
-