Skip to content

fix(client): default resultSchema to CallToolResultSchema in getTaskResult (#2742) - #2759

Open
amasen02 wants to merge 3 commits into
modelcontextprotocol:v1.xfrom
amasen02:fix/client-tasks-default-result-schema-2742
Open

fix(client): default resultSchema to CallToolResultSchema in getTaskResult (#2742)#2759
amasen02 wants to merge 3 commits into
modelcontextprotocol:v1.xfrom
amasen02:fix/client-tasks-default-result-schema-2742

Conversation

@amasen02

@amasen02 amasen02 commented Sep 5, 2026

Copy link
Copy Markdown

Summary

Fixes #2742

client.experimental.tasks.getTaskResult(taskId) declared resultSchema?: T, but when omitted, undefined was forwarded to the underlying protocol request, causing TypeError: Cannot read properties of undefined (reading '_zod') in isZ4Schema during response validation.

This change:

  • Defaults resultSchema to CallToolResultSchema both at runtime and in type generics for ExperimentalClientTasks.getTaskResult, matching the convention used by callToolStream().
  • Adds test assertions verifying that getTaskResult(taskId) works when omitting resultSchema (using default) as well as when supplying an explicit schema.

Motivation and Context

Resolves #2742. Callers omitting the optional schema parameter previously experienced an uncaught runtime error in the transport handler. Defaulting to CallToolResultSchema provides the expected behavior.

How Has This Been Tested?

  • Verified reproduction of TypeError: Cannot read properties of undefined (reading '_zod') before fix when omitting resultSchema.
  • Ran npx vitest run test/client/index.test.ts -t "getTaskResult" — passed.
  • Ran all 100 tests in test/experimental/tasks — 100% passed.
  • Ran full npx tsc --noEmit — clean with zero errors.
  • Verified ESLint and Prettier compliance.

@amasen02
amasen02 requested a review from a team as a code owner September 5, 2026 10:48
@changeset-bot

changeset-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4319dc7

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@modelcontextprotocol/sdk@2759

commit: 4319dc7

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.

1 participant