The MCP (Model Context Protocol) module enables seamless integration of MCP-compliant tools and servers with PraisonAI agents, supporting both stdio and SSE 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")
from praisonaiagents import Agent, Task, PraisonAIAgents, 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 = PraisonAIAgents(agents=[agent], tasks=tasks)result = agents.start()