Class McpRevision
- All Implemented Interfaces:
McpRevision
McpRevision implementation for MCP revision 2025-06-18.
Owns this revision's JSON-RPC method table and error-code table. Note the error-code table
deliberately reproduces a known-wrong mapping: McpErrorKind.UNKNOWN_METHOD,
McpErrorKind.TOOL_NOT_FOUND and McpErrorKind.PROMPT_NOT_FOUND all report
-32601, which is only actually correct for the first. Preserving that is intentional —
the corrective fix for those two is tracked separately and is not part of this re-layering.
McpErrorKind.RESOURCE_NOT_FOUND is not part of that known-wrong grouping: it correctly
reports -32002, the 2025-06-18 spec's dedicated missing-resource error code.
Constructed per binding, not shared as a singleton (Correction C8). The bound servlet or
mixin builds a fresh instance on every revision() call, passing its own
capabilities() hook result into the constructor — see McpRestServlet and
McpEndpoint. That is how this revision learns which explicit capabilities (if any)
to advertise, with no channel back into core: this class is otherwise entirely stateless, so
constructing a new one per call costs nothing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intJSON-RPC error code: internal error.static final intJSON-RPC error code: invalid params.static final intJSON-RPC error code: invalid request.static final intJSON-RPC error code: method not found.static final intJSON-RPC error code: parse error.static final intJSON-RPC error code: resource not found (MCP-specific, per the2025-06-18spec).static final StringDefault server name reported byinitializewhen the config supplies no server identity. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondispatch(McpExchange exchange, McpServerConfig config, BeanStore ctx) Dispatches one JSON-RPC request.interrorCode(McpErrorKind kind) Maps a neutral failure classification to this revision's JSON-RPC error code.The MCP protocol revision string this implementation speaks.static voidvalidateSchemas(McpServerConfig config) Verifies that every registered tool's input and output schema is expressible in this revision's wire schema type.
-
Field Details
-
CODE_PARSE_ERROR
JSON-RPC error code: parse error. Never reported by this revision (seeMcpErrorKind.PARSE_ERROR).- See Also:
-
CODE_INVALID_REQUEST
JSON-RPC error code: invalid request.- See Also:
-
CODE_METHOD_NOT_FOUND
JSON-RPC error code: method not found.- See Also:
-
CODE_INVALID_PARAMS
JSON-RPC error code: invalid params.- See Also:
-
CODE_INTERNAL_ERROR
JSON-RPC error code: internal error.- See Also:
-
CODE_RESOURCE_NOT_FOUND
JSON-RPC error code: resource not found (MCP-specific, per the2025-06-18spec).- See Also:
-
DEFAULT_SERVER_NAME
Default server name reported byinitializewhen the config supplies no server identity.- See Also:
-
-
Constructor Details
-
McpRevision
Constructor.- Parameters:
capabilities- Explicit capabilities to advertise oninitialize, ornull to auto-derive from the registered tool/prompt/resource lists (today's default behavior).
-
-
Method Details
-
validateSchemas
Verifies that every registered tool's input and output schema is expressible in this revision's wire schema type.The neutral
McpSchemais an unconstrained JSON object carrier, but this revision'sJsonSchemabean supports exactly six keywords and models only object schemas. Each schema role is therefore checked twice: its root must declare"type":"object", and the complete graph reachable from that root may use only this revision's six keywords. Rather than silently dropping an unsupported keyword — or an incompatible root shape — on the wire, a config carrying one is rejected, naming the tool, the offending role (inputSchema/outputSchema), and the offending shape or keyword.Before walking, each schema is passed through
JsonValueSafetyto bound nesting depth, node count, traversal time, and cyclic/shared references, so a pathological config cannot stall or exhaust the walk.Note this cannot be a complete guarantee against every possible wire shape:
JsonSchemaispublicand non-final, and Juneau's reflection-based marshalling will serialize a getter added by a subclass. No such subclass exists in this codebase, and none can be constructed through the public MCP API, but the check covers what a caller can express throughMcpSchema, not what reflection can reach.- Parameters:
config- The config to validate. Nevernull.- Throws:
IllegalArgumentException- If any tool's input or output schema has a non-object root or uses an unsupported keyword.
-
protocolVersion
Description copied from interface:McpRevisionThe MCP protocol revision string this implementation speaks.- Specified by:
protocolVersionin interfaceMcpRevision- Returns:
- The revision token (e.g.
"2025-06-18"). Nevernull .
-
errorCode
Description copied from interface:McpRevisionMaps a neutral failure classification to this revision's JSON-RPC error code.- Specified by:
errorCodein interfaceMcpRevision- Parameters:
kind- The failure classification. Nevernull .- Returns:
- The JSON-RPC error code this revision reports for that kind.
-
dispatch
Description copied from interface:McpRevisionDispatches one JSON-RPC request.- Specified by:
dispatchin interfaceMcpRevision- Parameters:
exchange- The inbound envelope plus header access. Nevernull .config- The neutral handler registry and pagination strategy. Nevernull .ctx- The per-request bean store, passed through to handlers. Nevernull .- Returns:
- A
McpResponseResultfor a normal request, aMcpStreamResult(for example wrapping aFlow.Publisherproduced by a v2-only method) for a request whose response is not a single JSON-RPC envelope, ornull for a notification request (which the HTTP layer renders as an empty body).
-