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

# MCP Lifecycle CLI

> CLI commands for MCP server lifecycle and agent integration

Commands for running PraisonAI's MCP server, inspecting built-in tools, and attaching external MCP servers to agent runs.

## Quick Start

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Start the built-in MCP server (stdio)
praisonai mcp serve

# List built-in MCP tools
praisonai mcp list-tools

# Run an agent with an external MCP server
praisonai "What time is it?" --mcp "uvx mcp-server-time"
```

## MCP server commands

### Serve

Start the PraisonAI MCP server:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai mcp serve --transport stdio
praisonai mcp serve --transport http-stream --host 127.0.0.1 --port 8080
```

Common flags: `--name`, `--debug`, `--response-mode batch|stream`, `--session-ttl`, `--log-level`, `--json`.

### Inspect built-in tools

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# List all tools
praisonai mcp list-tools

# Search tools
praisonai mcp tools search "web"

# Tool details and schema
praisonai mcp tools info tavily_search
praisonai mcp tools schema tavily_search
```

### Health check

Use the doctor command to verify MCP connectivity (not `praisonai mcp doctor`):

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai doctor mcp
praisonai doctor mcp --deep
```

## Using MCP with agents

### Basic usage

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai "What time is it?" --mcp "uvx mcp-server-time"
```

### Multiple MCP servers

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai "Get time and search" \
  --mcp "uvx mcp-server-time" \
  --mcp "npx -y @modelcontextprotocol/server-brave-search"
```

### With environment variables

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export BRAVE_API_KEY="your-key"
praisonai "Search for Python" \
  --mcp "npx -y @modelcontextprotocol/server-brave-search" \
  --mcp-env "BRAVE_API_KEY=${BRAVE_API_KEY}"
```

## Connection types

| Transport       | Example `--mcp` value         |
| --------------- | ----------------------------- |
| Stdio (command) | `"uvx mcp-server-time"`       |
| SSE URL         | `"http://localhost:8080/sse"` |
| HTTP stream     | `"http://localhost:8080"`     |
| WebSocket       | `"ws://localhost:8080"`       |

## Lifecycle management

Connections opened via `--mcp` are cleaned up automatically when the agent run finishes:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai "What time is it?" --mcp "uvx mcp-server-time"
```

## Debugging

### Verbose agent run

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai "Task" --mcp "uvx mcp-server-time" --verbose
```

### Python connectivity check

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

with MCP('uvx mcp-server-time') as mcp:
    print('Connection: OK')
    tools = mcp.get_tools()
    print(f'Tools: {len(tools)}')
print('Cleanup: OK')
"
```

## Related

<CardGroup cols={2}>
  <Card title="MCP CLI Reference" icon="terminal" href="/docs/cli/mcp">
    Full MCP command reference
  </Card>

  <Card title="Doctor CLI" icon="stethoscope" href="/docs/cli/doctor">
    MCP health checks via doctor mcp
  </Card>

  <Card title="MCP Tool Search" icon="magnifying-glass" href="/docs/cli/mcp-tool-search">
    Search and inspect MCP tools
  </Card>

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