Connect OpenClaw to Your Server

This guide shows how to configure OpenClaw to work as an AI robot in your Lag server. OpenClaw connects to Lag’s MCP server and operates a robot on your behalf - when someone @mentions the robot, OpenClaw reads the conversation and responds.

No code required. You create a robot in Lag, connect OpenClaw to the MCP server, and it handles the rest.

What You’ll Get

  • A robot in your server that anyone can @mention
  • OpenClaw reads conversation context and responds as the robot
  • Works through Lag’s MCP - no deployment, no hosting, no code

Prerequisites

  • A Lag server you own
  • An OpenClaw account with MCP support

Step 1: Create the Robot

Go to the Robot Management Portal and select your server.

Click Create Robot and configure it:

FieldValue
NameThe name users will @mention (e.g. openclaw, assistant, claude)
TransportSSE
Permissionsread_messages, send_messages, read_rooms, read_members
Subscribed Eventsrobot.mentioned, room.message

After creation, note the robot ID from the robot details page. You’ll need this when telling OpenClaw which robot to operate. Each robot belongs to one server, so you don’t need the server ID separately.

The robot’s name is what users type after @ in chat. If you name it openclaw, users type @openclaw to interact with it.

Step 2: Connect OpenClaw to Lag MCP

Add the Lag MCP server to your OpenClaw configuration:

{
  "mcpServers": {
    "lag": {
      "url": "https://api.trylag.com/mcp/",
      "transport": "streamable-http"
    }
  }
}

On first connection, OpenClaw will open the Lag authorize page in your browser. If you’re already signed in to Lag, just click Authorize. If not, sign in with Discord or Google first. Once approved, OpenClaw has access to all of Lag’s MCP tools.

Step 3: Configure OpenClaw

Tell OpenClaw how to operate the robot. Add instructions to your OpenClaw system prompt or configuration:

You are connected to a Lag voice chat server. You operate a robot named "[your robot name]".

Robot ID: [your robot ID]

Your workflow:
1. Periodically call `robot_receive_events` to check for new events
2. When you see a `robot.mentioned` event, someone is talking to you
3. Use `robot_get_messages` to read recent conversation for context
4. Use `robot_send_message` to respond in the room

Keep responses concise and conversational - this is a chat room.

Replace the robot ID and robot name with your actual values from Step 1. You don’t need the server ID - each robot belongs to one server and the API resolves it automatically.

Step 4: Test It

Go to any room in your server and type:

@openclaw hello, what can you do?

OpenClaw will pick up the robot.mentioned event on its next poll, read the conversation context, and send a response as the robot. The response appears in chat with a BOT badge.

Available MCP Tools

These are the tools OpenClaw uses to operate the robot:

ToolParametersWhat it does
robot_receive_eventsrobotIdFetch new events (mentions, messages) for the robot
robot_send_messagerobotId, roomId, contentSend a message to a room as the robot
robot_get_messagesrobotId, roomIdRead message history from a room
robot_get_roomsrobotIdList all rooms in the server
robot_get_membersrobotIdList server members

All tools only need the robotId - the server is resolved automatically. OpenClaw authenticates as you (the server owner), so it can operate any robot you own.

See the full MCP documentation for all available tools.

How It Works

  1. You create a robot in Lag with the right permissions and event subscriptions

  2. OpenClaw connects to Lag’s MCP server and authenticates as your user account

  3. Someone @mentions the robot - Lag detects @robotname in the message, resolves it to the robot, and queues a robot.mentioned event

  4. OpenClaw polls for events using robot_receive_events and sees the mention

  5. OpenClaw reads context using robot_get_messages to understand the conversation

  6. OpenClaw responds using robot_send_message - the message appears in chat from the robot with a BOT badge

The robot doesn’t need to be “running” anywhere. Events are queued in Lag until OpenClaw polls for them. As long as OpenClaw is connected to the MCP server and checking for events, mentions get answered.

Tips

  • Robot name matters - Pick something short and easy to type. Users need to type it exactly after @.

  • Event polling frequency - The faster OpenClaw polls robot_receive_events, the quicker responses feel. For near-real-time, poll every few seconds.

  • Multiple rooms - The robot works across all rooms in the server. The roomId in each event tells OpenClaw which room to respond in.

  • Context window - Use robot_get_messages with a reasonable limit (10-20 messages) to give OpenClaw conversation context without overwhelming it.

  • Multiple robots - You can create different robots for different purposes (e.g. one for Q&A, one for moderation). Each has its own name, permissions, and event subscriptions. Configure OpenClaw with multiple robot IDs.

Troubleshooting

Robot doesn’t respond to @mentions

  • Check the robot is subscribed to robot.mentioned in the management portal
  • Verify it has read_messages and send_messages permissions
  • Make sure OpenClaw is actively polling robot_receive_events
  • Check that the robot ID in OpenClaw’s config matches

“Robot not found” errors

  • The robot ID in OpenClaw’s configuration is wrong
  • The robot may have been deleted - check the management portal

Slow responses

  • OpenClaw needs to poll for events - responses aren’t instant. The delay depends on how frequently OpenClaw calls robot_receive_events.
  • If you need real-time responses, consider building a custom robot using the SSE transport instead of MCP polling. See the Examples page for SSE client code.

Permission errors

  • You must be the server owner to operate robots through MCP
  • The robot needs the specific permission for each action (e.g. send_messages to send, read_messages to read history)