From 541a59f1fec0ce51aa93955d947e943a51243db6 Mon Sep 17 00:00:00 2001 From: olaservo Date: Sat, 18 Oct 2025 21:20:33 -0700 Subject: [PATCH] Add test to explicitly reproduce issue #846 regression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test verifies that tools with multiple nullable parameters (default: null) work correctly. In v0.17.0, cleanParams would incorrectly remove these null values, breaking tool execution. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- client/src/utils/__tests__/paramUtils.test.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/client/src/utils/__tests__/paramUtils.test.ts b/client/src/utils/__tests__/paramUtils.test.ts index 6c853490..1077d76b 100644 --- a/client/src/utils/__tests__/paramUtils.test.ts +++ b/client/src/utils/__tests__/paramUtils.test.ts @@ -277,4 +277,40 @@ describe("cleanParams", () => { // fieldWithDefault omitted because value (null) doesn't match default ("defaultValue") }); }); + + it("should fix regression from issue #846 - tools with multiple null defaults", () => { + // Reproduces the exact scenario from https://github.com/modelcontextprotocol/inspector/issues/846 + // In v0.17.0, the cleanParams function would remove all null values, + // breaking tools that have parameters with explicit default: null + const schema: JsonSchemaType = { + type: "object", + required: ["requiredString"], + properties: { + optionalString: { type: ["string", "null"], default: null }, + optionalNumber: { type: ["number", "null"], default: null }, + optionalBoolean: { type: ["boolean", "null"], default: null }, + requiredString: { type: "string" }, + }, + }; + + // When a user opens the tool in Inspector, fields initialize with their defaults + const params = { + optionalString: null, // initialized to default + optionalNumber: null, // initialized to default + optionalBoolean: null, // initialized to default + requiredString: "test", + }; + + const cleaned = cleanParams(params, schema); + + // In v0.16, null defaults were preserved (working behavior) + // In v0.17.0, they were removed (regression) + // This fix restores the v0.16 behavior + expect(cleaned).toEqual({ + optionalString: null, + optionalNumber: null, + optionalBoolean: null, + requiredString: "test", + }); + }); });