Skip to content

Commit a6ee2cb

Browse files
authored
fix: normalize null to undefined in ElicitResultSchema content field (#1204)
1 parent 4b651b8 commit a6ee2cb

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)