Skip to main content

Build your first Agent

Let’s build an Agent that connects to an MCP server, persists conversation state, and is served via FastAPI. Save the following code as agno_agent.py:
agno_agent.py
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.anthropic import Claude
from agno.os import AgentOS
from agno.tools.mcp import MCPTools

agno_agent = Agent(
    name="Agno Agent",
    model=Claude(id="claude-sonnet-4-5"),
    db=SqliteDb(db_file="agno.db"),
    tools=[MCPTools(url="https://docs.agno.com/mcp")],
    add_history_to_context=True,
    markdown=True,
)

agent_os = AgentOS(agents=[agno_agent])
app = agent_os.get_app()
In ~20 lines: an Agent with memory, state, and MCP tools, served via FastAPI with pre-built endpoints.

Run your AgentOS

1

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate
2

Install dependencies

uv pip install -U agno anthropic mcp 'fastapi[standard]' sqlalchemy
3

Export your Anthropic API key

export ANTHROPIC_API_KEY=sk-***
4

Run your AgentOS

fastapi dev agno_agent.py
This starts your AgentOS at http://localhost:8000.

Connect to the AgentOS UI

The AgentOS UI connects directly to your runtime, letting you monitor, manage, and test your system.
  1. Open os.agno.com and sign in.
  2. Click “Add new OS” in the top navigation.
  3. Select “Local” to connect to a local AgentOS.
  4. Enter your endpoint URL (default: http://localhost:8000).
  5. Name it something like “Development OS”.
  6. Click “Connect”.
Once connected, you’ll see your OS with a live status indicator.

Chat with your Agent

Go to Chat in the sidebar and select your Agent.
  • Ask “What is Agno?” and the Agent will answer using the Agno MCP server.
  • Each Agent maintains its own history, tools, and instructions. Switching users won’t mix context.
Click Sessions in the sidebar to view your Agent’s conversations. Data is stored in your Agent’s database. No third-party tracing required.

Pre-built API endpoints

The FastAPI app includes SSE-compatible endpoints you can build on. Add your own routes, middleware, or any FastAPI feature. View the API docs at http://localhost:8000/docs.

Next Steps