Skip to content

Commit 8119632

Browse files
Adam Bloomstonclaude
andcommitted
style: apply prettier formatting
Applied prettier auto-formatting to README.md and src/server/mcp.ts to fix code style issues. Changes linted and tested. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 4955cc5 commit 8119632

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,21 +1116,30 @@ Control how tools handle parameter validation errors and unexpected inputs:
11161116

11171117
```typescript
11181118
// Strict validation - catches typos and unexpected parameters immediately
1119-
const devTool = server.registerTool("dev-tool", {
1120-
inputSchema: { userName: z.string(), itemCount: z.number() },
1121-
strictInputSchemaValidation: true // Reject { username: "test", itemcount: 42 }
1122-
}, handler);
1119+
const devTool = server.registerTool(
1120+
'dev-tool',
1121+
{
1122+
inputSchema: { userName: z.string(), itemCount: z.number() },
1123+
strictInputSchemaValidation: true // Reject { username: "test", itemcount: 42 }
1124+
},
1125+
handler
1126+
);
11231127

11241128
// Lenient validation (default) - maintains backwards compatibility with existing clients
1125-
const prodTool = server.registerTool("prod-tool", {
1126-
inputSchema: { userName: z.string().optional(), itemCount: z.number().optional() },
1127-
strictInputSchemaValidation: false // Accept extra parameters for backwards compatibility with clients that may send additional fields
1128-
}, handler);
1129+
const prodTool = server.registerTool(
1130+
'prod-tool',
1131+
{
1132+
inputSchema: { userName: z.string().optional(), itemCount: z.number().optional() },
1133+
strictInputSchemaValidation: false // Accept extra parameters for backwards compatibility with clients that may send additional fields
1134+
},
1135+
handler
1136+
);
11291137
```
11301138

11311139
**When to use strict validation:**
1140+
11321141
- Development and testing: Catch parameter name typos early
1133-
- Production APIs: Ensure clients send only expected parameters
1142+
- Production APIs: Ensure clients send only expected parameters
11341143
- Security-sensitive tools: Prevent injection of unexpected data
11351144

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

src/server/mcp.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,12 @@ export class McpServer {
654654
const registeredTool: RegisteredTool = {
655655
title,
656656
description,
657-
inputSchema: inputSchema === undefined ? undefined : strictInputSchemaValidation === true ? z.object(inputSchema).strict() : z.object(inputSchema),
657+
inputSchema:
658+
inputSchema === undefined
659+
? undefined
660+
: strictInputSchemaValidation === true
661+
? z.object(inputSchema).strict()
662+
: z.object(inputSchema),
658663
outputSchema: outputSchema === undefined ? undefined : z.object(outputSchema),
659664
annotations,
660665
_meta,

0 commit comments

Comments
 (0)