Package io.jenkins.plugins.mcp.server
Class Endpoint
java.lang.Object
hudson.security.csrf.CrumbExclusion
io.jenkins.plugins.mcp.server.Endpoint
- All Implemented Interfaces:
ExtensionPoint
,Action
,ModelObject
,RootAction
,io.modelcontextprotocol.spec.McpServerTransportProvider
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
@Extension
public class Endpoint
extends CrumbExclusion
implements RootAction, io.modelcontextprotocol.spec.McpServerTransportProvider
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>
Initiates a graceful shutdown of the transport.static String
getRequestedResourcePath
(jakarta.servlet.http.HttpServletRequest httpServletRequest) protected void
handleMessage
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Handles POST requests for client messages.protected void
handleSSE
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Handles GET requests to establish SSE connections.protected void
init()
reactor.core.publisher.Mono<Void>
notifyClients
(String method, Object params) Broadcasts a notification to all connected clients.boolean
process
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain chain) void
setSessionFactory
(io.modelcontextprotocol.spec.McpServerSession.Factory sessionFactory) Methods inherited from class hudson.security.csrf.CrumbExclusion
all, process
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.modelcontextprotocol.spec.McpServerTransportProvider
close
-
Field Details
-
UTF_8
- See Also:
-
APPLICATION_JSON
- See Also:
-
FAILED_TO_SEND_ERROR_RESPONSE
- See Also:
-
MCP_SERVER
- See Also:
-
SSE_ENDPOINT
- See Also:
-
MCP_SERVER_SSE
- See Also:
-
MESSAGE_EVENT_TYPE
Event type for regular messages- See Also:
-
ENDPOINT_EVENT_TYPE
Event type for endpoint information- See Also:
-
MCP_SERVER_MESSAGE
- See Also:
-
-
Constructor Details
-
Endpoint
public Endpoint() throws jakarta.servlet.ServletException- Throws:
jakarta.servlet.ServletException
-
-
Method Details
-
getRequestedResourcePath
public static String getRequestedResourcePath(jakarta.servlet.http.HttpServletRequest httpServletRequest) -
process
public boolean process(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException - Overrides:
process
in classCrumbExclusion
- Throws:
IOException
jakarta.servlet.ServletException
-
init
protected void init() throws jakarta.servlet.ServletException- Throws:
jakarta.servlet.ServletException
-
getIconFileName
- Specified by:
getIconFileName
in interfaceAction
-
getDisplayName
- Specified by:
getDisplayName
in interfaceAction
- Specified by:
getDisplayName
in interfaceModelObject
-
getUrlName
- Specified by:
getUrlName
in interfaceAction
-
setSessionFactory
public void setSessionFactory(io.modelcontextprotocol.spec.McpServerSession.Factory sessionFactory) - Specified by:
setSessionFactory
in interfaceio.modelcontextprotocol.spec.McpServerTransportProvider
-
notifyClients
Broadcasts a notification to all connected clients.- Specified by:
notifyClients
in interfaceio.modelcontextprotocol.spec.McpServerTransportProvider
- Parameters:
method
- The method name for the notificationparams
- The parameters for the notification- Returns:
- A Mono that completes when the broadcast attempt is finished
-
handleSSE
protected void handleSSE(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Handles GET requests to establish SSE connections.This method sets up a new SSE connection when a client connects to the SSE endpoint. It configures the response headers for SSE, creates a new session, and sends the initial endpoint information to the client.
- Parameters:
request
- The HTTP servlet requestresponse
- The HTTP servlet response- Throws:
IOException
- If an I/O error occurs
-
handleMessage
protected void handleMessage(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Handles POST requests for client messages.This method processes incoming messages from clients, routes them through the session handler, and sends back the appropriate response. It handles error cases and formats error responses according to the MCP specification.
- Parameters:
request
- The HTTP servlet requestresponse
- The HTTP servlet response- Throws:
IOException
- If an I/O error occurs
-
closeGracefully
Initiates a graceful shutdown of the transport.This method marks the transport as closing and closes all active client sessions. New connection attempts will be rejected during shutdown.
- Specified by:
closeGracefully
in interfaceio.modelcontextprotocol.spec.McpServerTransportProvider
- Returns:
- A Mono that completes when all sessions have been closed
-