Create a callable operation from a definition. The returned function validates input against the Zod schema before delegating to the implementation.
The operation definition with name, schemas, and implementation.
A callable function with .def, .inputSchema, and .outputSchema attached.
.def
.inputSchema
.outputSchema
If the input fails Zod validation.
const myOp = defineOperation({ name: "greet", description: "Say hello", input: z.object({ name: z.string() }), output: z.string(), fn: ({ name }) => `Hello, ${name}!`,});myOp({ name: "world" }); // => "Hello, world!" Copy
const myOp = defineOperation({ name: "greet", description: "Say hello", input: z.object({ name: z.string() }), output: z.string(), fn: ({ name }) => `Hello, ${name}!`,});myOp({ name: "world" }); // => "Hello, world!"
Create a callable operation from a definition. The returned function validates input against the Zod schema before delegating to the implementation.