Class McpRevision

java.lang.Object
org.apache.juneau.rest.server.mcp.v20260728.McpRevision
All Implemented Interfaces:
McpRevision

public final class McpRevision extends Object implements McpRevision
McpRevision implementation for MCP revision 2026-07-28.

Owns this revision's stateless JSON-RPC method table, per-request _meta negotiation, SEP-2243 Mcp-Method/Mcp-Name header agreement checks, server/discover dispatch, and error-code table. Every request is independently negotiated from its own _meta; no handshake, session, or prior-request state exists.

Constructed per binding, not shared as a singleton. The bound servlet or mixin builds a fresh instance on every revision() call, passing its McpOptions.getCapabilities() result and its published McpCacheConfig into the constructor — see McpRestServlet and McpEndpoint. A null capabilities override auto-derives server/discover capabilities from the registered tool/prompt/resource/resource-template lists; a non-null override is advertised as-is. The cache config is binding-owned: it is supplied once at construction, is never null, and is treated as static and request-independent for the lifetime of this instance — every page of a given list method resolves to identical cache values. The instance retains no request-derived state.

  • Field Details

  • Constructor Details

    • McpRevision

      public McpRevision(ServerCapabilities capabilities)
      Constructor. Uses an empty McpCacheConfig (no cache hints emitted on any result) and no discovery instructions.
      Parameters:
      capabilities - Explicit capabilities to advertise on server/discover, or null to auto-derive from the registered tool/prompt/resource lists.
    • McpRevision

      public McpRevision(ServerCapabilities capabilities, McpCacheConfig cacheConfig)
      Constructor. Advertises no discovery instructions.
      Parameters:
      capabilities - Explicit capabilities to advertise on server/discover, or null to auto-derive from the registered tool/prompt/resource lists.
      cacheConfig - Binding-owned cache configuration. Must not be null.
    • McpRevision

      public McpRevision(ServerCapabilities capabilities, McpCacheConfig cacheConfig, String instructions)
      Constructor. Uses a default McpMrtrConfig (AES-GCM ephemeral codec, 5-minute requestState TTL, 10-round cap).
      Parameters:
      capabilities - Explicit capabilities to advertise on server/discover, or null to auto-derive from the registered tool/prompt/resource lists.
      cacheConfig - Binding-owned cache configuration. Must not be null.
      instructions - Optional free-form server/discover usage instructions, or null to omit them.
    • McpRevision

      public McpRevision(ServerCapabilities capabilities, McpCacheConfig cacheConfig, String instructions, McpMrtrConfig mrtrConfig)
      Constructor.
      Parameters:
      capabilities - Explicit capabilities to advertise on server/discover, or null to auto-derive from the registered tool/prompt/resource lists.
      cacheConfig - Binding-owned cache configuration. Must not be null.
      instructions - Optional free-form server/discover usage instructions, or null to omit them.
      mrtrConfig - Binding-owned MRTR (Multi-Round-Trip Request) configuration. Must not be null.
  • Method Details

    • protocolVersion

      Description copied from interface: McpRevision
      The MCP protocol revision string this implementation speaks.
      Specified by:
      protocolVersion in interface McpRevision
      Returns:
      The revision token (e.g. "2025-06-18"). Never null.
    • errorCode

      public int errorCode(McpErrorKind kind)
      Description copied from interface: McpRevision
      Maps a neutral failure classification to this revision's JSON-RPC error code.
      Specified by:
      errorCode in interface McpRevision
      Parameters:
      kind - The failure classification. Never null.
      Returns:
      The JSON-RPC error code this revision reports for that kind.
    • dispatch

      Description copied from interface: McpRevision
      Dispatches one JSON-RPC request.
      Specified by:
      dispatch in interface McpRevision
      Parameters:
      exchange - The inbound envelope plus header access. Never null.
      config - The neutral handler registry and pagination strategy. Never null.
      ctx - The per-request bean store, passed through to handlers. Never null.
      Returns:
      A McpResponseResult for a normal request, a McpStreamResult (for example wrapping a Flow.Publisher produced by a v2-only method) for a request whose response is not a single JSON-RPC envelope, or null for a notification request (which the HTTP layer renders as an empty body).