This guide demonstrates how to create Model Context Protocol
(MCP) servers using Praison Labs agents. MCP is a protocol that
enables AI models to use tools and communicate with external
systems in a standardized way.
The simplest way to create an MCP server is with a single
agent. This approach is ideal for specialized tasks where you
need just one agent with a specific capability.
1
Install Dependencies
Make sure you have the required packages installed:
Copy
pip install "praisonaiagents[mcp]>=0.0.81"
2
Create a Simple MCP Server
Create a file named
simple-mcp-server.py with the following
code:
Copy
from praisonaiagents import Agentagent = Agent(instructions="Create a Tweet based on the topic provided")agent.launch(port=8080, protocol="mcp")
3
Run the Server
Copy
python simple-mcp-server.py
Your MCP server will be available at
http://localhost:8080
For more complex scenarios, you can create an MCP server with
multiple agents and custom tools. This approach allows for
collaborative problem-solving and specialized capabilities.
For scenarios where you need multiple agents to collaborate
without custom tools, you can create a simpler multi-agent MCP
server:
Copy
from praisonaiagents import Agent, Agentsagent = Agent(instructions="You Search the internet for information")agent2 = Agent(instructions="You Summarise the information")agents = Agents(agents=[agent, agent2])agents.launch(port=8080, protocol="mcp")
This approach is ideal for cases where you want agents with
different specializations to work together using their
built-in capabilities.
from praisonaiagents import Agent, MCPclient_agent = Agent( instructions="Use the MCP server to complete tasks", llm="gpt-4o-mini", tools=MCP("http://localhost:8080"))response = client_agent.start("Create a tweet about artificial intelligence")print(response)