From f7603b3e76cc02d6b4371634aaa4019789e02523 Mon Sep 17 00:00:00 2001 From: Matt Carey Date: Mon, 1 Dec 2025 16:29:44 +0000 Subject: [PATCH 1/2] 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. --- src/types.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index e02d4e23e..86ae6ea12 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1831,8 +1831,13 @@ export const ElicitResultSchema = ResultSchema.extend({ /** * The submitted form data, only present when action is "accept". * Contains values matching the requested schema. + * Per MCP spec, content is "typically omitted" for decline/cancel actions. + * We normalize null to undefined for leniency while maintaining type compatibility. */ - content: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.string())])).optional() + content: z.preprocess( + (val) => (val === null ? undefined : val), + z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.string())])).optional() + ) }); /* Autocomplete */ From d597cbe5442f9c2c3b537b3bee67fb7f2f2ad988 Mon Sep 17 00:00:00 2001 From: Matt Carey Date: Mon, 1 Dec 2025 16:52:59 +0000 Subject: [PATCH 2/2] linting --- src/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index 86ae6ea12..e34e6255c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1835,7 +1835,7 @@ export const ElicitResultSchema = ResultSchema.extend({ * We normalize null to undefined for leniency while maintaining type compatibility. */ content: z.preprocess( - (val) => (val === null ? undefined : val), + val => (val === null ? undefined : val), z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.string())])).optional() ) });