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

# MCP (Model Context Protocol)

> Integrate Model Context Protocol servers as tools for agents

The `--mcp` flag enables integration with Model Context Protocol (MCP) servers, allowing agents to use external tools and services.

## Quick Start

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

<Frame>
  <img src="https://mintcdn.com/praisonai/SX0Y8_-DRBjzOTnt/docs/cli/mcp-list-mcp-servers.gif?s=bc21d02b7521bab81095a5b81621ebc3" alt="List MCP servers example" width="1497" height="1104" data-path="docs/cli/mcp-list-mcp-servers.gif" />
</Frame>

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai "Search files" --mcp "npx -y @modelcontextprotocol/server-filesystem ."
```

## Usage

<img src="https://mintcdn.com/praisonai/fT4nF3hY6KPMOPvS/docs/cli/mcp-manage-mcp-server-configuratio.gif?s=e407e0dbfb36fa93a415658c5d02b981" alt="Manage MCP Server Configuration" width="1497" height="1104" data-path="docs/cli/mcp-manage-mcp-server-configuratio.gif" />

### Basic MCP Server

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai "List files in current directory" --mcp "npx -y @modelcontextprotocol/server-filesystem ."
```

**Expected Output:**

```
🔌 MCP Server connected: @modelcontextprotocol/server-filesystem

╭─ Agent Info ─────────────────────────────────────────────────────────────────╮
│  👤 Agent: DirectAgent                                                       │
│  Role: Assistant                                                             │
│  🔧 Tools: list_directory, read_file, write_file                            │
╰──────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────── Response ──────────────────────────────────╮
│ Here are the files in the current directory:                                 │
│                                                                              │
│ 📁 src/                                                                      │
│ 📁 tests/                                                                    │
│ 📄 README.md                                                                 │
│ 📄 package.json                                                              │
│ 📄 requirements.txt                                                          │
╰──────────────────────────────────────────────────────────────────────────────╯
```

### MCP with Environment Variables

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Brave Search with API key
praisonai "Search for AI news" \
  --mcp "npx -y @modelcontextprotocol/server-brave-search" \
  --mcp-env "BRAVE_API_KEY=your_api_key"
```

**Expected Output:**

```
🔌 MCP Server connected: @modelcontextprotocol/server-brave-search
🔑 Environment variables loaded

╭────────────────────────────────── Response ──────────────────────────────────╮
│ Here are the latest AI news articles:                                        │
│                                                                              │
│ 1. "OpenAI Announces GPT-5" - TechCrunch                                    │
│    https://techcrunch.com/2024/12/...                                       │
│                                                                              │
│ 2. "Google DeepMind's Latest Breakthrough" - The Verge                      │
│    https://theverge.com/2024/12/...                                         │
╰──────────────────────────────────────────────────────────────────────────────╯
```

### Multiple Environment Variables

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai "Complex task" \
  --mcp "npx server-name" \
  --mcp-env "API_KEY=key1,SECRET=secret2,REGION=us-east-1"
```

## Popular MCP Servers

<CardGroup cols={2}>
  <Card title="Filesystem" icon="folder">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    --mcp "npx -y @modelcontextprotocol/server-filesystem ."
    ```

    Read, write, and list files
  </Card>

  <Card title="Brave Search" icon="magnifying-glass">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    --mcp "npx -y @modelcontextprotocol/server-brave-search"
    --mcp-env "BRAVE_API_KEY=xxx"
    ```

    Web search capabilities
  </Card>

  <Card title="GitHub" icon="github">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    --mcp "npx -y @modelcontextprotocol/server-github"
    --mcp-env "GITHUB_TOKEN=xxx"
    ```

    GitHub repository operations
  </Card>

  <Card title="PostgreSQL" icon="database">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    --mcp "npx -y @modelcontextprotocol/server-postgres"
    --mcp-env "DATABASE_URL=xxx"
    ```

    Database queries
  </Card>

  <Card title="Slack" icon="slack">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    --mcp "npx -y @modelcontextprotocol/server-slack"
    --mcp-env "SLACK_TOKEN=xxx"
    ```

    Slack messaging
  </Card>

  <Card title="Google Drive" icon="google-drive">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    --mcp "npx -y @anthropic/server-gdrive"
    ```

    Google Drive access
  </Card>
</CardGroup>

## Use Cases

### File Operations

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai "Read the README.md file and summarize it" \
  --mcp "npx -y @modelcontextprotocol/server-filesystem ."
```

### Web Research

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai "Research the latest developments in quantum computing" \
  --mcp "npx -y @modelcontextprotocol/server-brave-search" \
  --mcp-env "BRAVE_API_KEY=your_key"
```

### Database Queries

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai "Show me the top 10 customers by revenue" \
  --mcp "npx -y @modelcontextprotocol/server-postgres" \
  --mcp-env "DATABASE_URL=postgresql://user:pass@localhost/db"
