> ## 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 Server CLI

> CLI commands for running PraisonAI as an MCP server

# MCP Server CLI Commands

PraisonAI provides comprehensive CLI commands for running and managing MCP servers.

<Note>
  The MCP server host ships as the standalone [praisonai-mcp](/docs/features/praisonai-mcp-package) package. Every `praisonai mcp serve …` example below also runs as `praisonai-mcp serve …` — both forms are equivalent for host commands. See [The Three MCP Layers](/docs/features/mcp-three-layers) for how the host fits.
</Note>

## Primary Command

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-mcp <subcommand> [options]   # standalone console script
praisonai mcp <subcommand> [options]   # equivalent (umbrella)
```

## Subcommands

`list-tools`, `list-resources`, `list-prompts`, `serve`, and `doctor` all share the same `register_all()` registration — anything `serve` exposes at runtime shows up in the corresponding `list-*` command (see sibling parity fix [#2146](https://github.com/MervinPraison/PraisonAIDocs/issues/2146)).

### serve

Start the MCP server.

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# STDIO transport (default, for Claude Desktop)
praisonai-mcp serve
praisonai mcp serve                 # equivalent

# HTTP Stream transport
praisonai-mcp serve --transport http-stream

# With all options
praisonai mcp serve \
  --transport http-stream \
  --host 127.0.0.1 \
  --port 8080 \
  --endpoint /mcp \
  --api-key YOUR_KEY \
  --name praisonai \
  --response-mode batch \
  --session-ttl 3600 \
  --log-level info
```

**Options:**

| Option              | Description                                             | Default     |
| ------------------- | ------------------------------------------------------- | ----------- |
| `--transport`       | `stdio` or `http-stream`                                | `stdio`     |
| `--host`            | Server host                                             | `127.0.0.1` |
| `--port`            | Server port                                             | `8080`      |
| `--endpoint`        | MCP endpoint path                                       | `/mcp`      |
| `--api-key`         | API key for authentication (single wildcard-scoped key) | None        |
| `--keys-file`       | JSON file of per-key scopes for least-privilege access  | None        |
| `--name`            | Server name                                             | `praisonai` |
| `--response-mode`   | `batch` or `stream`                                     | `batch`     |
| `--cors-origins`    | Comma-separated CORS origins                            | `*`         |
| `--allowed-origins` | Comma-separated allowed origins                         | localhost   |
| `--session-ttl`     | Session TTL in seconds                                  | `3600`      |
| `--no-termination`  | Disable client session termination                      | False       |
| `--resumability`    | Enable SSE resumability                                 | True        |
| `--log-level`       | `debug`, `info`, `warning`, `error`                     | `warning`   |
| `--json`            | Output in JSON format                                   | False       |
| `--debug`           | Enable debug mode                                       | False       |

