Skip to main content
Schemas are the contract between your tools and the AI agents that call them. They specify what inputs are required, what types they are, and provide examples that help agents understand what values to send.

Input Schema (JSON Schema)

WebMCP uses JSON Schema for input validation:

Common JSON Schema Types

Built-in formats:
  • email - Email address
  • uri - URI/URL
  • date - ISO 8601 date
  • date-time - ISO 8601 date-time
  • uuid - UUID string

Zod Schema (React)

When using React and TypeScript, Zod provides type-safe schema validation:

Zod Schema Patterns

Schema Best Practices

Descriptions help AI agents understand how to use your tools:
Use schema validation instead of manual checks:
Apply relevant constraints to prevent invalid inputs:
Use default values for optional parameters:
Don’t make schemas overly complex. Split into multiple tools if needed:

Validation Error Handling

When validation fails, the error is caught before your handler executes:
The AI agent receives a clear error message indicating what validation failed.

Tool Registration

Learn how to register tools with schemas

Tool Design

Best practices for designing tools

React WebMCP

Using Zod schemas with React

JSON Schema Spec

Official JSON Schema documentation