Delx
OpenClaw / MCP integration

OpenClaw MCP Integration: Complete Tool Discovery & Session Guide

Connect OpenClaw to any MCP-compliant server in four steps. This guide covers endpoint configuration, tool discovery, schema validation, session continuity, and DELX_META handling with copy-paste JSON-RPC examples you can use immediately.

OpenClaw + MCP architecture overview

OpenClaw communicates with MCP servers using JSON-RPC 2.0 over Streamable HTTP. Every tool call follows the same lifecycle: the agent discovers available tools, validates parameters against the published schema, sends the call, and parses the structured response including any DELX_META metadata.

Step 1: Configure the MCP endpoint

Point your OpenClaw agent at the MCP server by setting the endpoint URL and authentication headers. The config accepts any MCP-compliant server, not just Delx.

{
  "mcp": {
    "endpoint": "https://api.delx.ai/api/v1/mcp",
    "headers": {
      "Authorization": "Bearer YOUR_API_KEY",
      "x-delx-session-id": "session_abc123"
    },
    "timeout_ms": 15000
  }
}

Step 2: Discover available tools

Before making any tool call, use tools/list to enumerate every tool the server exposes. The response includes tool names, descriptions, and full JSON Schema definitions for each input.

// Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/list",
  "params": {}
}

// Response
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "tools": [
      {
        "name": "session-recap",
        "description": "Returns the current session state including health score and risk level.",
        "inputSchema": {
          "type": "object",
          "properties": {
            "session_id": { "type": "string" }
          },
          "required": ["session_id"]
        }
      },
      {
        "name": "recovery-start",
        "description": "Initiates a structured recovery loop for a degraded agent.",
        "inputSchema": {
          "type": "object",
          "properties": {
            "session_id": { "type": "string" },
            "incident_type": { "type": "string" }
          },
          "required": ["session_id", "incident_type"]
        }
      }
    ]
  }
}

Cache the tool list at agent startup. Re-fetch only when you receive a schema validation error or after a server version change.

Step 3: Make your first tool call

Use tools/call to invoke a specific tool. Include the session ID header to maintain continuity across requests.

// Request
POST /api/v1/mcp HTTP/1.1
Authorization: Bearer YOUR_API_KEY
x-delx-session-id: session_abc123
Content-Type: application/json

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "session-recap",
    "arguments": {
      "session_id": "session_abc123"
    }
  }
}

// Response
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "Session active. Score: 92. No incidents."
      }
    ],
    "DELX_META": {
      "session_id": "session_abc123",
      "score": 92,
      "risk_level": "low"
    }
  }
}

Step 4: Handle DELX_META in responses

Every Delx MCP response includes a DELX_META object alongside the standard content array. Parse these fields to drive agent behavior:

// Parsing DELX_META in your agent
const response = await fetch(MCP_ENDPOINT, { method: "POST", headers, body });
const json = await response.json();

const meta = json.result?.DELX_META;
if (meta) {
  agent.sessionId = meta.session_id;
  agent.healthScore = meta.score;

  if (meta.risk_level === "high") {
    agent.escalateHeartbeat();
  }
}

Schema validation

OpenClaw validates every tool call against the schema returned by tools/list before sending the request. This prevents malformed payloads from reaching the server and surfaces errors locally with clear messages.

If validation fails, OpenClaw returns a structured error with the field name, expected type, and received value. No network request is made.

Session continuity across MCP calls

Session continuity ensures the MCP server maintains state between operations. Without it, every call is stateless and the server cannot track agent history, scores, or incident context.

// Persist session ID across calls
let sessionId = loadFromStorage("delx_session_id");

const headers = {
  "Authorization": "Bearer YOUR_API_KEY",
  "Content-Type": "application/json",
  ...(sessionId && { "x-delx-session-id": sessionId })
};

const res = await mcpCall("session-recap", { session_id: sessionId });
sessionId = res.DELX_META?.session_id ?? sessionId;
saveToStorage("delx_session_id", sessionId);

Copy-paste JSON-RPC examples

Three ready-to-use examples. Replace YOUR_API_KEY and session_abc123 with your actual values.

Example 1: tools/list — discover available tools

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

Example 2: tools/call — invoke session-recap

curl -X POST https://api.delx.ai/api/v1/mcp \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-delx-session-id: session_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "session-recap",
      "arguments": {
        "session_id": "session_abc123"
      }
    }
  }'

Example 3: tools/call — start recovery

curl -X POST https://api.delx.ai/api/v1/mcp \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-delx-session-id: session_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
      "name": "recovery-start",
      "arguments": {
        "session_id": "session_abc123",
        "incident_type": "degraded_performance"
      }
    }
  }'

Troubleshooting MCP connection issues

FAQ

What MCP servers can OpenClaw connect to?

Any MCP-compliant server including Delx, filesystem, GitHub, and databases. OpenClaw uses standard JSON-RPC 2.0 over Streamable HTTP, so any server that implements the MCP specification works out of the box.

Does OpenClaw validate MCP tool schemas?

Yes, OpenClaw validates input schemas before every tool call, preventing malformed payloads and reducing runtime errors. Schema mismatches are caught before the request leaves the agent.

How does session continuity work with MCP?

Include x-delx-session-id in every request header. OpenClaw persists this across calls so the server maintains state between operations. Use the session-recap endpoint to restore context after restarts.

Can I use multiple MCP servers with one OpenClaw agent?

Yes. Configure multiple endpoint entries and OpenClaw routes tool calls to the correct server based on tool name prefix or namespace. Each server maintains its own session independently.

Is MCP integration free?

Yes. MCP tool discovery and calls are free during campaign mode. Heartbeat monitoring is permanently free. Only recovery interventions use x402 micropayments.

Related