From f763dc327bb4a923a4acdfaa2e97e7a78b73d5ee Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 21 Jan 2026 10:25:56 +0100 Subject: [PATCH 1/5] refactor: create the types subpackage, and the jsonrpc module --- src/mcp/server/session.py | 6 +- src/mcp/types/__init__.py | 416 ++++++++++++++++++++++++++ src/mcp/{types.py => types/_types.py} | 75 +---- src/mcp/types/jsonrpc.py | 83 +++++ 4 files changed, 505 insertions(+), 75 deletions(-) create mode 100644 src/mcp/types/__init__.py rename src/mcp/{types.py => types/_types.py} (96%) create mode 100644 src/mcp/types/jsonrpc.py diff --git a/src/mcp/server/session.py b/src/mcp/server/session.py index cc4973fc2..5a70ee02e 100644 --- a/src/mcp/server/session.py +++ b/src/mcp/server/session.py @@ -42,7 +42,7 @@ async def handle_list_prompts(ctx: RequestContext) -> list[types.Prompt]: import anyio import anyio.lowlevel from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream -from pydantic import AnyUrl +from pydantic import AnyUrl, TypeAdapter import mcp.types as types from mcp.server.experimental.session_features import ExperimentalServerSessionFeatures @@ -105,11 +105,11 @@ def __init__( self._exit_stack.push_async_callback(lambda: self._incoming_message_stream_reader.aclose()) @property - def _receive_request_adapter(self) -> types.TypeAdapter[types.ClientRequest]: + def _receive_request_adapter(self) -> TypeAdapter[types.ClientRequest]: return types.client_request_adapter @property - def _receive_notification_adapter(self) -> types.TypeAdapter[types.ClientNotification]: + def _receive_notification_adapter(self) -> TypeAdapter[types.ClientNotification]: return types.client_notification_adapter @property diff --git a/src/mcp/types/__init__.py b/src/mcp/types/__init__.py new file mode 100644 index 000000000..e669d1114 --- /dev/null +++ b/src/mcp/types/__init__.py @@ -0,0 +1,416 @@ +"""MCP types package.""" + +# Re-export everything from _types for backward compatibility +from mcp.types._types import ( + DEFAULT_NEGOTIATED_VERSION, + LATEST_PROTOCOL_VERSION, + TASK_FORBIDDEN, + TASK_OPTIONAL, + TASK_REQUIRED, + TASK_STATUS_CANCELLED, + TASK_STATUS_COMPLETED, + TASK_STATUS_FAILED, + TASK_STATUS_INPUT_REQUIRED, + TASK_STATUS_WORKING, + Annotations, + AnyFunction, + AudioContent, + BaseMetadata, + BlobResourceContents, + CallToolRequest, + CallToolRequestParams, + CallToolResult, + CancelledNotification, + CancelledNotificationParams, + CancelTaskRequest, + CancelTaskRequestParams, + CancelTaskResult, + ClientCapabilities, + ClientNotification, + ClientRequest, + ClientResult, + ClientTasksCapability, + ClientTasksRequestsCapability, + CompleteRequest, + CompleteRequestParams, + CompleteResult, + Completion, + CompletionArgument, + CompletionContext, + CompletionsCapability, + ContentBlock, + CreateMessageRequest, + CreateMessageRequestParams, + CreateMessageResult, + CreateMessageResultWithTools, + CreateTaskResult, + Cursor, + ElicitationCapability, + ElicitationRequiredErrorData, + ElicitCompleteNotification, + ElicitCompleteNotificationParams, + ElicitRequest, + ElicitRequestedSchema, + ElicitRequestFormParams, + ElicitRequestParams, + ElicitRequestURLParams, + ElicitResult, + EmbeddedResource, + EmptyResult, + FormElicitationCapability, + GetPromptRequest, + GetPromptRequestParams, + GetPromptResult, + GetTaskPayloadRequest, + GetTaskPayloadRequestParams, + GetTaskPayloadResult, + GetTaskRequest, + GetTaskRequestParams, + GetTaskResult, + Icon, + ImageContent, + Implementation, + IncludeContext, + InitializedNotification, + InitializeRequest, + InitializeRequestParams, + InitializeResult, + ListPromptsRequest, + ListPromptsResult, + ListResourcesRequest, + ListResourcesResult, + ListResourceTemplatesRequest, + ListResourceTemplatesResult, + ListRootsRequest, + ListRootsResult, + ListTasksRequest, + ListTasksResult, + ListToolsRequest, + ListToolsResult, + LoggingCapability, + LoggingLevel, + LoggingMessageNotification, + LoggingMessageNotificationParams, + MCPModel, + MethodT, + ModelHint, + ModelPreferences, + Notification, + NotificationParams, + NotificationParamsT, + PaginatedRequest, + PaginatedRequestParams, + PaginatedResult, + PingRequest, + ProgressNotification, + ProgressNotificationParams, + ProgressToken, + Prompt, + PromptArgument, + PromptListChangedNotification, + PromptMessage, + PromptReference, + PromptsCapability, + ReadResourceRequest, + ReadResourceRequestParams, + ReadResourceResult, + RelatedTaskMetadata, + Request, + RequestParams, + RequestParamsT, + Resource, + ResourceContents, + ResourceLink, + ResourceListChangedNotification, + ResourcesCapability, + ResourceTemplate, + ResourceTemplateReference, + ResourceUpdatedNotification, + ResourceUpdatedNotificationParams, + Result, + Role, + Root, + RootsCapability, + RootsListChangedNotification, + SamplingCapability, + SamplingContent, + SamplingContextCapability, + SamplingMessage, + SamplingMessageContentBlock, + SamplingToolsCapability, + ServerCapabilities, + ServerNotification, + ServerRequest, + ServerResult, + ServerTasksCapability, + ServerTasksRequestsCapability, + SetLevelRequest, + SetLevelRequestParams, + StopReason, + SubscribeRequest, + SubscribeRequestParams, + Task, + TaskExecutionMode, + TaskMetadata, + TasksCallCapability, + TasksCancelCapability, + TasksCreateElicitationCapability, + TasksCreateMessageCapability, + TasksElicitationCapability, + TasksListCapability, + TasksSamplingCapability, + TaskStatus, + TaskStatusNotification, + TaskStatusNotificationParams, + TasksToolsCapability, + TextContent, + TextResourceContents, + Tool, + ToolAnnotations, + ToolChoice, + ToolExecution, + ToolListChangedNotification, + ToolResultContent, + ToolsCapability, + ToolUseContent, + UnsubscribeRequest, + UnsubscribeRequestParams, + UrlElicitationCapability, + client_notification_adapter, + client_request_adapter, + client_result_adapter, + server_notification_adapter, + server_request_adapter, + server_result_adapter, +) + +# Re-export JSONRPC types +from mcp.types.jsonrpc import ( + CONNECTION_CLOSED, + INTERNAL_ERROR, + INVALID_PARAMS, + INVALID_REQUEST, + METHOD_NOT_FOUND, + PARSE_ERROR, + URL_ELICITATION_REQUIRED, + ErrorData, + JSONRPCError, + JSONRPCMessage, + JSONRPCNotification, + JSONRPCRequest, + JSONRPCResponse, + RequestId, + jsonrpc_message_adapter, +) + +__all__ = [ + # Protocol version constants + "LATEST_PROTOCOL_VERSION", + "DEFAULT_NEGOTIATED_VERSION", + # Task execution mode constants + "TASK_FORBIDDEN", + "TASK_OPTIONAL", + "TASK_REQUIRED", + # Task status constants + "TASK_STATUS_CANCELLED", + "TASK_STATUS_COMPLETED", + "TASK_STATUS_FAILED", + "TASK_STATUS_INPUT_REQUIRED", + "TASK_STATUS_WORKING", + # Type aliases and variables + "AnyFunction", + "ContentBlock", + "Cursor", + "ElicitRequestedSchema", + "ElicitRequestParams", + "IncludeContext", + "LoggingLevel", + "MethodT", + "NotificationParamsT", + "ProgressToken", + "RequestParamsT", + "Role", + "SamplingContent", + "SamplingMessageContentBlock", + "StopReason", + "TaskExecutionMode", + "TaskStatus", + # Base classes + "MCPModel", + "BaseMetadata", + "Request", + "Notification", + "Result", + "RequestParams", + "NotificationParams", + "PaginatedRequest", + "PaginatedRequestParams", + "PaginatedResult", + "EmptyResult", + # Capabilities + "ClientCapabilities", + "ClientTasksCapability", + "ClientTasksRequestsCapability", + "CompletionsCapability", + "ElicitationCapability", + "FormElicitationCapability", + "LoggingCapability", + "PromptsCapability", + "ResourcesCapability", + "RootsCapability", + "SamplingCapability", + "SamplingContextCapability", + "SamplingToolsCapability", + "ServerCapabilities", + "ServerTasksCapability", + "ServerTasksRequestsCapability", + "TasksCancelCapability", + "TasksCallCapability", + "TasksCreateElicitationCapability", + "TasksCreateMessageCapability", + "TasksElicitationCapability", + "TasksListCapability", + "TasksSamplingCapability", + "TasksToolsCapability", + "ToolsCapability", + "UrlElicitationCapability", + # Content types + "Annotations", + "AudioContent", + "BlobResourceContents", + "EmbeddedResource", + "Icon", + "ImageContent", + "ResourceContents", + "ResourceLink", + "TextContent", + "TextResourceContents", + "ToolResultContent", + "ToolUseContent", + # Entity types + "Completion", + "CompletionArgument", + "CompletionContext", + "Implementation", + "ModelHint", + "ModelPreferences", + "Prompt", + "PromptArgument", + "PromptMessage", + "PromptReference", + "Resource", + "ResourceTemplate", + "ResourceTemplateReference", + "Root", + "SamplingMessage", + "Task", + "TaskMetadata", + "RelatedTaskMetadata", + "Tool", + "ToolAnnotations", + "ToolChoice", + "ToolExecution", + # Requests + "CallToolRequest", + "CallToolRequestParams", + "CancelTaskRequest", + "CancelTaskRequestParams", + "CompleteRequest", + "CompleteRequestParams", + "CreateMessageRequest", + "CreateMessageRequestParams", + "ElicitRequest", + "ElicitRequestFormParams", + "ElicitRequestURLParams", + "GetPromptRequest", + "GetPromptRequestParams", + "GetTaskPayloadRequest", + "GetTaskPayloadRequestParams", + "GetTaskRequest", + "GetTaskRequestParams", + "InitializeRequest", + "InitializeRequestParams", + "ListPromptsRequest", + "ListResourcesRequest", + "ListResourceTemplatesRequest", + "ListRootsRequest", + "ListTasksRequest", + "ListToolsRequest", + "PingRequest", + "ReadResourceRequest", + "ReadResourceRequestParams", + "SetLevelRequest", + "SetLevelRequestParams", + "SubscribeRequest", + "SubscribeRequestParams", + "UnsubscribeRequest", + "UnsubscribeRequestParams", + # Results + "CallToolResult", + "CancelTaskResult", + "CompleteResult", + "CreateMessageResult", + "CreateMessageResultWithTools", + "CreateTaskResult", + "ElicitResult", + "ElicitationRequiredErrorData", + "GetPromptResult", + "GetTaskPayloadResult", + "GetTaskResult", + "InitializeResult", + "ListPromptsResult", + "ListResourcesResult", + "ListResourceTemplatesResult", + "ListRootsResult", + "ListTasksResult", + "ListToolsResult", + "ReadResourceResult", + # Notifications + "CancelledNotification", + "CancelledNotificationParams", + "ElicitCompleteNotification", + "ElicitCompleteNotificationParams", + "InitializedNotification", + "LoggingMessageNotification", + "LoggingMessageNotificationParams", + "ProgressNotification", + "ProgressNotificationParams", + "PromptListChangedNotification", + "ResourceListChangedNotification", + "ResourceUpdatedNotification", + "ResourceUpdatedNotificationParams", + "RootsListChangedNotification", + "TaskStatusNotification", + "TaskStatusNotificationParams", + "ToolListChangedNotification", + # Union types for request/response routing + "ClientNotification", + "ClientRequest", + "ClientResult", + "ServerNotification", + "ServerRequest", + "ServerResult", + # Type adapters + "client_notification_adapter", + "client_request_adapter", + "client_result_adapter", + "server_notification_adapter", + "server_request_adapter", + "server_result_adapter", + # JSON-RPC types + "CONNECTION_CLOSED", + "INTERNAL_ERROR", + "INVALID_PARAMS", + "INVALID_REQUEST", + "METHOD_NOT_FOUND", + "PARSE_ERROR", + "URL_ELICITATION_REQUIRED", + "ErrorData", + "JSONRPCError", + "JSONRPCMessage", + "JSONRPCNotification", + "JSONRPCRequest", + "JSONRPCResponse", + "RequestId", + "jsonrpc_message_adapter", +] diff --git a/src/mcp/types.py b/src/mcp/types/_types.py similarity index 96% rename from src/mcp/types.py rename to src/mcp/types/_types.py index 10b0c61fa..eb94687e3 100644 --- a/src/mcp/types.py +++ b/src/mcp/types/_types.py @@ -7,6 +7,8 @@ from pydantic import BaseModel, ConfigDict, Field, FileUrl, TypeAdapter from pydantic.alias_generators import to_camel +from mcp.types.jsonrpc import RequestId + LATEST_PROTOCOL_VERSION = "2025-11-25" """ @@ -20,7 +22,6 @@ ProgressToken = str | int Cursor = str Role = Literal["user", "assistant"] -RequestId = Annotated[int, Field(strict=True)] | str AnyFunction: TypeAlias = Callable[..., Any] TaskExecutionMode = Literal["forbidden", "optional", "required"] @@ -32,6 +33,7 @@ class MCPModel(BaseModel): """Base class for all MCP protocol types. Allows extra fields for forward compatibility.""" + # TODO(Marcelo): The extra="allow" should be only on specific types e.g. `Meta`, not on the base class. model_config = ConfigDict(extra="allow", alias_generator=to_camel, populate_by_name=True) @@ -130,77 +132,6 @@ class PaginatedResult(Result): """ -class JSONRPCRequest(Request[dict[str, Any] | None, str]): - """A request that expects a response.""" - - jsonrpc: Literal["2.0"] - id: RequestId - method: str - params: dict[str, Any] | None = None - - -class JSONRPCNotification(Notification[dict[str, Any] | None, str]): - """A notification which does not expect a response.""" - - jsonrpc: Literal["2.0"] - params: dict[str, Any] | None = None - - -class JSONRPCResponse(MCPModel): - """A successful (non-error) response to a request.""" - - jsonrpc: Literal["2.0"] - id: RequestId - result: dict[str, Any] - - -# MCP-specific error codes in the range [-32000, -32099] -URL_ELICITATION_REQUIRED = -32042 -"""Error code indicating that a URL mode elicitation is required before the request can be processed.""" - -# SDK error codes -CONNECTION_CLOSED = -32000 -# REQUEST_TIMEOUT = -32001 # the typescript sdk uses this - -# Standard JSON-RPC error codes -PARSE_ERROR = -32700 -INVALID_REQUEST = -32600 -METHOD_NOT_FOUND = -32601 -INVALID_PARAMS = -32602 -INTERNAL_ERROR = -32603 - - -class ErrorData(MCPModel): - """Error information for JSON-RPC error responses.""" - - code: int - """The error type that occurred.""" - - message: str - """ - A short description of the error. The message SHOULD be limited to a concise single - sentence. - """ - - data: Any | None = None - """ - Additional information about the error. The value of this member is defined by the - sender (e.g. detailed error information, nested errors etc.). - """ - - -class JSONRPCError(MCPModel): - """A response to a request that indicates an error occurred.""" - - jsonrpc: Literal["2.0"] - id: str | int - error: ErrorData - - -JSONRPCMessage = JSONRPCRequest | JSONRPCNotification | JSONRPCResponse | JSONRPCError -jsonrpc_message_adapter = TypeAdapter[JSONRPCMessage](JSONRPCMessage) - - class EmptyResult(Result): """A response that indicates success but carries no data.""" diff --git a/src/mcp/types/jsonrpc.py b/src/mcp/types/jsonrpc.py new file mode 100644 index 000000000..eae3fc949 --- /dev/null +++ b/src/mcp/types/jsonrpc.py @@ -0,0 +1,83 @@ +"""This module follows the JSON-RPC 2.0 specification: https://www.jsonrpc.org/specification.""" + +from __future__ import annotations + +from typing import Annotated, Any, Literal + +from pydantic import BaseModel, Field, TypeAdapter + +RequestId = Annotated[int, Field(strict=True)] | str +"""The ID of a JSON-RPC request.""" + + +class JSONRPCRequest(BaseModel): + """A JSON-RPC request that expects a response.""" + + jsonrpc: Literal["2.0"] + id: RequestId + method: str + params: dict[str, Any] | None = None + + +class JSONRPCNotification(BaseModel): + """A JSON-RPC notification which does not expect a response.""" + + jsonrpc: Literal["2.0"] + method: str + params: dict[str, Any] | None = None + + +# TODO(Marcelo): This is actually not correct. A JSONRPCResponse is the union of a successful response and an error. +class JSONRPCResponse(BaseModel): + """A successful (non-error) response to a request.""" + + jsonrpc: Literal["2.0"] + id: RequestId + result: dict[str, Any] + + +# MCP-specific error codes in the range [-32000, -32099] +URL_ELICITATION_REQUIRED = -32042 +"""Error code indicating that a URL mode elicitation is required before the request can be processed.""" + +# SDK error codes +CONNECTION_CLOSED = -32000 +# REQUEST_TIMEOUT = -32001 # the typescript sdk uses this + +# Standard JSON-RPC error codes +PARSE_ERROR = -32700 +INVALID_REQUEST = -32600 +METHOD_NOT_FOUND = -32601 +INVALID_PARAMS = -32602 +INTERNAL_ERROR = -32603 + + +class ErrorData(BaseModel): + """Error information for JSON-RPC error responses.""" + + code: int + """The error type that occurred.""" + + message: str + """ + A short description of the error. The message SHOULD be limited to a concise single + sentence. + """ + + data: Any = None + """ + Additional information about the error. The value of this member is defined by the + sender (e.g. detailed error information, nested errors etc.). + """ + + +class JSONRPCError(BaseModel): + """A response to a request that indicates an error occurred.""" + + jsonrpc: Literal["2.0"] + id: str | int + error: ErrorData + + +JSONRPCMessage = JSONRPCRequest | JSONRPCNotification | JSONRPCResponse | JSONRPCError +jsonrpc_message_adapter: TypeAdapter[JSONRPCMessage] = TypeAdapter(JSONRPCMessage) From 35d0951497cb12d8f4d0e63be6bf7edcacc7d947 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 21 Jan 2026 13:43:22 +0100 Subject: [PATCH 2/5] Apply suggestion from @Kludex --- src/mcp/types/_types.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mcp/types/_types.py b/src/mcp/types/_types.py index eb94687e3..7b109a1c3 100644 --- a/src/mcp/types/_types.py +++ b/src/mcp/types/_types.py @@ -22,7 +22,6 @@ ProgressToken = str | int Cursor = str Role = Literal["user", "assistant"] -AnyFunction: TypeAlias = Callable[..., Any] TaskExecutionMode = Literal["forbidden", "optional", "required"] TASK_FORBIDDEN: Final[Literal["forbidden"]] = "forbidden" From da407d01aed475c2e8dae54778b1ab703f182134 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 21 Jan 2026 13:56:15 +0100 Subject: [PATCH 3/5] drop clalable --- src/mcp/types/_types.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mcp/types/_types.py b/src/mcp/types/_types.py index 7b109a1c3..f63d3ebac 100644 --- a/src/mcp/types/_types.py +++ b/src/mcp/types/_types.py @@ -1,6 +1,5 @@ from __future__ import annotations -from collections.abc import Callable from datetime import datetime from typing import Annotated, Any, Final, Generic, Literal, TypeAlias, TypeVar From b689e8f27f07b3ead0fdc2443f777fdb7c822497 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 21 Jan 2026 15:14:59 +0100 Subject: [PATCH 4/5] fully drop anyfunction --- src/mcp/types/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mcp/types/__init__.py b/src/mcp/types/__init__.py index e669d1114..25e821cc9 100644 --- a/src/mcp/types/__init__.py +++ b/src/mcp/types/__init__.py @@ -13,7 +13,6 @@ TASK_STATUS_INPUT_REQUIRED, TASK_STATUS_WORKING, Annotations, - AnyFunction, AudioContent, BaseMetadata, BlobResourceContents, @@ -218,7 +217,6 @@ "TASK_STATUS_INPUT_REQUIRED", "TASK_STATUS_WORKING", # Type aliases and variables - "AnyFunction", "ContentBlock", "Cursor", "ElicitRequestedSchema", From a45cc281466f52fcd4db176794fb0993a66151c2 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 21 Jan 2026 15:15:40 +0100 Subject: [PATCH 5/5] fix: replace http code by jsonrpc --- src/mcp/server/streamable_http_manager.py | 5 +---- src/mcp/server/validation.py | 7 +------ src/mcp/shared/session.py | 4 ++-- src/mcp/types/__init__.py | 2 ++ src/mcp/types/jsonrpc.py | 2 +- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/mcp/server/streamable_http_manager.py b/src/mcp/server/streamable_http_manager.py index 3213eceff..964c52b6f 100644 --- a/src/mcp/server/streamable_http_manager.py +++ b/src/mcp/server/streamable_http_manager.py @@ -281,10 +281,7 @@ async def run_server(*, task_status: TaskStatus[None] = anyio.TASK_STATUS_IGNORE error_response = JSONRPCError( jsonrpc="2.0", id="server-error", - error=ErrorData( - code=INVALID_REQUEST, - message="Session not found", - ), + error=ErrorData(code=INVALID_REQUEST, message="Session not found"), ) response = Response( content=error_response.model_dump_json(by_alias=True, exclude_none=True), diff --git a/src/mcp/server/validation.py b/src/mcp/server/validation.py index 192b9d492..cfd663d43 100644 --- a/src/mcp/server/validation.py +++ b/src/mcp/server/validation.py @@ -50,12 +50,7 @@ def validate_sampling_tools( """ if tools is not None or tool_choice is not None: if not check_sampling_tools_capability(client_caps): - raise McpError( - ErrorData( - code=INVALID_PARAMS, - message="Client does not support sampling tools capability", - ) - ) + raise McpError(ErrorData(code=INVALID_PARAMS, message="Client does not support sampling tools capability")) def validate_tool_use_result_messages(messages: list[SamplingMessage]) -> None: diff --git a/src/mcp/shared/session.py b/src/mcp/shared/session.py index e01167956..d00fd764c 100644 --- a/src/mcp/shared/session.py +++ b/src/mcp/shared/session.py @@ -7,7 +7,6 @@ from typing import Any, Generic, Protocol, TypeVar import anyio -import httpx from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream from pydantic import BaseModel, TypeAdapter from typing_extensions import Self @@ -18,6 +17,7 @@ from mcp.types import ( CONNECTION_CLOSED, INVALID_PARAMS, + REQUEST_TIMEOUT, CancelledNotification, ClientNotification, ClientRequest, @@ -272,7 +272,7 @@ async def send_request( except TimeoutError: raise McpError( ErrorData( - code=httpx.codes.REQUEST_TIMEOUT, + code=REQUEST_TIMEOUT, message=( f"Timed out while waiting for response to {request.__class__.__name__}. " f"Waited {timeout} seconds." diff --git a/src/mcp/types/__init__.py b/src/mcp/types/__init__.py index 25e821cc9..c4df66f8d 100644 --- a/src/mcp/types/__init__.py +++ b/src/mcp/types/__init__.py @@ -191,6 +191,7 @@ INVALID_REQUEST, METHOD_NOT_FOUND, PARSE_ERROR, + REQUEST_TIMEOUT, URL_ELICITATION_REQUIRED, ErrorData, JSONRPCError, @@ -402,6 +403,7 @@ "INVALID_REQUEST", "METHOD_NOT_FOUND", "PARSE_ERROR", + "REQUEST_TIMEOUT", "URL_ELICITATION_REQUIRED", "ErrorData", "JSONRPCError", diff --git a/src/mcp/types/jsonrpc.py b/src/mcp/types/jsonrpc.py index eae3fc949..86066d80d 100644 --- a/src/mcp/types/jsonrpc.py +++ b/src/mcp/types/jsonrpc.py @@ -42,7 +42,7 @@ class JSONRPCResponse(BaseModel): # SDK error codes CONNECTION_CLOSED = -32000 -# REQUEST_TIMEOUT = -32001 # the typescript sdk uses this +REQUEST_TIMEOUT = -32001 # Standard JSON-RPC error codes PARSE_ERROR = -32700