Description
Is your feature request related to a problem? Please describe.
This SDK seems quite coupled to zod. The creator of zod as well as the creators of other popular virtual TS type libs partnered to define the Standard Schema Spec. Given that a lot of these virtual type libs enable JSON schema generation, I see no reason for this SDK to be coupled to zod directly.
Describe the solution you'd like
Let's consider the tool
method signature:
tool<Args extends ZodRawShape>(name: string, description: string, paramsSchema: Args, cb: ToolCallback<Args>): void;
This could instead be declared as the following:
tool<Args extends object>(name: string, description: string, paramsSchema: StandardSchemaV1 <Args>, cb: ToolCallback<Args>): void;
^ This isn't exactly what it would need to be, as different virtual type libraries are converted to JSON in different ways... but it's the gist. The real implementation would likely involve a wrapper function and type, similar to Hono's standard validator. Ie. users would wrap their virtual type with an adapter that simply calls whatever JSON-producing method of the virtual type (in this case, an arktype.
import { type } from "arktype"
import { schema } from "arktype-mcp"
// ^ hypothetical lib
const MyType = type({
a: "string | number",
"b?": {
c: "'d'"
},
e: ["'f'", "'g'"]
})
tool(NAME, DESC, schema(MyType), (v) => {
v satisfies {
a: string | number;
b: {
c: "d";
};
e: ["f", "g"];
}
})
Describe alternatives you've considered
Virtual type libraries are a critical utility for ensuring a single source of truth. But Zod is not necessarily the best choice depending on use case / preferences. I personally prefer arktype, which is more versatile for modeling nested types, custom scopes and type-safe cycles.
Additional context
- https://arktype.io
- https://valibot.dev
- https://effect.website/docs/schema/introduction/
- https://github.com/modiimedia/arri
- https://github.com/sinclairzx81/typemap
- https://github.com/GauBen/formgator
- https://github.com/nvie/decoders
- https://github.com/DZakh/rescript-schema
- https://github.com/skunkteam/types
^ All of these implement standard schema and can have their static types extracted via T["~standard"]
, where T
is any virtual type.