Package io.modelcontextprotocol.spec
Class McpSchema
java.lang.Object
io.modelcontextprotocol.spec.McpSchema
Based on the JSON-RPC 2.0
specification and the Model
Context Protocol Schema.
- Author:
- Christian Tzolov, Luca Chang, Surbhi Bansal, Anurag Pant, Dariusz Jędrzejczyk
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceBase for objects that include optional annotations for the client.static final recordOptional annotations for the client.static final recordAudio provided to or from an LLM.static final recordBinary contents of a resource.static final recordSchema for a boolean field in a form-based elicitation request.static final recordUsed by the client to call a tool provided by the server.static final recordThe server's response to a tools/call request from the client.static final recordCapabilities a client may support.static interfaceA reference to a prompt or resource that can be used as input for completion requests.static final recordA request from the client to the server, to ask for completion options.static final recordThe server's response to a completion/complete request.static interfaceA polymorphic content value that can appear in messages and tool results.static final recordA request from the server to sample an LLM via the client.static final recordThe client's response to a sampling/create_message request from the server.static final recordA notification from the server to the client indicating that an out-of-band URL elicitation interaction has completed.static final recordA request from the server to elicit additional information from the user via the client, usingformmode.static interfaceA request from the server to elicit additional information from the user, either through the client or out-of-band.static final recordThe client's response to an elicitation request.static final recordA request from the server to elicit additional information from the user out of band, usingurlmode.static final recordThe contents of a resource, embedded into a prompt or tool call result.static final recordAn option in a titled enum schema, with a machine-readable value and a human-readable display label.static final classStandard error codes used in MCP JSON-RPC responses.static final recordUsed by the client to get a prompt provided by the server.static final recordThe server's response to a prompts/get request from the client.static final recordRepresents an icon that can be displayed in a user interface.static interfaceBase interface with name (identifier) and title (display name) properties.static final recordAn image provided to or from an LLM.static final recordDescribes the name and version of an MCP implementation, with an optional title for UI representation.static final recordThis request is sent from the client to the server when it first connects, asking it to begin initialization.static final recordAfter receiving an initialize request from the client, the server sends this response.static interfacestatic final recordA notification which does not expect a response.static final recordA request that expects a response.static final recordA response to a request (successful, or error).static final recordDeprecated.static final recordDeprecated.UseMcpSchema.TitledSingleSelectEnumSchemainsteadstatic final recordThe server's response to a prompts/list request from the client.static final recordThe server's response to a resources/list request from the client.static final recordThe server's response to a resources/templates/list request from the client.static final recordThe client's response to a roots/list request from the server.static final recordThe server's response to a tools/list request from the client.static enumSeverity levels for MCP log messages, ordered from least to most severe.static final recordThe Model Context Protocol (MCP) provides a standardized way for servers to send structured log messages to clients.static interfaceBase interface for MCP objects that include optional metadata in the `_meta` field.static final recordHints to use for model selection.static final recordThe server's preferences for model selection, requested of the client during sampling.static interfacestatic final recordSchema for a numeric field in a form-based elicitation request, supporting both"number"(floating-point) and"integer"types.static final recordA request that supports pagination using cursors.static final recordAn opaque token representing the pagination position after the last returned result.static final recordThe Model Context Protocol (MCP) supports optional progress tracking for long-running operations through notification messages.static final recordA prompt or prompt template that the server offers.static final recordDescribes an argument that a prompt can accept.static final recordDescribes a message returned as part of a prompt.static final recordIdentifies a prompt for completion requests.static final recordSent from the client to the server, to read a specific resource URI.static final recordThe server's response to a resources/read request from the client.static interfacestatic final recordA known resource that the server is capable of reading.static interfaceA common interface for resource content, which includes metadata about the resource such as its URI, name, description, MIME type, size, and annotations.static interfaceThe contents of a specific resource or sub-resource.static final recordA known resource that the server is capable of reading.static final recordA reference to a resource or resource template definition for completion requests.static final recordThe Model Context Protocol (MCP) provides a standardized way for servers to send resources update message to clients.static final recordResource templates allow servers to expose parameterized resources using URIstatic interfacestatic enumstatic final recordRepresents a root directory or file that the server can operate on.static final recordDescribes a message issued to or received from an LLM API.static final recordCapabilities that a server may support.static final recordA request from the client to the server, to enable or adjust logging.static final recordSchema for a text input field in a form-based elicitation request.static final recordSent from the client to request resources/updated notifications from the server whenever a particular resource changes.static final recordText provided to or from an LLM.static final recordText contents of a resource.static final recordSchema for multiple-selection enumeration with display titles for each option.static final recordThe items schema forMcpSchema.TitledMultiSelectEnumSchema, describing the allowed enum options with display labels.static final recordSchema for single-selection enumeration with display titles for each option.static final recordRepresents a tool that the server provides.static final recordAdditional properties describing a Tool to clients.static final recordSent from the client to request cancellation of resources/updated notifications from the server.static final recordSchema for multiple-selection enumeration without display titles for options.static final recordThe items schema forMcpSchema.UntitledMultiSelectEnumSchema, describing the allowed enum values.static final recordSchema for single-selection enumeration without display titles for options. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StringThe JSON Schema 2020-12 meta-schema URI (SEP-1613).static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionstatic McpSchema.JSONRPCMessagedeserializeJsonRpcMessage(McpJsonMapper jsonMapper, String jsonText) Deserializes a JSON string into a JSONRPCMessage object.
-
Field Details
-
JSONRPC_VERSION
- See Also:
-
FIRST_PAGE
-
JSON_SCHEMA_DIALECT_2020_12
The JSON Schema 2020-12 meta-schema URI (SEP-1613). This is the default dialect for all schema objects in MCP when no explicit$schemafield is present.- See Also:
-
METHOD_INITIALIZE
- See Also:
-
METHOD_NOTIFICATION_INITIALIZED
- See Also:
-
METHOD_PING
- See Also:
-
METHOD_NOTIFICATION_PROGRESS
- See Also:
-
METHOD_TOOLS_LIST
- See Also:
-
METHOD_TOOLS_CALL
- See Also:
-
METHOD_NOTIFICATION_TOOLS_LIST_CHANGED
- See Also:
-
METHOD_RESOURCES_LIST
- See Also:
-
METHOD_RESOURCES_READ
- See Also:
-
METHOD_NOTIFICATION_RESOURCES_LIST_CHANGED
- See Also:
-
METHOD_NOTIFICATION_RESOURCES_UPDATED
- See Also:
-
METHOD_RESOURCES_TEMPLATES_LIST
- See Also:
-
METHOD_RESOURCES_SUBSCRIBE
- See Also:
-
METHOD_RESOURCES_UNSUBSCRIBE
- See Also:
-
METHOD_PROMPT_LIST
- See Also:
-
METHOD_PROMPT_GET
- See Also:
-
METHOD_NOTIFICATION_PROMPTS_LIST_CHANGED
- See Also:
-
METHOD_COMPLETION_COMPLETE
- See Also:
-
METHOD_LOGGING_SET_LEVEL
- See Also:
-
METHOD_NOTIFICATION_MESSAGE
- See Also:
-
METHOD_ROOTS_LIST
- See Also:
-
METHOD_NOTIFICATION_ROOTS_LIST_CHANGED
- See Also:
-
METHOD_SAMPLING_CREATE_MESSAGE
- See Also:
-
METHOD_ELICITATION_CREATE
- See Also:
-
METHOD_NOTIFICATION_ELICITATION_COMPLETE
- See Also:
-
-
Method Details
-
deserializeJsonRpcMessage
public static McpSchema.JSONRPCMessage deserializeJsonRpcMessage(McpJsonMapper jsonMapper, String jsonText) throws IOException Deserializes a JSON string into a JSONRPCMessage object.- Parameters:
jsonMapper- The JsonMapper instance to use for deserializationjsonText- The JSON string to deserialize- Returns:
- A JSONRPCMessage instance using either the
McpSchema.JSONRPCRequest,McpSchema.JSONRPCNotification, orMcpSchema.JSONRPCResponseclasses. - Throws:
IOException- If there's an error during deserializationIllegalArgumentException- If the JSON structure doesn't match any known message type
-
Mapinstead.