Skip to content

Commit 63d818d

Browse files
docs(core): clarify isSpecType validates input type, not output structure
1 parent 94abeea commit 63d818d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/core/src/types/specTypeSchema.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,14 @@ export const specTypeSchemas: SchemaRecord = Object.freeze(_specTypeSchemas) as
271271
/**
272272
* Type predicates for every MCP spec type, keyed by type name.
273273
*
274-
* Returns `true` if the value structurally matches the named spec type. Each guard is a standalone
275-
* function, so it can be passed directly as a callback.
274+
* Returns `true` if the value satisfies the schema's input type (`z.input<>`, before defaults and
275+
* transforms are applied), and narrows to that input type. For schemas with `.default()` or
276+
* `.preprocess()`, this may accept values that do not structurally match the named output type;
277+
* for example `isSpecType.CallToolResult({})` is `true` because `content` has a default. Use
278+
* `specTypeSchemas.X['~standard'].validate(value)` (or `.parse(value)`) when you need the
279+
* validated output value.
280+
*
281+
* Each guard is a standalone function, so it can be passed directly as a callback.
276282
*
277283
* @example
278284
* ```ts source="./specTypeSchema.examples.ts#isSpecType_basicUsage"

0 commit comments

Comments
 (0)