Free course · 13 lessons · Advanced
AI Agents and MCP in Production
Build agents that stay bounded, recover from tool failures and can be debugged: the agent loop and its budgets, tool definitions the model can't misuse, context management for long tasks, the Model Context Protocol (servers, clients, transports and security), human approval for risky actions, multi-agent orchestration, tracing, and cost and latency budgets. Every lesson starts from a real production failure and has a runnable Python simulation.
1. Agent Loops That Behave
The loop at the heart of every agent: when it stops, how tools are described, what happens when they fail, and how context grows.
- The Agent Loop and the Runaway Bill — Why one support conversation made 180 model calls, and how step budgets and repeat detection keep agents bounded.
- Tool Definitions the Model Can't Misuse — Ambiguous parameters and overlapping tools cause silent mistakes; precise schemas, enums and strict validation prevent them.
- When Tools Fail: Errors the Agent Can Recover From — An exception kills the conversation, a swallowed error invites a made-up answer; structured tool errors and in-tool retries fix both.
- Context Growth in Long-Running Agents — Every step resends the whole history; large tool outputs make cost grow quadratically until the context window overflows.
2. The Model Context Protocol (MCP)
Connect agents to tools and data through one protocol: how MCP works, how to design servers agents use well, how to secure them, and how to run them remotely.
- MCP: One Protocol Instead of N×M Integrations — Why every AI app re-implemented the same integrations, and how MCP's servers, clients and transports replace them.
- Designing MCP Servers Agents Use Well — A server that returns whole tables floods the context; filtered, paginated, concise tools with annotations work far better.
- MCP Security: Untrusted Servers, Tool Poisoning and Tokens — Tool descriptions are instructions to your model; untrusted servers and passed-through tokens turn that into an attack path.
- Remote MCP Servers in Production — Sessions held in one instance's memory break behind a load balancer; stateless servers, proper auth and limits fix remote MCP.
3. Running Agents in Production
Keep humans in control of risky actions, decide when several agents beat one, trace what agents do, and control cost and latency.
- Human Approval for Risky Actions — An agent that can delete or pay will eventually do it at the wrong time; risk levels, approval gates and dry runs keep it safe.
- Multi-Agent Systems: Orchestrator and Workers — Agents chatting freely duplicate work and loop; an orchestrator with clear subtasks and a shared budget gets the benefit without the chaos.
- Tracing Agents: Answering "Why Did It Do That?" — Without per-step traces you cannot explain a bad answer or a big bill; spans for model calls and tools make agents debuggable.
- Cost and Latency Budgets for Agents — Sequential tool calls and one big model for everything make agents slow and expensive; parallel calls, routing and caching fix both.
4. Capstone
Design a production agent end to end.
- Capstone: An On-Call Assistant with MCP Tools — Design an agent that helps on-call engineers investigate incidents safely, using MCP servers for logs, metrics and deployments.