Description
Background
FastMCP currently uses Zod directly for schema validation. However, the Standard Schema specification has been developed as a common interface for JavaScript/TypeScript schema libraries. The creators of Zod (along with Valibot and ArkType) designed this specification to make it easier for ecosystem tools to accept user-defined type validators without needing custom adapters for each library.
Request
Please consider replacing direct Zod usage with Standard Schema in FastMCP. This would allow users to:
- Choose their preferred validation library (Zod, Valibot, ArkType, etc.)
- Benefit from the "integrate once, validate anywhere" philosophy of Standard Schema
- Follow best practices recommended by schema library authors
Rationale
From the Standard Schema documentation:
"The spec was designed by the creators of Zod, Valibot, and ArkType. Recent versions of these libraries already implement the spec."
Many ecosystem tools are already adopting Standard Schema, including tRPC, TanStack Form, TanStack Router, and others. This change would align FastMCP with this emerging ecosystem standard.
Implementation Notes
The change should be fairly straightforward since:
- Zod already implements the Standard Schema interface (in v3.24.0+)
- The Standard Schema interface is designed to be minimal and easy to integrate
Example
Current implementation:
server.addTool({
name: "add",
parameters: z.object({
a: z.number(),
b: z.number(),
}),
// ...
});
Potential Standard Schema implementation:
server.addTool({
name: "add",
parameters: anyStandardSchema, // Could be Zod, Valibot, ArkType, etc.
// ...
});
Thank you for considering this request!