The MCPAgent supports structured output, allowing you to get strongly-typed Pydantic models instead of plain text responses. The agent becomes schema-aware and will intelligently retry to gather missing information until all required fields can be populated.Documentation Index
Fetch the complete documentation index at: https://docs.mcp-use.com/llms.txt
Use this file to discover all available pages before exploring further.
How it Works
When you provide anoutput_schema parameter, the agent:
- Understands requirements - The agent knows exactly what information it needs to collect
- Attempts structured output - At completion points, tries to format the result into your schema
- Intelligently retries - If required fields are missing, continues execution to gather the missing data
- Validates completeness - Only finishes when all required fields can be populated
Basic Example
Key Benefits
- Type Safety: Get Pydantic (Python) or Zod (TypeScript) models with full IDE support and validation
- Intelligent Gathering: Agent knows what information is required and won’t stop until it has everything
- Automatic Retry: Missing fields trigger continued execution automatically
- Field Validation: Built-in validation for required fields, data types, and constraints