Skip to content

v2 refactor!: remove Zod schema parameter from public-facing APIs#1606

Merged
KKonstantinov merged 5 commits intomodelcontextprotocol:mainfrom
KKonstantinov:remove-schema-from-public-apis
Mar 4, 2026
Merged

v2 refactor!: remove Zod schema parameter from public-facing APIs#1606
KKonstantinov merged 5 commits intomodelcontextprotocol:mainfrom
KKonstantinov:remove-schema-from-public-apis

Conversation

@KKonstantinov
Copy link
Contributor

@KKonstantinov KKonstantinov commented Feb 28, 2026

Remove the Zod result schema argument from Protocol.request(), BaseContext.mcpReq.send(), Client.callTool(), and
ExperimentalServerTasks.requestStream(). The SDK now resolves the correct result schema internally based on the method name via a new getResultSchema() function.

This simplifies the public API surface — callers no longer need to import and pass result schemas like CallToolResultSchema or ElicitResultSchema when making requests.

BREAKING CHANGE: Protocol.request(), ctx.mcpReq.send(), Client.callTool(), and ExperimentalServerTasks.requestStream() no longer accept a schema parameter. Internal SDK methods use the new protected _requestWithSchema()/_requestStreamWithSchema() escape hatches.

Motivation and Context

How Has This Been Tested?

Breaking Changes

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

Additional context

Remove the Zod result schema argument from Protocol.request(),
BaseContext.mcpReq.send(), Client.callTool(), and
ExperimentalServerTasks.requestStream(). The SDK now resolves
the correct result schema internally based on the method name
via a new getResultSchema() function.

This simplifies the public API surface — callers no longer need
to import and pass result schemas like CallToolResultSchema or
ElicitResultSchema when making requests.

BREAKING CHANGE: Protocol.request(), ctx.mcpReq.send(),
Client.callTool(), and ExperimentalServerTasks.requestStream()
no longer accept a schema parameter. Internal SDK methods use
the new protected _requestWithSchema()/_requestStreamWithSchema()
escape hatches.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Feb 28, 2026

⚠️ No Changeset found

Latest commit: e8b3645

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 28, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1606

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1606

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1606

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1606

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1606

commit: 09d0f00

Add type casts and narrowing in example files where code accesses
result.content after client.request() or client.callTool(), since
the return type is now a union that includes CreateTaskResult.
Also fix formatting with prettier.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@KKonstantinov KKonstantinov changed the title refactor!: remove Zod schema parameter from public-facing APIs v2 refactor!: remove Zod schema parameter from public-facing APIs Mar 1, 2026
@KKonstantinov KKonstantinov marked this pull request as ready for review March 1, 2026 18:40
@KKonstantinov KKonstantinov requested a review from a team as a code owner March 1, 2026 18:40
@KKonstantinov KKonstantinov requested a review from mattzcarey March 2, 2026 11:47
@KKonstantinov KKonstantinov added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Mar 2, 2026

console.log('Calling notification tool...');
const result = await client.request(request, CallToolResultSchema);
const result = (await client.request(request)) as CallToolResult;
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make this typing work natively or pass a generic to avoid the cast

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Believe this is because of tasks (as it returns Promise<CallToolResult | CreateTaskResult>) - we could fix this as part of the tasks refactor?

But also, in this specific scenario/example here, we could simply do .callTool() instead of .request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#1628

Follow up PR

Copy link
Contributor

@mattzcarey mattzcarey left a comment

Choose a reason for hiding this comment

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

question but non blocking

@KKonstantinov KKonstantinov merged commit f88c376 into modelcontextprotocol:main Mar 4, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants