> ## Documentation Index
> Fetch the complete documentation index at: https://redop.useagents.site/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Add Typed Input with Zod

> Add a Zod schema to a Redop tool so handler input is validated and inferred.

This tutorial assumes you already have a working Redop server.

## What you will add

* runtime validation for tool input
* TypeScript inference inside the handler
* defaults and constraints in one schema

## Step 1: Install Zod

```sh theme={null}
bun add zod
```

## Step 2: Add a schema

```ts theme={null}
import { Redop } from "@redopjs/redop";
import { z } from "zod";

new Redop({ serverInfo: { name: "typed-server" } })
  .tool("search_posts", {
    description: "Search posts by query",
    inputSchema: z.object({
      query: z.string().min(1),
      limit: z.number().int().min(1).max(20).default(10),
    }),
    handler: ({ input }) => {
      return {
        query: input.query,
        limit: input.limit,
      };
    },
  });
```

## What changed

* `input.query` is now typed as `string`
* `input.limit` is now typed as `number`
* Redop uses the same schema for runtime parsing and tool discovery

## Milestone

If your client can still connect and call the tool, you now have the core Redop flow working: transport, schema parsing, and typed handler input.

## Next

* [Add middleware and hooks](/docs/tutorials/add-middleware-hooks)
