You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds regression coverage for McpServer tool outputSchema validation when the registered Zod schema is not a bare z.object(...).
This is test-only. It does not change production behavior or claim to close either referenced issue.
Motivation and Context
The original coverage handled Zod wrappers such as .optional() and unions of object schemas. Review feedback asked for actual non-object roots too, especially strings and arrays.
Invalid structured output is still rejected against wrapper/non-object schemas, so validation is not skipped.
On the default/in-memory legacy path, z.string() and z.array(z.string()) output schemas are projected into the legacy { result: ... } wrapper and the returned structuredContent is wrapped the same way.
On a real modern createMcpHandler HTTP connection negotiated through server/discover, z.string() and z.array(z.string()) keep their natural output schemas and return bare structuredContent values.
No changeset is included because this is test-only.
The default/in-memory McpServer.server.connect() integration path negotiates a 2025-era connection, where non-object outputs are intentionally wrapped for compatibility. The added createMcpHandler coverage exercises the 2026-era path and shows that modern clients receive the natural string/array schema and structuredContent values.
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
Thanks, could you also add tests for actual non-objects like string and arrays? I have issues with strings in #2530
Also why do you say that it fixes #1308 as you just change tests? Or is it just a first draft before fixing the code as well?
Thanks for the catch. I added tests for actual non-object roots now: z.string() and z.array(z.string()).
The added coverage checks both paths:
the default/in-memory 2025-era path, where non-object output schemas and structuredContent are intentionally wrapped as { result: ... }
the modern createMcpHandler HTTP path negotiated via server/discover, where string/array schemas and bare structuredContent values are preserved
I also updated the PR title/body from Fixes #1308 to Refs #1308 / Refs #2530 and clarified that this PR is test-only, not a production code fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1308
Refs #2530
Adds regression coverage for
McpServertooloutputSchemavalidation when the registered Zod schema is not a barez.object(...).This is test-only. It does not change production behavior or claim to close either referenced issue.
Motivation and Context
The original coverage handled Zod wrappers such as
.optional()and unions of object schemas. Review feedback asked for actual non-object roots too, especially strings and arrays.The tests now verify:
z.object(...).optional()accepts matching structured output.z.union([z.object(...), z.object(...)])accepts matching structured output.z.string()andz.array(z.string())output schemas are projected into the legacy{ result: ... }wrapper and the returnedstructuredContentis wrapped the same way.createMcpHandlerHTTP connection negotiated throughserver/discover,z.string()andz.array(z.string())keep their natural output schemas and return barestructuredContentvalues.How Has This Been Tested?
Breaking Changes
None.
Types of changes
Checklist
Additional context
No changeset is included because this is test-only.
The default/in-memory
McpServer.server.connect()integration path negotiates a 2025-era connection, where non-object outputs are intentionally wrapped for compatibility. The addedcreateMcpHandlercoverage exercises the 2026-era path and shows that modern clients receive the natural string/array schema andstructuredContentvalues.