Skip to content

Commit 13f5463

Browse files
committed
migrate to zod 3.x
1 parent 77be672 commit 13f5463

5 files changed

Lines changed: 22 additions & 86 deletions

File tree

package-lock.json

Lines changed: 14 additions & 78 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"tar": "^7.4.3",
4646
"turndown": "7.2.0",
4747
"unified": "11.0.5",
48-
"zod": "4.1.12"
48+
"zod": "3.25.20",
49+
"zod-to-json-schema": "3.24.6"
4950
},
5051
"optionalDependencies": {
5152
"@rollup/rollup-linux-x64-gnu": "^4.43.0"

src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import {
66
SetLevelRequestSchema,
77
} from '@modelcontextprotocol/sdk/types.js';
88
import { Tool } from './tools/types';
9-
import z from 'zod';
109
import { logger } from './utils/logger';
1110
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
1211
import { Context } from './utils/context';
1312
import { searchTool } from './tools/search';
1413
import { logsTool } from './tools/logs';
1514
import { sendEvent } from './utils/telemetry';
15+
import { zodToJsonSchema } from 'zod-to-json-schema';
1616

1717
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1818
const tools: Tool<any>[] = [searchTool, logsTool];
@@ -41,7 +41,7 @@ export const createServer = (): Server => {
4141
return {
4242
tools: tools.map(({ handler: _handler, inputSchema, ...rest }) => ({
4343
...rest,
44-
inputSchema: z.toJSONSchema(inputSchema),
44+
inputSchema: zodToJsonSchema(inputSchema),
4545
})),
4646
};
4747
});

src/tools/search.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ For redis docs, use redis.{my_command}
1313
Examples:
1414
- {query: "how do hooks work"}
1515
- {query: "redis.bitfield"}
16-
- {query: "useState"}
17-
- {query: "working with useState", limit: 10}
18-
- {query: "scheduler"}`,
16+
- {query: "navigate to external urls"}
17+
- {query: "how does devvit.json work"}`,
1918
inputSchema: z.object({
2019
query: z.string().describe('Search query'),
2120
limit: z.number().optional().default(2).describe('Maximum number of results'),

src/tools/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ export type ToolResult = {
88
isError?: boolean;
99
};
1010

11-
export type Tool<T extends z.ZodObject = z.ZodObject> = {
11+
export type Tool<T extends z.AnyZodObject = z.AnyZodObject> = {
1212
name: string;
1313
description: string;
1414
inputSchema: T;
1515
handler: (args: { params: z.infer<T>; context: Context }) => Promise<ToolResult>;
1616
};
1717

1818
// Needed for automatic type inference
19-
export const createTool = <T extends z.ZodObject>(args: {
19+
export const createTool = <T extends z.AnyZodObject>(args: {
2020
name: string;
2121
description: string;
2222
inputSchema: T;

0 commit comments

Comments
 (0)