Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 7b71d22 The changes in this PR will be included in the next version bump. This PR includes changesets to release 33 packages
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 |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
Merged
This branch is waiting to be deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
McpServer.registerToolkitput the schema-encoded success value of a toolkit tool (Schema.encodeUnknownEffect(successSchema)) intostructuredContent. The RPC layer then serializes thetools/callresult withSchema.toCodecJson, which rejects values that are not JSON. A result with aSchema.Voidfield, aSchema.Datefield or aSchema.optionalfield set toundefinedtherefore failed with-32603 Internal error, on2026-07-28and on2025-11-25. Repro: #10088The advertised
outputSchemawas already built from the JSON codec (toolJsonSchema), so results that did serialize could still contradict it. For example,NaNwas sent as a number, but the schema lists it as the string"NaN".registerToolkitnow converts the Toolkit's encoded success value withSchema.toCodecJson(Schema.toEncoded(successSchema)), so the success schema's own transformations still run only once. The encoder is built once per tool. BothstructuredContentand its text mirror use the JSON value:structuredContentStruct({ reply: Void, version: Number }){ reply: undefined, version: 1 }{"reply":null,"version":1}Struct({ at: Date }){ at: new Date(0) }{"at":"1970-01-01T00:00:00.000Z"}Struct({ note: optional(String) }){ note: undefined }{"note":null}Each value validates against the tool's listed
outputSchema.Schema.Void, still returnscontent: []withoutstructuredContent(Fix void MCP tools are reported as internal failures #7072).nulland array results keep the behavior from fix(ai): keep non-object tool results out of structuredContent #7495.AiErrorwith reasonToolResultEncodingError, as the Toolkit already does for its own result-encoding failures. Before this change, abigintunderSchema.Unknownwas reported as aTypeErrordefect fromJSON.stringify. The existing test is updated for the new cause.Datebecomes an ISO string,NaNbecomes"NaN", and aVoidfield becomesnull.MCP.mdmentions this under "Tools and Toolkit".There is no public API change.
Tests
test/ai/McpServer/McpConformance/ToolsTest.ts, "Structured content": new toolkit fixturesVoidFieldTool,DateFieldTool,OptionalFieldToolandNaNFieldTool. For each, the test checks thestructuredContenton the wire, thatcontent[0].textis itsJSON.stringify, and that it validates against the listedoutputSchema(Ajv 2020). The suite runs for2025-06-18,2025-11-25and2026-07-28. The cases for all three revisions fail without the source change and pass with it.test/ai/McpServer/McpServer.test.ts: the serialization-failure test now expects a reportedToolResultEncodingError.pnpm test --run packages/effect/test/ai/: 1662 passed, 48 skipped.pnpm check,pnpm test-types packages/effect/typetest/ai/McpServer.tst.ts packages/effect/typetest/ai/Toolkit.tst.ts,pnpm lint,pnpm jsdocs --check,pnpm circular,deno check .: clean.pnpm ai-docgenleaves no diff.Closes #10088
Closes EFF-3101