The MCP (Model Context Protocol) module enables seamless integration of MCP-compliant tools and servers with PraisonAI agents, supporting multiple transport methods.
from praisonaiagents import Agent, MCP# Use the memory MCP server from NPXagent = Agent( name="Memory Assistant", instructions="You can store and retrieve memories.", tools=MCP("npx @modelcontextprotocol/server-memory"))response = agent.start("Remember that my favourite colour is blue")
PraisonAI supports passing multiple MCP server instances directly to an agent. You can combine different MCP servers along with regular Python functions.
Copy
from praisonaiagents import Agent, MCP# Pass multiple MCP instances directly in a listagent = Agent( name="Multi-Tool Assistant", instructions="You can manage files, memories, and check time.", tools=[ MCP("uvx mcp-server-time"), # Time tools MCP("npx @modelcontextprotocol/server-memory"), # Memory tools MCP("npx @modelcontextprotocol/server-filesystem /tmp") # File tools ])response = agent.start("What time is it in Tokyo? Then save this to memory.")
from praisonaiagents import Agent, Task, Agents, MCPimport os# Set up environmentos.environ["GITHUB_TOKEN"] = "ghp_..."# Create agent with multiple MCP toolsagent = Agent( name="DevOps Assistant", instructions="""You are a DevOps assistant that can: - Manage files and directories - Interact with GitHub repositories - Store and retrieve important information Use your tools wisely to help with development tasks.""", tools=[ MCP("npx @modelcontextprotocol/server-filesystem"), MCP("npx @modelcontextprotocol/server-github"), MCP("npx @modelcontextprotocol/server-memory") ])# Create taskstasks = [ Task( description="Check the current directory structure", agent=agent, expected_output="Directory listing with key files identified" ), Task( description="Remember the project structure for future reference", agent=agent, expected_output="Confirmation that structure is memorised" )]# Run the systemagents = Agents(agents=[agent], tasks=tasks)result = agents.start()