Skip to main content
MCP (Model Context Protocol) endpoints for agents deployed via Agent.launch(protocol="mcp") or ToolsMCPServer.

Base URL

http://localhost:{port}
Default port is 8080.

Endpoints

GET /sse

Server-Sent Events endpoint for MCP communication. Request:
curl -N http://localhost:8080/sse
Response: SSE stream with MCP protocol messages.

POST /messages/

Send JSON-RPC messages to the MCP server. Request:
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": "execute_assistant_task",
        "description": "Executes the agent's primary task with the given prompt.",
        "inputSchema": {
          "type": "object",
          "properties": {
            "prompt": {"type": "string"}
          },
          "required": ["prompt"]
        }
      }
    ]
  }
}

MCP Methods

tools/list

List available tools. Request:
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"]
        }
      }
    ]
  }
}

tools/call

Execute a tool. Request:
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"
      }
    ]
  }
}

initialize

Initialize MCP session. Request:
curl -X POST http://localhost:8080/messages/ \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "initialize",
    "params": {
      "protocolVersion": "2024-11-05",
      "capabilities": {},
      "clientInfo": {"name": "test-client", "version": "1.0.0"}
    },
    "id": 0
  }'
Response:
{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "protocolVersion": "2024-11-05",
    "capabilities": {"tools": {}},
    "serverInfo": {"name": "praisonai-tools", "version": "1.0.0"}
  }
}

Error Responses

MCP errors follow JSON-RPC 2.0 format:
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32601,
    "message": "Method not found"
  }
}
CodeMessage
-32700Parse error
-32600Invalid request
-32601Method not found
-32602Invalid params
-32603Internal error

Python Client

import requests

# List tools
response = requests.post(
    "http://localhost:8080/messages/",
    json={"jsonrpc": "2.0", "method": "tools/list", "id": 1}
)
tools = response.json()["result"]["tools"]
print(f"Available tools: {[t['name'] for t in tools]}")

# Call tool
response = requests.post(
    "http://localhost:8080/messages/",
    json={
        "jsonrpc": "2.0",
        "method": "tools/call",
        "params": {"name": "search", "arguments": {"query": "AI"}},
        "id": 2
    }
)
print(response.json()["result"])