Skip to content

Add default JSON schema validator to MCP client#665

Merged
threepointone merged 1 commit into
mainfrom
mcp-client-default-options
Nov 19, 2025
Merged

Add default JSON schema validator to MCP client#665
threepointone merged 1 commit into
mainfrom
mcp-client-default-options

Conversation

@threepointone

Copy link
Copy Markdown
Contributor

Introduces CfWorkerJsonSchemaValidator as the default jsonSchemaValidator in MCP client options. Ensures that client instantiation includes schema validation by default, improving reliability and consistency.

Introduces CfWorkerJsonSchemaValidator as the default jsonSchemaValidator in MCP client options. Ensures that client instantiation includes schema validation by default, improving reliability and consistency.
@changeset-bot

changeset-bot Bot commented Nov 19, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 998252c

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

This PR includes changesets to release 1 package
Name Type
agents 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 Nov 19, 2025

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@665

commit: 998252c

@claude

claude Bot commented Nov 19, 2025

Copy link
Copy Markdown

Claude Code Review

Potential Issue: Validator Instance Sharing

The change creates a single shared CfWorkerJsonSchemaValidator instance at module level (line 30-31) that will be reused across all MCP client instances. Depending on the validator's implementation, this could cause issues if:

  1. The validator maintains internal state
  2. Multiple clients access it concurrently with race conditions

Recommendation: Consider creating a new validator instance per client to avoid potential state/concurrency issues, OR verify that CfWorkerJsonSchemaValidator is stateless/thread-safe and document this assumption.

Otherwise: The change looks reasonable - adds validation by default while allowing overrides, includes proper changeset.

threepointone pushed a commit to cloudflare/cloudflare-docs that referenced this pull request Nov 19, 2025
Adds documentation for the CfWorkerJsonSchemaValidator that is now included by default in MCP client connections. This improves transparency about the default validation behavior and helps users understand that tool parameters are automatically validated.

Synced from cloudflare/agents#665

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

Co-Authored-By: Claude <noreply@anthropic.com>
@threepointone

Copy link
Copy Markdown
Contributor Author

📚 Documentation sync in progress

A documentation PR has been created to reflect the changes from this PR:

Documentation PR: cloudflare/cloudflare-docs#26620

The documentation updates include:

  • Added information about the default CfWorkerJsonSchemaValidator in MCP client connections
  • Documented that JSON schema validation is now included by default for all MCP tool parameters
  • Added a note explaining the validation behavior and how to override it if needed

The docs PR is ready for review and will be merged once this PR is approved and merged.


🤖 Generated with Claude Code

@threepointone
threepointone merged commit 4c0838a into main Nov 19, 2025
6 checks passed
@threepointone
threepointone deleted the mcp-client-default-options branch November 19, 2025 11:53
@threepointone threepointone mentioned this pull request Nov 19, 2025
naji247 pushed a commit to agentcathq/agents that referenced this pull request Nov 20, 2025
Introduces CfWorkerJsonSchemaValidator as the default jsonSchemaValidator in MCP client options. Ensures that client instantiation includes schema validation by default, improving reliability and consistency.
threepointone added a commit to cloudflare/cloudflare-docs that referenced this pull request Nov 21, 2025
Adds documentation for the CfWorkerJsonSchemaValidator that is now included by default in MCP client connections. This improves transparency about the default validation behavior and helps users understand that tool parameters are automatically validated.

Synced from cloudflare/agents#665

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

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants