Simple Example: Daily Weather Report
Let’s create an agent that fetches weather data and sends a report.Add MCP Server
Add the HTTP Client MCP server so the agent can call weather APIs:
- Server Type: HTTP Client
- URL: (automatically configured)
Add Callback (Optional)
If you want to receive the report via webhook:
- Callback URL:
https://your-domain.com/weather-reports - Headers: Any authentication needed
What Happens
When you run the agent loop:- Agent Reads Instructions: Processes system prompt and user message
- Plans Approach: Decides to use HTTP tool to call weather API
- Calls Tool: Makes HTTP request to weather service
- Processes Response: Extracts temperature, conditions, forecast
- Generates Report: Creates formatted summary
- Sends Callback: Delivers report to your webhook (if configured)
- Completes: Marks execution as successful
Example Output
The agent might produce:More Complex Example: Database Report
Create an agent that queries a database and generates a report.Agent Loop Patterns
Pattern 1: Data Fetcher
Purpose: Retrieve data from external sources Components:- HTTP MCP server
- Clear data source instructions
- Output formatting guidelines
Pattern 2: Data Processor
Purpose: Transform or analyze data Components:- File system MCP server
- Processing instructions
- Output format specification
Pattern 3: Report Generator
Purpose: Create scheduled reports Components:- Data source access (HTTP/Database)
- Report template in system prompt
- Callback for delivery
Pattern 4: Monitoring Agent
Purpose: Check systems and alert on issues Components:- HTTP MCP for API checks
- Conditional logic in prompt
- Callback for alerts
Iterative Development
Agents use multiple reasoning steps:- Simple: 5 iterations
- Medium: 10 iterations
- Complex: 20+ iterations
Testing Your Agent
Common Mistakes
Vague Instructions
Bad:Too Many Tools
Problem: Providing unnecessary MCP servers confuses the agent. Solution: Only include tools needed for the specific task.Insufficient Iterations
Problem: Agent runs out of iterations before completing. Solution: Increase max iterations or simplify the task.No Error Handling
Problem: Agent fails when API returns an error. Solution: Include error handling instructions in system prompt:Best Practices
Explicit Steps
Break tasks into numbered steps in system prompt
Expected Output
Describe exactly what format you want
Error Handling
Tell the agent how to handle failures
Test Thoroughly
Run multiple times with different scenarios
Next Steps
MCP Servers
Learn about available tools
Callbacks
Set up result webhooks
API Reference
Trigger agents programmatically