Skip to content

fix(tasks): default getTaskResult to the generic tasks/result schema when none is given - #2749

Open
SAY-5 wants to merge 2 commits into
modelcontextprotocol:v1.xfrom
SAY-5:fix-gettaskresult-optional-schema
Open

SAY-5 wants to merge 2 commits into
modelcontextprotocol:v1.xfrom
SAY-5:fix-gettaskresult-optional-schema

Conversation

@SAY-5

@SAY-5 SAY-5 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

client.experimental.tasks.getTaskResult(taskId) now falls back to GetTaskPayloadResultSchema when the caller omits the optional result schema, instead of forwarding undefined into validation.

Fixes #2742

Motivation and Context

The wrapper declares resultSchema?: T but hands it straight to Protocol.getTaskResult, whose parameter is required and goes into request() unchanged. With undefined the response path reaches isZ4Schema(undefined) in src/server/zod-compat.ts and throws TypeError: Cannot read properties of undefined (reading '_zod') from inside _onresponse, so it does not surface as a rejection of the awaited call either.

getTask and listTasks already pass a default schema; tasks/result has one too (GetTaskPayloadResultSchema, the loose ResultSchema), it was just never wired up. The type parameter now defaults to that schema so a schema-less call is typed as GetTaskPayloadResult rather than resolving through the bare AnyObjectSchema constraint. Callers that pass a schema are unaffected.

How Has This Been Tested?

Extended the existing should query task result from server using getTaskResult test in test/client/index.test.ts to also fetch the same task without a schema. It fails on v1.x with the reported _zod TypeError before the change. npm run typecheck, npm run lint and the client, server and task-lifecycle suites pass locally.

Breaking Changes

None.

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

Based on v1.x since that is where the reported code lives.

…when none is given

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@SAY-5
SAY-5 requested a review from a team as a code owner September 2, 2026 20:34
@claude claude Bot added the v1 Issues / PRs related to v1.x label Sep 25, 2026
@changeset-bot

changeset-bot Bot commented Sep 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9caca46

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.

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

pkg-pr-new Bot commented Sep 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 9caca46

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 Issues / PRs related to v1.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant