Skip to content

Commit f7603b3

Browse files
committed
fix: normalize null to undefined in ElicitResultSchema content field
Add z.preprocess to convert null values to undefined in the content field of ElicitResultSchema for better leniency while maintaining type compatibility. Per MCP spec, content is typically omitted for decline/cancel actions.
1 parent fab7e1e commit f7603b3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,8 +1831,13 @@ export const ElicitResultSchema = ResultSchema.extend({
18311831
/**
18321832
* The submitted form data, only present when action is "accept".
18331833
* Contains values matching the requested schema.
1834+
* Per MCP spec, content is "typically omitted" for decline/cancel actions.
1835+
* We normalize null to undefined for leniency while maintaining type compatibility.
18341836
*/
1835-
content: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.string())])).optional()
1837+
content: z.preprocess(
1838+
(val) => (val === null ? undefined : val),
1839+
z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.string())])).optional()
1840+
)
18361841
});
18371842

18381843
/* Autocomplete */

0 commit comments

Comments
 (0)