Skip to content

Commit 991639a

Browse files
Adam Bloomstonclaude
andcommitted
refactor: rename strict to strictInputSchemaValidation
Renamed parameter from `strict` to `strictInputSchemaValidation` for clarity. The longer name makes it more explicit that this validation applies specifically to the input schema and helps distinguish it from other types of strictness. Updated: - src/server/mcp.ts: Parameter in registerTool config and _createRegisteredTool signature - src/server/mcp.test.ts: Test using the renamed parameter - README.md: Documentation examples and notes Changes linted and tested. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 8a232b5 commit 991639a

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,13 +1118,13 @@ Control how tools handle parameter validation errors and unexpected inputs:
11181118
// Strict validation - catches typos and unexpected parameters immediately
11191119
const devTool = server.registerTool("dev-tool", {
11201120
inputSchema: { userName: z.string(), itemCount: z.number() },
1121-
strict: true // Reject { username: "test", itemcount: 42 }
1121+
strictInputSchemaValidation: true // Reject { username: "test", itemcount: 42 }
11221122
}, handler);
11231123

11241124
// Lenient validation (default) - maintains backwards compatibility with existing clients
11251125
const prodTool = server.registerTool("prod-tool", {
11261126
inputSchema: { userName: z.string().optional(), itemCount: z.number().optional() },
1127-
strict: false // Accept extra parameters for backwards compatibility with clients that may send additional fields
1127+
strictInputSchemaValidation: false // Accept extra parameters for backwards compatibility with clients that may send additional fields
11281128
}, handler);
11291129
```
11301130

@@ -1133,7 +1133,7 @@ const prodTool = server.registerTool("prod-tool", {
11331133
- Production APIs: Ensure clients send only expected parameters
11341134
- Security-sensitive tools: Prevent injection of unexpected data
11351135

1136-
**Note:** The `strict` parameter is only available in `registerTool()`. The legacy `tool()` method uses lenient validation for backward compatibility.
1136+
**Note:** The `strictInputSchemaValidation` parameter is only available in `registerTool()`. The legacy `tool()` method uses lenient validation for backward compatibility.
11371137

11381138
### Low-Level Server
11391139

src/server/mcp.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4141,7 +4141,7 @@ describe('elicitInput()', () => {
41414141
'test-strict',
41424142
{
41434143
inputSchema: { userName: z.string().optional(), itemCount: z.number().optional() },
4144-
strict: true
4144+
strictInputSchemaValidation: true
41454145
},
41464146
async ({ userName, itemCount }) => ({
41474147
content: [{ type: 'text', text: `${userName || 'none'}: ${itemCount || 0}` }]

src/server/mcp.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -647,14 +647,14 @@ export class McpServer {
647647
inputSchema: ZodRawShape | undefined,
648648
outputSchema: ZodRawShape | undefined,
649649
annotations: ToolAnnotations | undefined,
650-
strict: boolean | undefined,
650+
strictInputSchemaValidation: boolean | undefined,
651651
_meta: Record<string, unknown> | undefined,
652652
callback: ToolCallback<ZodRawShape | undefined>
653653
): RegisteredTool {
654654
const registeredTool: RegisteredTool = {
655655
title,
656656
description,
657-
inputSchema: inputSchema === undefined ? undefined : strict === true ? z.object(inputSchema).strict() : z.object(inputSchema),
657+
inputSchema: inputSchema === undefined ? undefined : strictInputSchemaValidation === true ? z.object(inputSchema).strict() : z.object(inputSchema),
658658
outputSchema: outputSchema === undefined ? undefined : z.object(outputSchema),
659659
annotations,
660660
_meta,
@@ -795,7 +795,7 @@ export class McpServer {
795795
inputSchema?: InputArgs;
796796
outputSchema?: OutputArgs;
797797
annotations?: ToolAnnotations;
798-
strict?: boolean;
798+
strictInputSchemaValidation?: boolean;
799799
_meta?: Record<string, unknown>;
800800
},
801801
cb: ToolCallback<InputArgs>
@@ -804,7 +804,7 @@ export class McpServer {
804804
throw new Error(`Tool ${name} is already registered`);
805805
}
806806

807-
const { title, description, inputSchema, outputSchema, annotations, strict, _meta } = config;
807+
const { title, description, inputSchema, outputSchema, annotations, strictInputSchemaValidation, _meta } = config;
808808

809809
return this._createRegisteredTool(
810810
name,
@@ -813,7 +813,7 @@ export class McpServer {
813813
inputSchema,
814814
outputSchema,
815815
annotations,
816-
strict,
816+
strictInputSchemaValidation,
817817
_meta,
818818
cb as ToolCallback<ZodRawShape | undefined>
819819
);

0 commit comments

Comments
 (0)