Skip to main content
The best DX path in redop is a Zod schema feeding directly into a typed handler.

Copy-paste example

import { Redop } from "redop";
import { z } from "zod";

new Redop({
  name: "typed-server",
  version: "0.1.0",
})
  .tool("search", {
    description: "Search posts",
    input: z.object({
      query: z.string().min(1),
      limit: z.number().int().min(1).max(50).default(10),
    }),
    handler: ({ input }) => {
      return {
        query: input.query,
        limit: input.limit,
      };
    },
  })
  .listen({
    port: 3000,
    hostname: "0.0.0.0",
  });

Why this feels good

  • input.query is inferred as string
  • input.limit is inferred as number
  • defaults and coercions happen before the handler runs
  • the generated MCP tool schema is derived from the Zod schema

When to use plain JSON Schema instead

Use plain JSON Schema when:
  • you already have schema objects elsewhere
  • you want a minimal dependency path
  • you do not need Zod-specific transforms or the same inference ergonomics

See the full example

For a richer example, see Zod blog example.