diff --git a/src/mcp/shared/session.py b/src/mcp/shared/session.py index 51d1f64e02..94b340372f 100644 --- a/src/mcp/shared/session.py +++ b/src/mcp/shared/session.py @@ -320,8 +320,8 @@ async def send_notification( """ # Some transport implementations may need to set the related_request_id # to attribute to the notifications to the request that triggered them. + # Note: notification already has jsonrpc="2.0" from base Notification class jsonrpc_notification = JSONRPCNotification( - jsonrpc="2.0", **notification.model_dump(by_alias=True, mode="json", exclude_none=True), ) session_message = SessionMessage( # pragma: no cover diff --git a/src/mcp/types.py b/src/mcp/types.py index 6fc551035b..b91b8f3f31 100644 --- a/src/mcp/types.py +++ b/src/mcp/types.py @@ -108,6 +108,7 @@ class PaginatedRequest(Request[PaginatedRequestParams | None, MethodT], Generic[ class Notification(MCPModel, Generic[NotificationParamsT, MethodT]): """Base class for JSON-RPC notifications.""" + jsonrpc: Literal["2.0"] = "2.0" method: MethodT params: NotificationParamsT @@ -142,7 +143,6 @@ class JSONRPCRequest(Request[dict[str, Any] | None, str]): 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