Skip to content

feat(client): allow async tool output validators (#2971) - #3011

Open
karaaslanz wants to merge 2 commits into
modelcontextprotocol:mainfrom
karaaslanz:fix/client-async-output-schema-2971
Open

karaaslanz wants to merge 2 commits into
modelcontextprotocol:mainfrom
karaaslanz:fix/client-async-output-schema-2971

Conversation

@karaaslanz

Copy link
Copy Markdown

Summary

  • Allow the client-only jsonSchemaValidator option to provide an async getValidator(schema) and/or an async validation callback.
  • Await compilation before tools/call, converting rejected compilation into the existing per-tool InvalidParams error, and await validation before inspecting valid.
  • Preserve the shared synchronous validator interface and fromJsonSchema/server contract. Explicit per-call toolDefinition continues to compile in isolation.
  • Add four focused client tests covering async compilation + validation, compilation rejection, validation mismatch and explicit-definition isolation; include a client changeset.

Refs #2971. Related #2998 modifies lazy validator-cache compilation and must be considered when integrating this change.

Verification

  • git diff --check: PASS.
  • Exact patched-source probe on Windows Node 24 + TypeScript 5.9.3: syntax transpilation of modified source/test, sync control, async compile/validate, cached reuse, rejection/mismatch: PASS. This is a focused source-backed test, not the full SDK suite.
  • Full pnpm install / Vitest / package typecheck: NOT RUN successfully. The filtered install aborted with ERR_PNPM_BAD_PACKAGE_JSON: local node_modules/.pnpm/js-yaml@4.1.1/.../package.json contained NUL bytes. A direct typecheck was consequently blocked by missing workspace dependencies. No environment cleanup was attempted.

Opening as a draft so reviewers can confirm the client-only API scope and #2998 interaction before a ready-for-review declaration.

@changeset-bot

changeset-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 71ee58c

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

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/client Minor
@modelcontextprotocol/codemod Minor
@modelcontextprotocol/core Minor
@modelcontextprotocol/server-legacy Minor
@modelcontextprotocol/server Minor
@modelcontextprotocol/core-internal Patch

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 Oct 13, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@3011

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@3011

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@3011

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@3011

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@3011

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@3011

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@3011

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@3011

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@3011

commit: 71ee58c

@karaaslanz
karaaslanz marked this pull request as ready for review October 13, 2026 15:38
@karaaslanz
karaaslanz requested a review from a team as a code owner October 13, 2026 15:38

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant