> ## 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.

# Server: Agents MCP

> Deploy agents as MCP servers using Agent.launch(protocol='mcp')

Publish single or multi-agent systems over MCP with `launch(protocol="mcp")` — the built-in idiom that delegates to `serve_agents(...)` under the hood.

<Note>
  **Same code path as [`serve_agents([...])`](/docs/features/serve-agents).** `launch(protocol="mcp")` calls `serve_agents(...)` for you, so the published tools (`ask_{name}` + `list_agents`), the `/mcp` endpoint, and per-session continuity are **identical**. Pick whichever idiom fits your code — a method on the `Agent`/`Agents` object, or the standalone function.
</Note>

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    L1["agent.launch(protocol='mcp')"] --> Serve["⚙️ serve_agents([agent])"]
    L2["PraisonAIAgents(...).launch(protocol='mcp')"] --> Serve
    F["serve_agents([...])"] --> Serve
    Serve --> Ask["🔧 ask_{name} + list_agents"]
    Ask --> Endpoint["🌐 /mcp (http-stream)"]

    classDef launch fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef process fill:#189AB4,stroke:#7C90A0,color:#fff
    classDef result fill:#10B981,stroke:#7C90A0,color:#fff

    class L1,L2,F launch
    class Serve,Ask process
    class Endpoint result
```

## Quick Start

<Steps>
  <Step title="Install Dependencies">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    pip install praisonai-mcp
    ```

    `praisonai-mcp` is an optional package imported lazily. Without it, `launch(protocol="mcp")` prints: *"MCP serving requires the 'praisonai-mcp' package."*
  </Step>

  <Step title="Set API Key">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    export OPENAI_API_KEY="your-key"
    ```
  </Step>

  <Step title="Create Agent MCP Server">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent

    agent = Agent(
        name="TweetAgent",
        instructions="Create engaging tweets",
        llm="gpt-4o-mini"
    )
    agent.launch(port=8080, protocol="mcp")
    ```
  </Step>

  <Step title="Verify">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    curl http://localhost:8080/mcp
    ```
  </Step>
</Steps>

## Which idiom fits your code?

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph TB
    Q{How is your code shaped?}
    Q -->|You already hold an Agent object| A["agent.launch(protocol='mcp')"]
    Q -->|You already hold a PraisonAIAgents object| M["agents.launch(protocol='mcp')"]
    Q -->|Imperative script, no object yet| S["serve_agents([...])"]
    A --> Same["✅ Same tools · same /mcp · same sessions"]
    M --> Same
    S --> Same

    classDef q fill:#F59E0B,stroke:#7C90A0,color:#fff
    classDef opt fill:#189AB4,stroke:#7C90A0,color:#fff
    classDef ok fill:#10B981,stroke:#7C90A0,color:#fff

    class Q q
    class A,M,S opt
    class Same ok
```

## Single Agent as MCP

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(
    name="TweetAgent",
    instructions="Create engaging tweets",
    llm="gpt-4o-mini"
)
agent.launch(port=8080, protocol="mcp")
# Equivalent to: serve_agents([agent], port=8080)
```

Published tools: `ask_tweetagent` + `list_agents`. The output comes from `praisonai-mcp` and the endpoint is `/mcp`.

## Multi-Agent as MCP

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent
from praisonaiagents.agents import PraisonAIAgents

researcher = Agent(name="Researcher", instructions="Research topics", llm="gpt-4o-mini")
writer = Agent(name="Writer", instructions="Write content", llm="gpt-4o-mini")

agents = PraisonAIAgents(agents=[researcher, writer])
agents.launch(port=8080, protocol="mcp")
# Equivalent to: serve_agents([researcher, writer], port=8080)
```

Each agent gets its own `ask_{name}` tool — here `ask_researcher` and `ask_writer` — plus one shared `list_agents`.

<Note>
  `path` is ignored in MCP mode. `protocol="http"` behaviour is unchanged.
</Note>

## MCP Endpoints

| Endpoint | Method | Description                                  |
| -------- | ------ | -------------------------------------------- |
| `/mcp`   | POST   | JSON-RPC over spec-compliant streamable HTTP |

See [Serve Agents](/docs/features/serve-agents) for the canonical tool schema and session model.

## launch() Parameters

| Parameter  | Type | Default   | Description   |
| ---------- | ---- | --------- | ------------- |
| `port`     | int  | `8000`    | Server port   |
| `host`     | str  | `0.0.0.0` | Server host   |
| `protocol` | str  | `mcp`     | Must be `mcp` |
| `debug`    | bool | `False`   | Debug mode    |

## Connect MCP Client

**Claude Desktop** (`claude_desktop_config.json`):

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "mcpServers": {
    "praisonai-agent": {
      "url": "http://localhost:8080/mcp",
      "transport": "http-stream"
    }
  }
}
```

**Cursor** (`.cursor/mcp.json`):

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "mcpServers": {
    "praisonai-agent": {
      "url": "http://localhost:8080/mcp",
      "transport": "http-stream"
    }
  }
}
```

## Test MCP Tools

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# List tools
curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}'

# Call tool
curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {"name": "ask_tweetagent", "arguments": {"message": "Create a tweet about AI"}},
    "id": 2
  }'
```

## Docker Deployment

**app.py:**

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(instructions="Create tweets", llm="gpt-4o-mini")
agent.launch(port=8080, protocol="mcp")
```

**Dockerfile:**

```dockerfile theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY app.py .
EXPOSE 8080
CMD ["python", "app.py"]
```

**requirements.txt:**

```
praisonaiagents
praisonai-mcp
```

**Build and run:**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
docker build -t agent-mcp-server .
docker run -p 8080:8080 -e OPENAI_API_KEY=$OPENAI_API_KEY agent-mcp-server
```

## Troubleshooting

| Issue                                               | Fix                                  |
| --------------------------------------------------- | ------------------------------------ |
| Port in use                                         | `lsof -i :8080`                      |
| `MCP serving requires the 'praisonai-mcp' package.` | `pip install praisonai-mcp`          |
| No API key                                          | `export OPENAI_API_KEY="your-key"`   |
| Client can't connect                                | Check firewall, use `host="0.0.0.0"` |

## Related

* [Serve Agents](/docs/features/serve-agents) - The `serve_agents([...])` function `launch()` delegates to
* [API Vocabulary](/docs/features/api-vocabulary) - One page for `approval=` and `launch(protocol=...)`
* [Tools MCP](./tools-mcp) - Deploy tools as MCP server
* [Recipes MCP](./recipes-mcp) - Deploy recipes as MCP server
* [PraisonAI MCP](./praisonai-mcp) - Full PraisonAI MCP server
* [Agents HTTP](./agents) - Deploy as HTTP server
