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

# AgentOS as MCP Server

> Learn how and why to expose your AgentOS as an MCP server

Your AgentOS will by default be exposed as an API. But you can also expose it as an **MCP server**.

This is done by setting `enable_mcp_server=True` when creating your AgentOS instance:

```python theme={null}
agent_os = AgentOS(enable_mcp_server=True)
```

## Why use MCP?

The [MCP protocol](https://modelcontextprotocol.io) has become the industry standard to handle connecting AI applications with external tools and data sources.

By exposing your AgentOS as an MCP server, external clients that can handle MCP-compatible applications will be able to connect to your AgentOS and interact with it.

## Example

```python enable_mcp_example.py theme={null}
from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.models.anthropic import Claude
from agno.os import AgentOS
from agno.tools.hackernews import HackerNewsTools

# Setup the database
db = PostgresDb(db_url="postgresql+psycopg://ai:ai@localhost:5532/ai")

# Create your agents
web_research_agent = Agent(
    name="Web Research Agent",
    model=Claude(id="claude-sonnet-4-0"),
    db=db,
    tools=[HackerNewsTools()],
    markdown=True,
)

# Setup AgentOS with MCP enabled
agent_os = AgentOS(
    description="Example app with MCP enabled",
    agents=[web_research_agent],
    enable_mcp_server=True,  # This enables a LLM-friendly MCP server at /mcp
)

app = agent_os.get_app()

if __name__ == "__main__":
    # Your MCP server will be available at http://localhost:7777/mcp
    agent_os.serve(app="enable_mcp_example:app", reload=True)

```

Once enabled, your AgentOS will expose an MCP server via the `/mcp` endpoint.

You can see a complete example [here](/agent-os/usage/mcp/enable-mcp-example).

## Available MCP Tools

When you expose your AgentOS as an MCP server, the following MCP tools will be available:

### `get_agentos_config`

Get the configuration of the AgentOS

### `run_agent`

Run the desired Agent

* `agent_id` (str): The ID of the agent to run
* `message` (str): The message to send to the agent

### `run_team`

Run the desired Team

* `team_id` (str): The ID of the team to run
* `message` (str): The message to send to the team

### `run_workflow`

Run the desired Workflow

* `workflow_id` (str): The ID of the workflow to run
* `message` (str): The message to send to the workflow

### `get_sessions_for_agent`

Get the list of sessions for the desired Agent

* `agent_id` (str): The ID of the agent to get the sessions for
* `db_id` (str): The ID of the database to use
* `user_id` (Optional\[str]): The ID of the user to get the sessions for
* `sort_by` (Optional\[str]): The field to sort the sessions by. Defaults to `created_at`
* `sort_order` (Optional\[str]): The order to sort the sessions by. Defaults to `desc`

### `get_sessions_for_team`

Get the list of sessions for the desired Team

* `team_id` (str): The ID of the team to get the sessions for
* `db_id` (str): The ID of the database to use
* `user_id` (Optional\[str]): The ID of the user to get the sessions for
* `sort_by` (Optional\[str]): The field to sort the sessions by. Defaults to `created_at`
* `sort_order` (Optional\[str]): The order to sort the sessions by. Defaults to `desc`

### `get_sessions_for_workflow`

Get the list of sessions for the desired Workflow

* `workflow_id` (str): The ID of the workflow to get the sessions for
* `db_id` (str): The ID of the database to use
* `user_id` (Optional\[str]): The ID of the user to get the sessions for
* `sort_by` (Optional\[str]): The field to sort the sessions by. Defaults to `created_at`
* `sort_order` (Optional\[str]): The order to sort the sessions by. Defaults to `desc`

### `create_memory`

Create a new user memory

* `db_id` (str): The ID of the database to use
* `memory` (str): The memory content to store
* `user_id` (str): The user this memory is about
* `topics` (Optional\[list\[str]]): The topics of the memory

### `get_memories_for_user`

Get the list of memories for the given user

* `user_id` (str): The ID of the user to get the memories for
* `db_id` (Optional\[str]): The ID of the database to use
* `sort_by` (Optional\[str]): The field to sort the memories by. Defaults to `created_at`
* `sort_order` (Optional\[str]): The order to sort the memories by. Defaults to `desc`

### `update_memory`

Update the desired memory

* `db_id` (str): The ID of the database to use
* `memory_id` (str): The ID of the memory to update
* `memory` (str): The memory content to store
* `user_id` (str): The ID of the user to update the memory for

### `delete_memory`

Delete the desired memory

* `db_id` (str): The ID of the database to use
* `memory_id` (str): The ID of the memory to delete

See a full example [here](/agent-os/usage/mcp/enable-mcp-example).
