Skip to content

Commit 541a59f

Browse files
olaservoclaude
andcommitted
Add test to explicitly reproduce issue #846 regression
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 <[email protected]>
1 parent 1306a95 commit 541a59f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

client/src/utils/__tests__/paramUtils.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,40 @@ describe("cleanParams", () => {
277277
// fieldWithDefault omitted because value (null) doesn't match default ("defaultValue")
278278
});
279279
});
280+
281+
it("should fix regression from issue #846 - tools with multiple null defaults", () => {
282+
// Reproduces the exact scenario from https://github.com/modelcontextprotocol/inspector/issues/846
283+
// In v0.17.0, the cleanParams function would remove all null values,
284+
// breaking tools that have parameters with explicit default: null
285+
const schema: JsonSchemaType = {
286+
type: "object",
287+
required: ["requiredString"],
288+
properties: {
289+
optionalString: { type: ["string", "null"], default: null },
290+
optionalNumber: { type: ["number", "null"], default: null },
291+
optionalBoolean: { type: ["boolean", "null"], default: null },
292+
requiredString: { type: "string" },
293+
},
294+
};
295+
296+
// When a user opens the tool in Inspector, fields initialize with their defaults
297+
const params = {
298+
optionalString: null, // initialized to default
299+
optionalNumber: null, // initialized to default
300+
optionalBoolean: null, // initialized to default
301+
requiredString: "test",
302+
};
303+
304+
const cleaned = cleanParams(params, schema);
305+
306+
// In v0.16, null defaults were preserved (working behavior)
307+
// In v0.17.0, they were removed (regression)
308+
// This fix restores the v0.16 behavior
309+
expect(cleaned).toEqual({
310+
optionalString: null,
311+
optionalNumber: null,
312+
optionalBoolean: null,
313+
requiredString: "test",
314+
});
315+
});
280316
});

0 commit comments

Comments
 (0)