Emit MCP tool output schemas - #6780
Conversation
🦋 Changeset detectedLatest commit: 63cd95a The changes in this PR will be included in the next version bump. This PR includes changesets to release 29 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 |
| name: tool.name, | ||
| description: Tool.getDescription(tool), | ||
| inputSchema: Tool.getJsonSchema(tool), | ||
| ...(tool.successSchema === Schema.Void || tool.successSchema === Schema.Unknown ? {} : { |
There was a problem hiding this comment.
This should check the ast instead of comparing against the schema instances
There was a problem hiding this comment.
Actually I think every tool has a valid success schema, so we could always include outputSchema. Validate this against the mcp spec first before changing anything.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
outputSchemafield onMcpSchema.Tool— optional JSON Schema describing the tool's output, omitted when the tool has no typed success schemaregisterToolkitemitsoutputSchema— computes and spreadsoutputSchemafor tools whosesuccessSchemais neitherSchema.VoidnorSchema.Unknown- Test for typed vs untyped — adds an
UntypedTool(defaulting toSchema.Void) and a test assertingoutputSchemaappears only for typed tools
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Fixed
Schema.Void/Schema.Unknowncheck to use AST type guards — switched from===reference equality toSchemaAST.isVoid/SchemaAST.isUnknowninregisterToolkit, so annotated schemas likeSchema.Void.annotate({ description: "No output" })are correctly treated as void - Added
AnnotatedVoidTooltest coverage — new test tool withSchema.Void.annotate(...)and assertions confirming it omitsoutputSchemajust like an unadorned void tool
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Narrowed
outputSchemagating to object-type schemas only — switched from "exclude void/unknown schemas" to "only include schemas whose JSON Schematypeis"object"", so scalar tools likeSchema.Stringno longer emitoutputSchema - Added
StructuredResultTooltest — exercises aSchema.Structtool and verifies the full object output schema withproperties,required, andadditionalProperties - Added scalar-omission assertion — verifies
OptionalStringTool(scalar) does not get anoutputSchemafield, confirming the newtype === "object"gate
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

Summary
tools/listoutputSchemafor tools without typed success schemasTesting
pnpm --filter effect test --run test/unstable/ai/McpServer.test.tspnpm lint-fixpnpm checkgit diff --checkCloses EFF-226
Closes #6753