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
praisonai mcp list
List MCP servers example
bash
praisonai "Search files" --mcp "npx -y @modelcontextprotocol/server-filesystem ."

Usage

!Manage MCP Server Configuration

Basic MCP Server

bash
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
# 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
praisonai "Complex task" \
  --mcp "npx server-name" \
  --mcp-env "API_KEY=key1,SECRET=secret2,REGION=us-east-1"

Popular MCP Servers

Use Cases

File Operations

bash
praisonai "Read the README.md file and summarize it" \
  --mcp "npx -y @modelcontextprotocol/server-filesystem ."

Web Research

bash
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
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
praisonai "List open issues in the repository" \
  --mcp "npx -y @modelcontextprotocol/server-github" \
  --mcp-env "GITHUB_TOKEN=ghp_xxx"

Combine with Other Features

bash
# 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
--mcp "command [args...]"

Examples:

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

Environment Variables Format

bash
--mcp-env "KEY1=value1,KEY2=value2"

Best Practices

Troubleshooting

IssueSolution
Server not foundEnsure npx/node is installed and in PATH
Connection timeoutCheck network connectivity and server status
Permission deniedVerify API keys and access permissions
Tool not availableCheck 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
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
praisonai mcp create <name> <command> [args...]

Example:

bash
praisonai mcp create filesystem npx -y @modelcontextprotocol/server-filesystem .

Show Configuration

bash
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
praisonai mcp enable <name>
praisonai mcp disable <name>

Delete Configuration

bash
praisonai mcp delete <name>

Verify MCP Setup

Check server health and inspect available tools before wiring them into agents.

bash
# Health check โ€” config, dependencies, protocol version
praisonai mcp doctor

# List tools exposed by the PraisonAI MCP server
praisonai mcp list-tools
praisonai mcp list-tools --json

# Search or inspect a specific tool
praisonai mcp tools search "filesystem"
praisonai mcp tools schema <tool-name>

Configuration File Format

MCP configs are stored as JSON files in ~/.praisonai/mcp/:

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

Storage Locations

LocationScopeDescription
~/.praisonai/mcp/WorkspaceProject-specific configs
~/.praisonai/mcp/config.jsonGlobalShared across all projects

Python API

python
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