Back to Eliza

MCP Server API

packages/docs/rest/mcp.md

2.0.15.9 KB
Original Source

The MCP API manages Model Context Protocol server integrations. You can search the MCP marketplace for servers, add/remove server configurations, replace the full config, and check the runtime status of connected MCP servers.

Endpoints

MethodPathDescription
GET/api/mcp/marketplace/searchSearch the MCP marketplace
GET/api/mcp/marketplace/details/:nameGet details for a marketplace server
GET/api/mcp/configGet the current MCP server configuration
POST/api/mcp/config/serverAdd or update a single MCP server
DELETE/api/mcp/config/server/:nameRemove an MCP server from config
PUT/api/mcp/configReplace the entire MCP servers config
GET/api/mcp/statusGet runtime status of connected MCP servers

Search the MCP marketplace for available servers.

Query Parameters

ParameterTypeDefaultDescription
qstring""Search query (empty returns all)
limitnumber30Max results (1-50)

Response

json
{
  "ok": true,
  "results": [
    {
      "name": "filesystem",
      "description": "Read and write files on the local filesystem",
      "author": "modelcontextprotocol",
      "downloads": 50000
    }
  ]
}

Errors

StatusCondition
502Marketplace search failed (upstream error)

GET /api/mcp/marketplace/details/:name

Get full details for a specific MCP server from the marketplace.

Path Parameters

ParameterTypeDescription
namestringServer name (URL-encoded)

Response

json
{
  "ok": true,
  "server": {
    "name": "filesystem",
    "description": "Read and write files",
    "author": "modelcontextprotocol",
    "homepage": "https://github.com/modelcontextprotocol/servers",
    "config": {
      "command": "bunx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"]
    }
  }
}

Errors

StatusCondition
400Server name is empty
404Server not found in marketplace
502Failed to fetch details

GET /api/mcp/config

Returns the current MCP server configuration from the Eliza config file. Secret values (API keys, tokens) are redacted.

Response

json
{
  "ok": true,
  "servers": {
    "filesystem": {
      "command": "bunx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home"]
    },
    "brave-search": {
      "command": "bunx",
      "args": ["-y", "@modelcontextprotocol/server-brave-search"],
      "env": {
        "BRAVE_API_KEY": "****"
      }
    }
  }
}

POST /api/mcp/config/server

Add or update a single MCP server configuration. Changes are persisted to the config file. A restart is typically required for the runtime to pick up the new server.

Request Body

FieldTypeRequiredDescription
namestringYesServer identifier
configobjectYesServer config (command, args, env, etc.)
json
{
  "name": "brave-search",
  "config": {
    "command": "bunx",
    "args": ["-y", "@modelcontextprotocol/server-brave-search"],
    "env": {
      "BRAVE_API_KEY": "BSA_xxxx"
    }
  }
}

Response

json
{
  "ok": true,
  "name": "brave-search",
  "requiresRestart": true
}

Errors

StatusCondition
400Server name is empty or reserved (__proto__, constructor, prototype)
400Config object is missing or invalid

DELETE /api/mcp/config/server/:name

Remove an MCP server from the configuration. A restart is required for the change to take effect.

Path Parameters

ParameterTypeDescription
namestringServer name (URL-encoded)

Response

json
{
  "ok": true,
  "requiresRestart": true
}

PUT /api/mcp/config

Replace the entire MCP servers configuration object. All existing servers are replaced with the provided set.

Request Body

FieldTypeRequiredDescription
serversobjectYesComplete servers configuration map
json
{
  "servers": {
    "filesystem": {
      "command": "bunx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home"]
    }
  }
}

Response

json
{
  "ok": true
}

Errors

StatusCondition
400servers is not a JSON object
400Server config validation failed

GET /api/mcp/status

Returns the runtime status of all connected MCP servers, including tool and resource counts.

Response

json
{
  "ok": true,
  "servers": [
    {
      "name": "filesystem",
      "status": "connected",
      "toolCount": 5,
      "resourceCount": 0
    },
    {
      "name": "brave-search",
      "status": "disconnected",
      "toolCount": 0,
      "resourceCount": 0
    }
  ]
}
FieldTypeDescription
servers[].namestringServer identifier
servers[].statusstringConnection status (connected, disconnected, etc.)
servers[].toolCountnumberNumber of tools provided by this server
servers[].resourceCountnumberNumber of resources provided by this server

Common Error Codes

StatusCodeDescription
400INVALID_REQUESTRequest body is malformed or missing required fields
401UNAUTHORIZEDMissing or invalid authentication token
404NOT_FOUNDRequested resource does not exist
400INVALID_CONFIGMCP server configuration is invalid
404SERVER_NOT_FOUNDMCP server with specified name does not exist
400RESERVED_NAMEAttempted to use a reserved server name
502INTERNAL_ERRORMarketplace or server connection error