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
praisonai mcp list
praisonai "Search files" --mcp "npx -y @modelcontextprotocol/server-filesystem ."Usage
!Manage MCP Server Configuration
Basic MCP Server
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
# 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
praisonai "Complex task" \
--mcp "npx server-name" \
--mcp-env "API_KEY=key1,SECRET=secret2,REGION=us-east-1"Popular MCP Servers
--mcp "npx -y @modelcontextprotocol/server-filesystem ."Read, write, and list files
Brave Search--mcp "npx -y @modelcontextprotocol/server-brave-search"
--mcp-env "BRAVE_API_KEY=xxx"Web search capabilities
GitHub--mcp "npx -y @modelcontextprotocol/server-github"
--mcp-env "GITHUB_TOKEN=xxx"GitHub repository operations
PostgreSQL--mcp "npx -y @modelcontextprotocol/server-postgres"
--mcp-env "DATABASE_URL=xxx"Database queries
Slack--mcp "npx -y @modelcontextprotocol/server-slack"
--mcp-env "SLACK_TOKEN=xxx"Slack messaging
Google Drive--mcp "npx -y @anthropic/server-gdrive"Google Drive access
Use Cases
File Operations
praisonai "Read the README.md file and summarize it" \
--mcp "npx -y @modelcontextprotocol/server-filesystem ."Web Research
praisonai "Research the latest developments in quantum computing" \
--mcp "npx -y @modelcontextprotocol/server-brave-search" \
--mcp-env "BRAVE_API_KEY=your_key"Database Queries
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
praisonai "List open issues in the repository" \
--mcp "npx -y @modelcontextprotocol/server-github" \
--mcp-env "GITHUB_TOKEN=ghp_xxx"Combine with Other Features
# 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
--mcp "command [args...]"Examples:
--mcp "npx -y @modelcontextprotocol/server-filesystem ."--mcp "python -m mcp_server"--mcp "node ./my-server.js"
Environment Variables Format
--mcp-env "KEY1=value1,KEY2=value2"Best Practices
Use environment variables for sensitive credentials
TestingTest MCP servers with simple commands first
PermissionsGrant minimum necessary permissions to MCP servers
MonitoringUse --metrics to track MCP tool usage
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
praisonai mcp listExpected Output:
MCP Server Configurations
โโโโโโโโโโโโโโณโโโโโโโโโโณโโโโโโโโโโณโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Name โ Command โ Enabled โ Scope โ Description โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ filesystem โ npx โ โ
โ workspace โ Filesystem access โ
โ brave โ npx โ โ
โ global โ Brave search โ
โโโโโโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโCreate Configuration
praisonai mcp create <name> <command> [args...]Example:
praisonai mcp create filesystem npx -y @modelcontextprotocol/server-filesystem .Show Configuration
praisonai mcp show <name>Expected Output:
MCP Config: filesystem
Command: npx
Args: -y @modelcontextprotocol/server-filesystem .
Enabled: Yes
Description: Filesystem accessEnable/Disable Configuration
praisonai mcp enable <name>
praisonai mcp disable <name>Delete Configuration
praisonai mcp delete <name>Verify MCP Setup
Check server health and inspect available tools before wiring them into agents.
# 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/:
{
"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 |
|---|---|---|
~/.praisonai/mcp/ | Workspace | Project-specific configs |
~/.praisonai/mcp/config.json | Global | Shared across all projects |
Python API
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()