Skip to Content

MCP Integration

Extend your agents with external tools and services using the Model Context Protocol.

Stable

This page covers connecting MCP servers to your agents. For protocol details and building your own MCP server, see MCP Protocol.

Overview

MCP (Model Context Protocol) allows agents to:

Quick Start

Dashboard

Browse and connect MCP servers at Dashboard → MCPs.

API

curl -X POST "https://cloud.milady.ai/api/v1/mcps" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Weather MCP", "url": "https://mcp.eliza.ai/weather", "agentId": "agent_abc123" }'

MCP Registry

elizaOS Cloud provides a curated registry of MCP servers:

ServerDescriptionTools
WeatherCurrent weather and forecastsget_weather, get_forecast
SearchWeb search capabilitiessearch_web, search_images
CryptoCryptocurrency dataget_price, get_market_data
CalculatorMath operationscalculate, convert_units
TimeTime and timezone toolsget_time, convert_timezone

Browse Registry

curl -X GET "https://cloud.milady.ai/api/mcp/registry" \ -H "Authorization: Bearer YOUR_API_KEY"
{ "servers": [ { "id": "weather", "name": "Weather MCP", "description": "Get weather data for any location", "url": "https://mcp.eliza.ai/weather", "tools": [ { "name": "get_weather", "description": "Get current weather for a location", "inputSchema": { "type": "object", "properties": { "location": { "type": "string" } } } } ] } ] }

Connecting MCP Servers

Select a Server

Browse the MCP registry or use a custom server URL.

Configure Connection

Provide the server URL and any required authentication.

Connect the MCP server to your agent.

Test

Verify the tools are available in the agent.

Connect via API

curl -X POST "https://cloud.milady.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", "agentId": "agent_abc123", "authentication": { "type": "bearer", "token": "mcp_token_xxx" } }'

Using MCP Tools

When MCP servers are connected, agents can use their tools automatically:

const response = await fetch("https://cloud.milady.ai/api/v1/chat/completions", { method: "POST", headers: { Authorization: "Bearer YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ model: "agent_abc123", // Agent with MCP connected messages: [{ role: "user", content: "What's the weather in Tokyo?" }], }), });

The agent will automatically invoke the get_weather tool and include the result in its response.

MCP Protocol

JSON-RPC Interface

elizaOS Cloud exposes an MCP-compatible JSON-RPC interface:

curl -X POST "https://cloud.milady.ai/api/mcp" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "tools/list", "id": 1 }'

Available Methods

MethodDescription
tools/listList available tools
tools/callExecute a tool
resources/listList available resources
resources/readRead a resource
prompts/listList available prompts
prompts/getGet a prompt

Execute Tool

{ "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "get_weather", "arguments": { "location": "San Francisco" } }, "id": 2 }

Response:

{ "jsonrpc": "2.0", "result": { "content": [ { "type": "text", "text": "Current weather in San Francisco: 65°F, Partly Cloudy" } ] }, "id": 2 }

Custom MCP Servers

Server Requirements

Your MCP server must implement:

  1. HTTP Transport: Accept POST requests
  2. JSON-RPC 2.0: Standard JSON-RPC protocol
  3. MCP Methods: initialize, tools/list, tools/call

Basic Server Example

// Simple MCP server with Express const express = require("express"); const app = express(); app.use(express.json()); const tools = [ { name: "greet", description: "Greet a person", inputSchema: { type: "object", properties: { name: { type: "string" }, }, required: ["name"], }, }, ]; app.post("/mcp", (req, res) => { const { method, params, id } = req.body; if (method === "tools/list") { return res.json({ jsonrpc: "2.0", result: { tools }, id, }); } if (method === "tools/call") { const { name, arguments: args } = params; if (name === "greet") { return res.json({ jsonrpc: "2.0", result: { content: [{ type: "text", text: `Hello, ${args.name}!` }], }, id, }); } } res.json({ jsonrpc: "2.0", error: { code: -32601, message: "Method not found" }, id, }); }); app.listen(3000);

Demo Servers

elizaOS Cloud provides demo MCP servers for testing:

ServerURLDescription
Weather/api/mcps/weatherWeather data demo
Time/api/mcps/timeTime and timezone demo
Crypto/api/mcps/cryptoCryptocurrency data demo

Test Demo Server

curl -X POST "https://cloud.milady.ai/api/mcps/weather" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "get_weather", "arguments": { "location": "New York" } }, "id": 1 }'

Managing MCP Connections

List Connected MCPs

curl -X GET "https://cloud.milady.ai/api/v1/mcps?agentId=agent_abc123" \ -H "Authorization: Bearer YOUR_API_KEY"

Disconnect MCP

curl -X DELETE "https://cloud.milady.ai/api/v1/mcps/mcp_abc123" \ -H "Authorization: Bearer YOUR_API_KEY"

Publish Custom MCP

Share your MCP server in the registry:

curl -X POST "https://cloud.milady.ai/api/v1/mcps/{mcpId}/publish" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "visibility": "public", "description": "My custom MCP server", "category": "utilities" }'

Best Practices

Next Steps