Description
Is your feature request related to a problem? Please describe.
👋 I'm hoping to be able to use a z.intersection
or z.union
type as the main input schema for an MCP tool being registered using this SDK. Currently, the paramsSchema
is typed as Args extends ZodRawShape
. And ZodRawShape
is essentially a Record<string, ZodTypeAny>
.
Describe the solution you'd like
Is there anything blocking us from using ZodType
(aka ZodSchema
) for the params instead so we can more flexibly model a fixed set of params vs. things like polymorphic params/union types?
Describe alternatives you've considered
Currently, the only workaround is to make sure the tool is defined with all params being optional and then internally massaging or validating them in the MCP server to a more structured format.
Additional context
On the surface, it looks like this should work with a few tweaks in server/mcp.ts
, since the zod-to-json-schema
dependency accepts a full ZodSchema
: https://www.npmjs.com/package/zod-to-json-schema?activeTab=code. Happy to propose a PR for this myself but just wanted to get more folks' take on it first!