```

**Expected Output:**

```
╭────────────────────────────────── Response ──────────────────────────────────╮
│ Top 10 Customers by Revenue:                                                 │
│                                                                              │
│ | Rank | Customer        | Revenue      |                                   │
│ |------|-----------------|--------------|                                   │
│ | 1    | Acme Corp       | $1,250,000   |                                   │
│ | 2    | TechStart Inc   | $980,000     |                                   │
│ | 3    | Global Systems  | $875,000     |                                   │
│ | ...  | ...             | ...          |                                   │
╰──────────────────────────────────────────────────────────────────────────────╯
```

### GitHub Operations

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai "List open issues in the repository" \
  --mcp "npx -y @modelcontextprotocol/server-github" \
  --mcp-env "GITHUB_TOKEN=ghp_xxx"
```

## Combine with Other Features

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# MCP with metrics
praisonai "Search and analyze" --mcp "npx server" --metrics

# MCP with planning
praisonai "Complex research task" --mcp "npx server" --planning

# MCP with guardrail
praisonai "Query database" --mcp "npx postgres-server" --guardrail "Read-only queries"
```

## MCP Server Configuration

### Command Format

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
--mcp "command [args...]"
```

Examples:

* `--mcp "npx -y @modelcontextprotocol/server-filesystem ."`
* `--mcp "python -m mcp_server"`
* `--mcp "node ./my-server.js"`

### Environment Variables Format

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
--mcp-env "KEY1=value1,KEY2=value2"
```

<Warning>
  Never commit API keys or secrets to version control. Use environment variables or secure secret management.
</Warning>

## Best Practices

<Tip>
  Test MCP servers independently before using them with agents to ensure they're working correctly.
</Tip>

<CardGroup cols={2}>
  <Card title="Security">
    Use environment variables for sensitive credentials
  </Card>

  <Card title="Testing">
    Test MCP servers with simple commands first
  </Card>

  <Card title="Permissions">
    Grant minimum necessary permissions to MCP servers
  </Card>

  <Card title="Monitoring">
    Use `--metrics` to track MCP tool usage
  </Card>
</CardGroup>

## Troubleshooting

| Issue              | Solution                                       |
| ------------------ | ---------------------------------------------- |
| Server not found   | Ensure npx/node is installed and in PATH       |
| Connection timeout | Check network connectivity and server status   |
| Permission denied  | Verify API keys and access permissions         |
| Tool not available | Check server documentation for available tools |

## MCP Configuration Management

In addition to the `--mcp` flag, you can manage MCP server configurations using the `praisonai mcp` command.

### List Configurations

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

**Expected Output:**

```
                         MCP Server Configurations                         
┏━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Name       ┃ Command ┃ Enabled ┃ Scope     ┃ Description                ┃
┡━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ filesystem │ npx     │ ✅      │ workspace │ Filesystem access          │
│ brave      │ npx     │ ✅      │ global    │ Brave search               │
└────────────┴─────────┴─────────┴───────────┴────────────────────────────┘
```

### Create Configuration

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai mcp create <name> <command> [args...]
```

**Example:**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai mcp create filesystem npx -y @modelcontextprotocol/server-filesystem .
```

### Show Configuration

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai mcp show <name>
```

**Expected Output:**

```
MCP Config: filesystem
Command: npx
Args: -y @modelcontextprotocol/server-filesystem .
Enabled: Yes
Description: Filesystem access
```

### Enable/Disable Configuration

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai mcp enable <name>
praisonai mcp disable <name>
```

### Delete Configuration

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai mcp delete <name>
```

### Configuration File Format

MCP configs are stored as JSON files in `.praison/mcp/`:

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "name": "filesystem",
  "command": "npx",
  "args": ["-y", "@modelcontextprotocol/server-filesystem", "."],
  "env": {
    "SOME_VAR": "value"
  },
  "enabled": true,
  "description": "Filesystem access for the agent"
}
```

### Storage Locations

| Location            | Scope     | Description                |
| ------------------- | --------- | -------------------------- |
| `.praison/mcp/`     | Workspace | Project-specific configs   |
| `~/.praisonai/mcp/` | Global    | Shared across all projects |

### Python API

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

# Initialize
mcp = MCPConfigManager(workspace_path=".")

# List all configs
configs = mcp.list_configs()

# Get a specific config
config = mcp.get_config("filesystem")

# Create a config
mcp.create_config(
    name="brave-search",
    command="npx",
    args=["-y", "@modelcontextprotocol/server-brave-search"],
    env={"BRAVE_API_KEY": "$BRAVE_API_KEY"},
    description="Brave web search"
)

# Get MCP tools for agents
tools = mcp.get_mcp_tools()
```

## Related

* [MCP Overview](/mcp/transports)
* [MCP Servers](/mcp/mcp-server)
* [Custom MCP](/mcp/custom)
