Server: Agents MCP
Deploy agents as MCP servers using Agent.launch(protocol='mcp')
Publish single or multi-agent systems over MCP with launch(protocol="mcp") โ the built-in idiom that delegates to serve_agents(...) under the hood.
Quick Start
- Install Dependencies
bash pip install praisonai-mcppraisonai-mcpis an optional package imported lazily. Without it,launch(protocol="mcp")prints: “MCP serving requires the ‘praisonai-mcp’ package.” - Set API Key
bash export OPENAI_API_KEY="your-key" - Create Agent MCP Server
python from praisonaiagents import Agent agent = Agent( name="TweetAgent", instructions="Create engaging tweets", llm="gpt-4o-mini" ) agent.launch(port=8080, protocol="mcp") - Verify
bash curl http://localhost:8080/mcp
Which idiom fits your code?
Single Agent as MCP
from praisonaiagents import Agent
agent = Agent(
name="TweetAgent",
instructions="Create engaging tweets",
llm="gpt-4o-mini"
)
agent.launch(port=8080, protocol="mcp")
# Equivalent to: serve_agents([agent], port=8080)Published tools: ask_tweetagent + list_agents. The output comes from praisonai-mcp and the endpoint is /mcp.
Multi-Agent as MCP
from praisonaiagents import Agent
from praisonaiagents.agents import PraisonAIAgents
researcher = Agent(name="Researcher", instructions="Research topics", llm="gpt-4o-mini")
writer = Agent(name="Writer", instructions="Write content", llm="gpt-4o-mini")
agents = PraisonAIAgents(agents=[researcher, writer])
agents.launch(port=8080, protocol="mcp")
# Equivalent to: serve_agents([researcher, writer], port=8080)Each agent gets its own ask_{name} tool โ here ask_researcher and ask_writer โ plus one shared list_agents.
MCP Endpoints
| Endpoint | Method | Description |
|---|---|---|
/mcp | POST | JSON-RPC over spec-compliant streamable HTTP |
See Serve Agents for the canonical tool schema and session model.
launch() Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
port | int | 8000 | Server port |
host | str | 0.0.0.0 | Server host |
protocol | str | mcp | Must be mcp |
debug | bool | False | Debug mode |
Connect MCP Client
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"praisonai-agent": {
"url": "http://localhost:8080/mcp",
"transport": "http-stream"
}
}
}Cursor (.cursor/mcp.json):
{
"mcpServers": {
"praisonai-agent": {
"url": "http://localhost:8080/mcp",
"transport": "http-stream"
}
}
}Test MCP Tools
# List tools
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}'
# Call tool
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {"name": "ask_tweetagent", "arguments": {"message": "Create a tweet about AI"}},
"id": 2
}'Docker Deployment
app.py:
from praisonaiagents import Agent
agent = Agent(instructions="Create tweets", llm="gpt-4o-mini")
agent.launch(port=8080, protocol="mcp")Dockerfile:
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY app.py .
EXPOSE 8080
CMD ["python", "app.py"]requirements.txt:
praisonaiagents
praisonai-mcpBuild and run:
docker build -t agent-mcp-server .
docker run -p 8080:8080 -e OPENAI_API_KEY=$OPENAI_API_KEY agent-mcp-serverTroubleshooting
| Issue | Fix |
|---|---|
| Port in use | lsof -i :8080 |
MCP serving requires the 'praisonai-mcp' package. | pip install praisonai-mcp |
| No API key | export OPENAI_API_KEY="your-key" |
| Client can’t connect | Check firewall, use host="0.0.0.0" |
Related
- Serve Agents – The
serve_agents([...])functionlaunch()delegates to - API Vocabulary – One page for
approval=andlaunch(protocol=...) - Tools MCP – Deploy tools as MCP server
- Recipes MCP – Deploy recipes as MCP server
- PraisonAI MCP – Full PraisonAI MCP server
- Agents HTTP – Deploy as HTTP server