What is Zod?

Zod is a TypeScript-first schema validation library where you declare a schema once and get both runtime validation and a static type for free, widely used to define and enforce MCP tool inputs and LLM outputs.

Zod is a popular TypeScript library for defining schemas that validate data at runtime while also inferring a static TypeScript type from the same definition, so you describe a shape once and get both compile-time types and runtime checks without keeping them in sync by hand. You compose schemas from primitives and combinators, then call parse to throw on bad input or safeParse to get a typed result-or-error, which makes it a clean boundary for anything crossing into your program from the outside: HTTP bodies, environment variables, and especially model output. It is heavily used in the MCP and agent ecosystem for two jobs. First, tool definitions: SDKs let you declare a tool's input shape as a Zod schema, which is converted to the JSON Schema the protocol requires and used to validate arguments before the tool runs. Second, taming LLMs: because models return free-form JSON, you validate their responses against a Zod schema and reject or retry on anything off-shape, which is exactly how Glen's pipeline guards every structured LLM call. The pattern, schema as the single source of truth for types, validation, and the MCP contract, is why Zod shows up across so many TypeScript AI projects.