MCP Tools Integration
Protocol Revision: 2025-11-25
Overview
MCP (Model Context Protocol) is a standard for connecting AI assistants to external tools and data sources. The MCP module in PraisonAI provides:- stdio Transport: Run MCP servers as subprocess commands
- Streamable HTTP Transport: Connect to HTTP endpoints with session management
- WebSocket Transport: Bidirectional real-time connections (SEP-1288)
- SSE Transport (Legacy): Backward compatibility with older servers
- Automatic Tool Discovery: Tools are automatically discovered and made available to agents
- Session Management: Stateful sessions with
Mcp-Session-Idheader - Resumability: SSE stream recovery via
Last-Event-ID - Security: Origin validation, authentication headers, secure session IDs
Quick Start
Transport Methods
Stdio Transport
The stdio transport runs MCP servers as subprocesses:Streamable HTTP Transport
The Streamable HTTP transport (Protocol Revision 2025-11-25) provides session management and resumability:WebSocket Transport
The WebSocket transport provides bidirectional real-time connections:SSE Transport (Legacy)
The SSE transport is maintained for backward compatibility with older servers:Available MCP Servers
Official NPX Servers
Custom Python Servers
Create your own MCP server in Python:Tool Discovery
MCP automatically discovers available tools:Error Handling
MCP includes built-in error handling and retry logic for robust operation.Advanced Usage
Multiple MCP Servers
PraisonAI supports passing multiple MCP server instances directly to an agent. You can combine different MCP servers along with regular Python functions.Environment Configuration
Debugging MCP Connections
Creating SSE MCP Servers
Example SSE server implementation:Best Practices
Transport Choice
- Use stdio for local tools and development
- Use SSE for remote/cloud deployments
- Consider latency and reliability needs
Reliability
- Implement timeouts for long-running operations
- Handle server disconnections gracefully
- Provide fallback options
Security
- Validate input/output from MCP servers
- Use environment variables for secrets
- Implement proper authentication for SSE
Performance
- Reuse MCP instances when possible
- Monitor subprocess resource usage
- Implement connection pooling for SSE
Example: Multi-Tool Agent
Resources & Prompts
If the connected server advertisesresources or prompts capabilities, PraisonAI automatically registers agent-callable tools (list_mcp_resources, read_mcp_resource, list_mcp_prompts, get_mcp_prompt). Tools-only servers are unaffected — no extra tools appear.
See MCP Resources & Prompts for the full guide.
Next Steps
Create custom tools for agents
Explore available MCP servers

