MCPcopy Create free account
hub / github.com/cloudflare/mcp / zodInputSchemaFromJson

Function zodInputSchemaFromJson

src/openapi.ts:211–221  ·  view source on GitHub ↗
(
  inputSchema: JsonObjectSchema
)

Source from the content-addressed store, hash-verified

209
210/** Rehydrate the small Zod shape required by the SDK's tools/call validation. */
211export function zodInputSchemaFromJson(
212 inputSchema: JsonObjectSchema
213): Record<string, z.ZodTypeAny> {
214 const required = new Set(inputSchema.required ?? [])
215 return Object.fromEntries(
216 Object.entries(inputSchema.properties).map(([name, property]) => {
217 const schema = z.string().describe(property.description)
218 return [name, required.has(name) ? schema : schema.optional()]
219 })
220 )
221}
222
223function buildJsonInputSchema(operation: OperationInfo, path: string): JsonObjectSchema {
224 const properties: JsonObjectSchema['properties'] = {}

Callers 1

registerNonCodemodeToolsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected