> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AgentOS with MCPTools

> AgentOS whose agent connects to an external MCP server through MCPTools.

## Code

```python mcp_tools_example.py theme={null}
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

# Setup the database
db = SqliteDb(db_file="tmp/agentos.db")

mcp_tools = MCPTools(transport="streamable-http", url="https://docs.agno.com/mcp")

# Setup basic agent
agno_support_agent = Agent(
    id="agno-support-agent",
    name="Agno Support Agent",
    model=Claude(id="claude-sonnet-4-5"),
    db=db,
    tools=[mcp_tools],
    add_history_to_context=True,
    num_history_runs=3,
    markdown=True,
)


agent_os = AgentOS(
    description="Example app with MCP Tools",
    agents=[agno_support_agent],
)


app = agent_os.get_app()

if __name__ == "__main__":
    # Don't use reload=True here; it can break the MCP connection during the FastAPI lifespan
    agent_os.serve(app="mcp_tools_example:app")
```

AgentOS connects and disconnects `MCPTools` for you.

## Usage

<Snippet file="create-venv-step.mdx" />

**1. Set Environment Variables**

```bash theme={null}
export ANTHROPIC_API_KEY=your_anthropic_api_key
```

**2. Install dependencies**

```bash theme={null}
uv pip install -U "agno[os,mcp]" anthropic
```

**3. Run Server**

Save the code above as `mcp_tools_example.py`, then run:

```bash theme={null}
python mcp_tools_example.py
```

**4. Test**

Open [http://localhost:7777/docs](http://localhost:7777/docs) and run the agent from the API docs, or connect the instance to the [AgentOS UI](https://agno-v2.mintlify.site/agent-os/connect-your-os.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.