Skip to content

Split responses and errors into separate message categories#1441

Merged
dsp-ant merged 6 commits into
modelcontextprotocol:mainfrom
pja-ant:split-response-error-categories
Nov 25, 2025
Merged

Split responses and errors into separate message categories#1441
dsp-ant merged 6 commits into
modelcontextprotocol:mainfrom
pja-ant:split-response-error-categories

Conversation

@pja-ant

@pja-ant pja-ant commented Sep 8, 2025

Copy link
Copy Markdown
Contributor

I found it odd that the spec includes both success and error responses under the same Message type, but the schema has these as separate. I think keeping them separate works better so that (a) it matches the schema, and (b) you don't need awkward wording to explain what each type of responses needs to do.

A couple of other changes:

  • Linked to the respective messages in schema
  • Clarified that ID field for errors may not be there in some cases (e.g. for malformed requests as described in transport section)

Motivation and Context

Tidying up docs.

How Has This Been Tested?

npm serve:docs

Breaking Changes

N/A

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

@pja-ant pja-ant requested a review from a team September 8, 2025 15:18

@jonathanhefner jonathanhefner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the schema here is in reference to the JSON-RPC response object (which encompasses both "regular" responses and error responses), whereas our schema.json models those a bit differently.

My instinct would be to change schema.json to more closely model the JSON-RPC spec, but I also think the changes in this PR improve clarity.

Comment thread docs/specification/draft/basic/index.mdx Outdated
Comment thread docs/specification/draft/basic/index.mdx Outdated
@pja-ant

pja-ant commented Sep 9, 2025

Copy link
Copy Markdown
Contributor Author

Good call, didn't notice that JSON-RPC and the schema differed. I think updating the schema to match JSON-RPC feels like the right approach here.

Comment thread docs/specification/draft/basic/index.mdx Outdated
Comment thread schema/draft/schema.ts Outdated
Comment thread schema/draft/schema.ts Outdated
@pja-ant pja-ant force-pushed the split-response-error-categories branch from d5632fa to 0509c42 Compare September 25, 2025 12:33
@pja-ant

pja-ant commented Sep 25, 2025

Copy link
Copy Markdown
Contributor Author

Resolved comments (id for errors now optional, and updated response schema to be sum type over success + error response).

Comment thread schema/draft/schema.ts Outdated
@jonathanhefner jonathanhefner enabled auto-merge (squash) September 25, 2025 19:47
pja-ant and others added 5 commits November 25, 2025 11:22
- Separate "Responses" section for successful responses with result field
- Separate "Errors" section for error responses with error field
- Add schema anchor links to each message type description
- Clarify that responses must have result, errors must have error field

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Simplified the message type hierarchy by combining successful responses
and error responses into a single "Responses" section, as they are both
responses to requests per JSON-RPC 2.0 specification.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…rror ID optional

- Rename JSONRPCResponse to JSONRPCResponseSuccess
- Rename JSONRPCError to JSONRPCResponseError
- Make JSONRPCResponseError.id optional (for malformed requests)
- Create JSONRPCResponse as union type: JSONRPCResponseSuccess | JSONRPCResponseError
- Split Responses section in basic/index.mdx into Success Responses and Error Responses subsections
- Regenerate schema.json and schema.mdx

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ponseError to JSONRPCErrorResponse

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@pja-ant pja-ant force-pushed the split-response-error-categories branch from 5e1cda4 to 89dac20 Compare November 25, 2025 11:31
@pja-ant pja-ant requested a review from a team as a code owner November 25, 2025 11:31
@pja-ant pja-ant marked this pull request as draft November 25, 2025 11:37
auto-merge was automatically disabled November 25, 2025 11:37

Pull request was converted to draft

@pja-ant pja-ant marked this pull request as ready for review November 25, 2025 11:37
@dsp-ant dsp-ant self-requested a review November 25, 2025 15:42
@dsp-ant dsp-ant merged commit 14043ad into modelcontextprotocol:main Nov 25, 2025
2 checks passed
Comment thread schema/draft/schema.ts
*
* @category JSON-RPC
*/
export interface JSONRPCError {

@felixweinberger felixweinberger Dec 16, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: I think this technically manifests as a breaking change in the SDKs - e.g. TypeScript SDK used to export this type but it was replaced by the union above.

Also JSONRPCResponse is now a different type (union of 2 types rather than specifically JSONRPCResultResponse. Had keep around the old types as @deprecated: modelcontextprotocol/typescript-sdk#1306

cc: @KKonstantinov

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.

6 participants