packages/cloud-frontend/content/mcp.mdx
import { Callout, Tabs, Cards } from "@/docs/components";
Deep dive into the Model Context Protocol implementation on elizaOS Cloud.
<div className="status-badge status-stable">Stable</div> <Callout type="info"> This page covers the **MCP protocol specification**. To connect MCP servers to your agents, see [MCP Integration](/docs/mcps). </Callout>MCP (Model Context Protocol) is a standard for connecting AI models to external tools and data:
elizaOS Cloud exposes an MCP-compatible endpoint:
https://elizacloud.ai/api/mcp
curl -X POST "https://elizacloud.ai/api/mcp" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {
"name": "my-client",
"version": "1.0.0"
}
},
"id": 1
}'
{
"jsonrpc": "2.0",
"result": {
"protocolVersion": "2024-11-05",
"capabilities": {
"tools": {},
"resources": {},
"prompts": {}
},
"serverInfo": {
"name": "elizaOS Cloud MCP",
"version": "1.0.0"
}
},
"id": 1
}
{
"jsonrpc": "2.0",
"method": "tools/list",
"id": 2
}
{
"jsonrpc": "2.0",
"result": {
"tools": [
{
"name": "generate_image",
"description": "Generate an image from a text prompt",
"inputSchema": {
"type": "object",
"properties": {
"prompt": {
"type": "string",
"description": "Image description"
},
"size": {
"type": "string",
"enum": ["square", "landscape", "portrait"]
}
},
"required": ["prompt"]
}
},
{
"name": "search_documents",
"description": "Search the knowledge base",
"inputSchema": {
"type": "object",
"properties": {
"query": { "type": "string" },
"limit": { "type": "integer" }
},
"required": ["query"]
}
}
]
},
"id": 2
}
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "generate_image",
"arguments": {
"prompt": "A sunset over mountains",
"size": "landscape"
}
},
"id": 3
}
{
"jsonrpc": "2.0",
"result": {
"content": [
{
"type": "image",
"data": "base64...",
"mimeType": "image/png"
}
]
},
"id": 3
}
{
"jsonrpc": "2.0",
"method": "resources/list",
"id": 4
}
{
"jsonrpc": "2.0",
"method": "resources/read",
"params": {
"uri": "eliza://documents/doc_abc123"
},
"id": 5
}
{
"jsonrpc": "2.0",
"method": "prompts/list",
"id": 6
}
{
"jsonrpc": "2.0",
"method": "prompts/get",
"params": {
"name": "summarize",
"arguments": {
"text": "Long text to summarize..."
}
},
"id": 7
}
Standard HTTP POST requests:
curl -X POST "https://elizacloud.ai/api/mcp" \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", ...}'
For streaming responses:
curl -X GET "https://elizacloud.ai/api/mcp/stream" \
-H "Accept: text/event-stream"
Coming soon for bidirectional communication.
elizaOS Cloud provides these built-in MCP tools:
| Tool | Description |
|---|---|
generate_image | Create images from prompts |
generate_video | Create videos from prompts |
search_documents | Query knowledge base |
get_weather | Current weather data |
get_time | Time and timezone info |
get_crypto_price | Cryptocurrency prices |
curl -X POST "https://elizacloud.ai/api/v1/mcps" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "My MCP Server",
"url": "https://my-mcp-server.com/mcp",
"authentication": {
"type": "bearer",
"token": "xxx"
}
}'
Access external MCPs through elizaOS:
curl -X POST "https://elizacloud.ai/api/mcp/proxy/{mcpId}" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {...},
"id": 1
}'
const express = require('express');
const app = express();
app.post('/mcp', (req, res) => {
const { method, params, id } = req.body;
switch (method) {
case 'initialize':
return res.json({
jsonrpc: '2.0',
result: {
protocolVersion: '2024-11-05',
capabilities: { tools: {} },
serverInfo: { name: 'My MCP', version: '1.0.0' }
},
id
});
case 'tools/list':
return res.json({
jsonrpc: '2.0',
result: { tools: myTools },
id
});
case 'tools/call':
const result = await handleToolCall(params);
return res.json({
jsonrpc: '2.0',
result,
id
});
}
});
| Code | Name | Description |
|---|---|---|
| -32700 | Parse error | Invalid JSON |
| -32600 | Invalid request | Invalid JSON-RPC |
| -32601 | Method not found | Unknown method |
| -32602 | Invalid params | Invalid parameters |
| -32603 | Internal error | Server error |
{
"jsonrpc": "2.0",
"error": {
"code": -32602,
"message": "Invalid params",
"data": { "field": "prompt", "issue": "required" }
},
"id": 1
}