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

# Add MCP Server • AI Agent SDK

> add_mcp_server: Attach an MCP server to a live agent at runtime.

# add\_mcp\_server

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**Agent**](../classes/Agent) class in the [**agent**](../modules/agent) module.

Attach an MCP server to a live agent at runtime.

Connects the MCP server (discovering its tools), tracks it by name, and
appends it to `self.tools` so its tools become available on the next
turn of the same run — no agent rebuild required. New MCP tools flow
through the existing tool-execution and approval paths automatically.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def add_mcp_server(name: str, mcp: Any) -> Any
```

## Parameters

<ParamField query="name" type="str" required={true}>
  Unique name for this MCP server (used by `remove_mcp_server`).
</ParamField>

<ParamField query="mcp" type="Any" required={true}>
  An `MCP` instance (e.g. `MCP("npx -y @notionhq/notion-mcp-server")`).
</ParamField>

### Returns

<ResponseField name="Returns" type="Any">
  The attached `MCP` instance.
</ResponseField>

## Usage

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents.mcp import MCP
    agent.add_mcp_server("notion", MCP("npx -y @notionhq/notion-mcp-server"))
    # tools live on the next turn
```

## Uses

* `ValueError`
* `refresh_tools`
* `logging.debug`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/agent.py#L4865">
  `praisonaiagents/agent/agent.py` at line 4865
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="MCP Concept" icon="server" href="/docs/docs/concepts/mcp" />

  <Card title="MCP Lifecycle" icon="rotate" href="/docs/docs/features/mcp-lifecycle" />
</CardGroup>
