Server: Tools MCP
Deploy Python tools as MCP servers for Claude Desktop, Cursor, and other MCP clients
Expose Python functions as MCP (Model Context Protocol) tools for Claude Desktop, Cursor, and other MCP clients.
CLI
pip install "praisonaiagents[mcp]"
# Start MCP server
praisonai serve mcp --transport sse --port 8080
# Start with specific server name
praisonai serve mcp --name my-server --transport sse --port 8080| Option | Default | Description |
|---|---|---|
--host | 127.0.0.1 | Host to bind to |
--port | 8080 | Server port |
--transport | stdio | Transport: stdio, sse |
--name | – | Server name from config |
Python – Custom Tools
from praisonaiagents import ToolsMCPServer
def search(query: str) -> str:
"""Search the web for information."""
return f"Results for: {query}"
def calculate(expression: str) -> str:
"""Calculate a math expression."""
return str(eval(expression))
server = ToolsMCPServer(name="my-tools")
server.register_tool(search)
server.register_tool(calculate)
server.run(transport="sse", host="0.0.0.0", port=8080)Expected Output:
🚀 Starting MCP server 'my-tools' with SSE transport
📡 SSE endpoint: http://0.0.0.0:8080/sse
🛠️ Available tools: search, calculateVerify:
curl http://localhost:8080/ssePython – Built-in Tools
from praisonaiagents import launch_tools_mcp_server
launch_tools_mcp_server(
tool_names=["tavily_search", "wikipedia_search"],
transport="sse",
port=8080
)Expected Output:
🚀 Starting MCP server 'praisonai-tools' with SSE transport
📡 SSE endpoint: http://0.0.0.0:8080/sse
🛠️ Available tools: tavily_search, wikipedia_searchPython – Stdio Transport
For Claude Desktop local integration:
from praisonaiagents import ToolsMCPServer
def my_tool(query: str) -> str:
"""Process a query."""
return f"Processed: {query}"
server = ToolsMCPServer(name="my-tools", tools=[my_tool])
server.run(transport="stdio")Expected Output:
🚀 Starting MCP server 'my-tools' with stdio transport
🛠️ Available tools: my_toolagents.yaml
Tools MCP server is Python-only. No agents.yaml support.
MCP Endpoints (SSE Transport)
| Endpoint | Method | Description |
|---|---|---|
/sse | GET | SSE connection for MCP |
/messages/ | POST | Send MCP messages |
ToolsMCPServer Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | praisonai-tools | Server name |
tools | list | None | Initial tools to register |
debug | bool | False | Enable debug logging |
launch_tools_mcp_server Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
tools | list | None | Custom tool functions |
tool_names | list | None | Built-in tool names |
name | str | praisonai-tools | Server name |
transport | str | stdio | stdio or sse |
host | str | 0.0.0.0 | Host for SSE |
port | int | 8080 | Port for SSE |
Connect MCP Client
Claude Desktop (claude_desktop_config.json):
For SSE transport:
{
"mcpServers": {
"my-tools": {
"url": "http://localhost:8080/sse"
}
}
}For stdio transport:
{
"mcpServers": {
"my-tools": {
"command": "python",
"args": ["/path/to/mcp_server.py"]
}
}
}Cursor (.cursor/mcp.json):
{
"mcpServers": {
"my-tools": {
"url": "http://localhost:8080/sse"
}
}
}Test MCP Tools
# List tools
curl -X POST http://localhost:8080/messages/ \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}'Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"tools": [
{
"name": "search",
"description": "Search the web for information.",
"inputSchema": {
"type": "object",
"properties": {"query": {"type": "string"}},
"required": ["query"]
}
}
]
}
}# Call tool
curl -X POST http://localhost:8080/messages/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {"name": "search", "arguments": {"query": "AI news"}},
"id": 2
}'Response:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"content": [{"type": "text", "text": "Results for: AI news"}]
}
}Troubleshooting
| Issue | Fix |
|---|---|
| Port in use | lsof -i :8080 |
| Missing deps | pip install "praisonaiagents[mcp]" |
| Tool not found | Check tool is registered before run() |
| SSE not connecting | Check firewall, use host="0.0.0.0" |
Related
- MCP API Reference – Full MCP endpoint documentation
- Agents Server – Deploy agents as HTTP server
- A2A Server – Deploy as A2A server