Agent class with MCP to create intelligent agents that use external tools from MCP servers.
Overview
This example creates a chat agent that:- Connects to a remote MCP server over HTTP
- Uses the server’s tools to answer questions
- Maintains conversation history
- Tracks tool usage with step callbacks
The Code
Using Different Models
You can use any provider:Using SSE Transport
For legacy MCP servers using SSE:Persistent Storage
UseSQLiteStorage for persistent conversations:
Next Steps
MCP Integration
Learn more about MCP transports and servers
Stateful Agents
Build agents with persistent state