Skip to content

Conversation

@felixweinberger
Copy link
Contributor

Summary

Adds the jsonrpc: Literal["2.0"] = "2.0" field to the base Notification class, aligning with the TypeScript SDK where notification types extend JSONRPCNotification.

Motivation and Context

Issue #1729 identified that notification types like ProgressNotification inherit from Notification, not JSONRPCNotification, meaning they lack the jsonrpc: "2.0" field.

This PR addresses the Notifications part of that issue. The Results part is intentionally not changed because:

  • Results need an id field that comes from the request
  • Handlers don't know the request ID when returning a result
  • The session layer must wrap results with the request ID
  • The TypeScript SDK also keeps Results as payloads (extending Result, not JSONRPCResultResponse)

Partially fixes #1729

How Has This Been Tested?

  • All 1100 tests pass
  • pyright and ruff pass

Breaking Changes

None. The jsonrpc field has a default value, so existing code continues to work.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

This aligns with the TypeScript SDK where notification types extend
JSONRPCNotification and include the jsonrpc field. All notification
types now automatically have jsonrpc='2.0' via the base class.

The session.py code no longer needs to explicitly add jsonrpc since
it's included in the notification's model_dump().

Github-Issue: #1729
@felixweinberger felixweinberger marked this pull request as draft January 16, 2026 14:36
@felixweinberger felixweinberger deleted the fweinberger/jsonrpc-types branch January 16, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notification and Result types should inherit from JSONRPC base classes

2 participants