Skip to content

Commit cc7b5ae

Browse files
Will-hxwclaude
andcommitted
fix(everything): fix TypeScript type error in get-env tool inputSchema
Use Zod schema for type-safe input validation instead of inline object with incorrect 'required' field type. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent f2d1095 commit cc7b5ae

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

src/everything/tools/get-env.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1+
import { z } from "zod";
12
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
23
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
34

5+
// Tool input schema
6+
const GetEnvSchema = z.object({
7+
key: z.string().describe(
8+
"The name of the environment variable to retrieve (e.g., 'PATH', 'HOME', 'USER')",
9+
),
10+
});
11+
412
// Tool configuration
513
const name = "get-env";
614
const config = {
715
title: "Print Environment Tool",
816
description:
917
"Returns the value of a specific environment variable, helpful for debugging MCP server configuration",
10-
inputSchema: {
11-
type: "object",
12-
properties: {
13-
key: {
14-
type: "string",
15-
description:
16-
"The name of the environment variable to retrieve (e.g., 'PATH', 'HOME', 'USER')",
17-
},
18-
},
19-
required: ["key"],
20-
},
18+
inputSchema: GetEnvSchema,
2119
};
2220

2321
/**
@@ -31,7 +29,7 @@ const config = {
3129
*/
3230
export const registerGetEnvTool = (server: McpServer) => {
3331
server.registerTool(name, config, async (args): Promise<CallToolResult> => {
34-
const { key } = args as { key: string };
32+
const { key } = GetEnvSchema.parse(args);
3533
const value = process.env[key];
3634

3735
if (value === undefined) {

0 commit comments

Comments
 (0)