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
  • Field Details

  • 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 class CrumbExclusion
      Throws:
      IOException
      jakarta.servlet.ServletException
    • init

      protected void init() throws jakarta.servlet.ServletException
      Throws:
      jakarta.servlet.ServletException
    • getIconFileName

      public String getIconFileName()
      Specified by:
      getIconFileName in interface Action
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface Action
      Specified by:
      getDisplayName in interface ModelObject
    • getUrlName

      public String getUrlName()
      Specified by:
      getUrlName in interface Action
    • setSessionFactory

      public void setSessionFactory(io.modelcontextprotocol.spec.McpServerSession.Factory sessionFactory)
      Specified by:
      setSessionFactory in interface io.modelcontextprotocol.spec.McpServerTransportProvider
    • notifyClients

      public reactor.core.publisher.Mono<Void> notifyClients(String method, Object params)
      Broadcasts a notification to all connected clients.
      Specified by:
      notifyClients in interface io.modelcontextprotocol.spec.McpServerTransportProvider
      Parameters:
      method - The method name for the notification
      params - 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 request
      response - 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 request
      response - The HTTP servlet response
      Throws:
      IOException - If an I/O error occurs
    • closeGracefully

      public reactor.core.publisher.Mono<Void> 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 interface io.modelcontextprotocol.spec.McpServerTransportProvider
      Returns:
      A Mono that completes when all sessions have been closed