Skip to content

Commit 247a7d0

Browse files
authored
fix zod version incompatibility (#52)
1 parent 7f6ccb5 commit 247a7d0

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

packages/opencontrol/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
"@tsconfig/bun": "1.0.7",
2727
"ai": "4.2.11",
2828
"hono": "4.11.4",
29-
"zod": "4.2.1",
30-
"zod-to-json-schema": "3.25.0"
29+
"zod": "4.2.1"
3130
},
3231
"devDependencies": {
33-
"@standard-schema/spec": "1.0.0",
32+
"@standard-schema/spec": "1.1.0",
3433
"opencontrol-frontend": "workspace:*"
3534
}
3635
}

packages/opencontrol/src/mcp.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
} from "@modelcontextprotocol/sdk/types.js"
1111
import { z } from "zod"
1212
import { Tool } from "./tool.js"
13-
import { zodToJsonSchema } from "zod-to-json-schema"
1413

1514
const RequestSchema = z.union([
1615
InitializeRequestSchema,
@@ -41,10 +40,11 @@ export function createMcp(input: { tools: Tool[] }) {
4140
return {
4241
tools: input.tools.map((tool) => ({
4342
name: tool.name,
44-
inputSchema: zodToJsonSchema(
45-
tool.args || (z.object({}) as any),
46-
"args",
47-
).definitions!["args"] as any,
43+
inputSchema: (tool.args
44+
? tool.args["~standard"].jsonSchema.input({
45+
target: "draft-2020-12",
46+
})
47+
: { type: "object" }) as { type: "object" },
4848
description: tool.description,
4949
})),
5050
} satisfies ListToolsResult

packages/opencontrol/src/tool.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
import { StandardSchemaV1 } from "@standard-schema/spec"
1+
import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec"
22
import { z } from "zod"
33

4-
export interface Tool<
5-
Args extends undefined | StandardSchemaV1 = undefined | StandardSchemaV1,
6-
> {
4+
type Schema = StandardSchemaV1 & StandardJSONSchemaV1
5+
6+
export interface Tool<Args extends undefined | Schema = undefined | Schema> {
77
name: string
88
description: string
99
args?: Args
10-
run: Args extends StandardSchemaV1
10+
run: Args extends Schema
1111
? (args: StandardSchemaV1.InferOutput<Args>) => Promise<any>
1212
: () => Promise<any>
1313
}
1414

15-
export function tool<Args extends undefined | StandardSchemaV1>(
16-
input: Tool<Args>,
17-
) {
15+
export function tool<Args extends undefined | Schema>(input: Tool<Args>) {
1816
return input
1917
}
2018

0 commit comments

Comments
 (0)