Class McpRequestProcessor

java.lang.Object
org.mockserver.netty.mcp.McpRequestProcessor

public class McpRequestProcessor extends Object
Transport-neutral MCP (Model Context Protocol) JSON-RPC request processor.

This class contains all the MCP protocol logic (JSON-RPC parsing, session management, tool/resource dispatch, response construction) without any dependency on a specific transport (Netty HTTP/1.1, HTTP/2, or HTTP/3).

Both McpStreamableHttpHandler (TCP path) and the HTTP/3 MCP dispatch in Http3MockServerHandler delegate to this processor.

  • Constructor Details

  • Method Details

    • getSessionManager

      public McpSessionManager getSessionManager()
      Returns the session manager used by this processor.
    • isMcpPath

      public static boolean isMcpPath(String path)
      Check if a path matches the MCP endpoint.
    • handlePost

      public McpRequestProcessor.McpResult handlePost(String requestBody, String mcpSessionId)
      Process an MCP POST request.
      Parameters:
      requestBody - the raw JSON body
      mcpSessionId - the Mcp-Session-Id header value (may be null)
      Returns:
      the result to write back
    • handleDelete

      public McpRequestProcessor.McpResult handleDelete(String mcpSessionId)
      Process an MCP DELETE request.
      Parameters:
      mcpSessionId - the Mcp-Session-Id header value
      Returns:
      the result to write back
    • handleGet

      public McpRequestProcessor.McpResult handleGet()
      Process an MCP GET request (currently not supported -- returns 405).
      Returns:
      the result to write back
    • handleOptions

      public McpRequestProcessor.McpResult handleOptions(boolean hasOrigin)
      Process an MCP OPTIONS request (CORS preflight or method-not-allowed).
      Parameters:
      hasOrigin - whether the request has an Origin header
      Returns:
      the result to write back