<Note>
  Use `--keys-file` for per-team, least-privilege scoped keys. See [Scoped API keys](/docs/docs/mcp/mcp-auth#scoped-api-keys-via-keys-file) for the JSON format, the operation→scope map, and the `insufficient_scope` response.
</Note>

### list-tools

List all available MCP tools.

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

**Example Output:**

```
Available MCP Tools (86):

  • praisonai.chat.completion
    Generate chat completion.

  • praisonai.agent.chat
    Chat with a PraisonAI agent.

  • praisonai.images.generate
    Generate images from text prompt.
  ...
```

### list-resources

List all available MCP resources.

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai mcp list-resources
```

**Example Output:**

```
Available MCP Resources (7):

  • praisonai://memory/sessions
    List all memory sessions.

  • praisonai://workflows
    List available workflows in current directory.
  ...
```

<Note>
  The `list-resources` / `list-prompts` commands correctly print the registered
  entries as of **PraisonAI v4.6.154**. On earlier releases the two commands
  returned `"No resources registered"` / `"No prompts registered"` even when
  `doctor` reported 7 of each — see upstream [PR #3220](https://github.com/MervinPraison/PraisonAI/pull/3220).
  Upgrade with `pip install -U "praisonai-mcp[all]"` (or `pip install -U "praisonai[mcp]"`) if you see the old empty output.
</Note>

### list-prompts

List all available MCP prompts.

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai mcp list-prompts
```

**Example Output:**

```
Available MCP Prompts (7):

  • deep-research
    Generate a deep research prompt for comprehensive topic analysis

  • code-review
    Generate a code review prompt for analyzing code quality
  ...
```

<Note>
  Same version cutover as [`list-resources`](#list-resources): `list-prompts` prints
  the 7 registered prompts as of **PraisonAI v4.6.154**. Earlier releases printed
  `"No prompts registered"` even when `doctor` reported 7 — see upstream [PR #3220](https://github.com/MervinPraison/PraisonAI/pull/3220).
</Note>

### config-generate

Generate client configuration for MCP clients.

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Claude Desktop config
praisonai mcp config-generate --client claude-desktop

# Cursor config
praisonai mcp config-generate --client cursor

# VSCode config
praisonai mcp config-generate --client vscode

# Windsurf config
praisonai mcp config-generate --client windsurf

# Save to file
praisonai mcp config-generate --client claude-desktop --output config.json

# HTTP Stream config
praisonai mcp config-generate --client claude-desktop --transport http-stream --port 8080
```

**Options:**

| Option        | Description                   | Default          |
| ------------- | ----------------------------- | ---------------- |
| `--client`    | Client type                   | `claude-desktop` |
| `--output`    | Output file path              | stdout           |
| `--transport` | Transport type                | `stdio`          |
| `--host`      | Server host (for http-stream) | `127.0.0.1`      |
| `--port`      | Server port (for http-stream) | `8080`           |

**Output:**

Since **v4.6.154**, the generator auto-detects `praisonai-mcp` on your PATH and emits the matching STDIO command.

<Tabs>
  <Tab title="Standalone (praisonai-mcp)">
    ```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    {
      "mcpServers": {
        "praisonai": {
          "command": "praisonai-mcp",
          "args": ["serve", "--transport", "stdio"]
        }
      }
    }
    ```
  </Tab>

  <Tab title="Umbrella (praisonai)">
    ```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    {
      "mcpServers": {
        "praisonai": {
          "command": "praisonai",
          "args": ["mcp", "serve", "--transport", "stdio"]
        }
      }
    }
    ```
  </Tab>
</Tabs>

### doctor

Health check for the MCP server. Human-readable by default, or machine-readable with `--json`.

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Pretty (default)
praisonai mcp doctor

# Machine-readable — safe for CI, safe on Windows cp1252 consoles
praisonai mcp doctor --json
```

| Flag     | Effect                                                         |
| -------- | -------------------------------------------------------------- |
| `--json` | Machine-readable JSON output (no Unicode symbols, safe for CI) |

**Example Output (text):**

```
PraisonAI MCP Server Health Check

Protocol Version: 2025-11-25
Supported Versions: 2025-11-25, 2025-03-26, 2024-11-05

Registered Components:
  • Tools: 86
  • Resources: 7
  • Prompts: 7

Environment:
  ✓ OPENAI_API_KEY
  ○ ANTHROPIC_API_KEY
  ○ GOOGLE_API_KEY

Dependencies:
  ✓ starlette
  ✓ uvicorn
  ✓ praisonaiagents

✓ MCP server is ready to run
```

**Example Output (`--json`):**

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "protocol_version": "2025-11-25",
  "supported_versions": ["2025-11-25", "2025-03-26", "2024-11-05"],
  "components": {
    "tools": 86,
    "resources": 7,
    "prompts": 7
  },
  "environment": {
    "OPENAI_API_KEY": true,
    "ANTHROPIC_API_KEY": false,
    "GOOGLE_API_KEY": false
  },
  "dependencies": {
    "starlette": true,
    "uvicorn": true,
    "praisonaiagents": true
  },
  "ready": true
}
```

JSON-mode failures still emit valid JSON, so CI parsers never choke on Rich-formatted text:

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "error": "register blew up",
  "ready": false
}
```

<Note>
  On Windows consoles using a legacy code page (e.g. cp1252), `doctor` falls back to ASCII markers (`[OK]`, `[--]`, `[X]`) instead of the Unicode `✓ ○ ✗` — so it never crashes with `UnicodeEncodeError`. Add `--json` for automation on any platform; it never emits Unicode symbols. This mirrors the umbrella [`praisonai doctor`](/docs/docs/cli/doctor#status-symbols) status-symbol handling.
</Note>

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    Start[praisonai mcp doctor] --> Detect{stdout<br/>encoding?}
    Detect -->|utf-8| Unicode[✓ ○ ✗ •]
    Detect -->|cp1252 / other| Ascii["[OK] [--] [X] -"]
    Unicode --> Print[Render health check]
    Ascii --> Print

    classDef cmd fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef decide fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef ok fill:#10B981,stroke:#7C90A0,color:#fff
    classDef warn fill:#F59E0B,stroke:#7C90A0,color:#fff

    class Start cmd
    class Detect decide
    class Unicode ok
    class Ascii warn
    class Print cmd
```

## Deprecated Commands

The following commands are deprecated and will be removed in a future version:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# DEPRECATED - use 'praisonai mcp serve' instead
praisonai serve mcp

# DEPRECATED - use 'praisonai mcp serve' instead
praisonai serve tools
```

These commands will show a deprecation warning and redirect to `praisonai mcp serve`.

## Examples

### Start STDIO Server for Claude Desktop

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai mcp serve --transport stdio
```

### Start HTTP Server with Authentication

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai mcp serve \
  --transport http-stream \
  --port 8080 \
  --api-key mysecretkey
```

### Start Server with Custom Origins

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai mcp serve \
  --transport http-stream \
  --allowed-origins "http://localhost:3000,https://myapp.com"
```

### Generate and Apply Claude Desktop Config

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Generate config
praisonai mcp config-generate --client claude-desktop --output ~/Library/Application\ Support/Claude/claude_desktop_config.json

# Or manually copy the output
praisonai mcp config-generate --client claude-desktop
```

### Debug Mode

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai mcp serve --transport http-stream --debug --log-level debug
```

## Environment Variables

| Variable            | Description                         |
| ------------------- | ----------------------------------- |
| `OPENAI_API_KEY`    | OpenAI API key for chat/image tools |
| `ANTHROPIC_API_KEY` | Anthropic API key                   |
| `GOOGLE_API_KEY`    | Google API key                      |

## Exit Codes

| Code | Description                                                            |
| ---- | ---------------------------------------------------------------------- |
| 0    | Success — all dependencies present and at least one API key configured |
| 1    | Error — any dependency missing, or any exception raised                |

<Note>
  In `doctor --json` mode, missing API keys alone (with all dependencies present) still exit `0` — only a missing dependency or an exception exits `1`.
</Note>

## Common Issues

| Issue                                                                                     | Fix                                                                                                                                                                               |
| ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `praisonai-mcp list-resources` or `list-prompts` prints "No resources/prompts registered" | Upgrade to **v4.6.154** or later — the registries were being read before being populated on those subcommands ([PR #3220](https://github.com/MervinPraison/PraisonAI/pull/3220)). |

## See Also

* [PraisonAI MCP Server](/docs/mcp/praisonai-mcp-server) - Full MCP server documentation
* [MCP Transports](/docs/mcp/transports) - Transport protocol details
* [Custom MCP Server](/docs/mcp/custom-python-server) - Building custom MCP servers
* [praisonai doctor](/docs/cli/doctor) - Umbrella doctor with `--json` and status-symbol handling
