---
title: "Connect Clam to OpenClaw"
description: "Add your Clam Shell to OpenClaw from the terminal, so OpenClaw can work in your Gmail within your rules."
route: /docs/agents/openclaw
---

# Connect Clam to OpenClaw

OpenClaw connects to Clam from the terminal: stop its Gateway, add your Shell, sign in through the link OpenClaw prints, and start the Gateway again. From then on, OpenClaw's email requests follow your Shell's rules.

## Before you start

You need a Clam account with a Shell; the [Quickstart](https://useclam.ai/docs/get-started/quickstart) sets up both. Everything here starts on your Shell's Install tab in the [Clam console](https://console.useclam.ai), under OpenClaw. Copy the commands from there rather than retyping them.

OpenClaw talks to Clam over MCP, the standard way an AI agent plugs into an outside tool: each Shell is an MCP server, and its email tools go through your rules before they reach Gmail.

OpenClaw only saves a server while its Gateway is stopped, so every method here starts with `openclaw gateway stop` and ends with `openclaw gateway start`.

## Connect OpenClaw

Three ways in. Start with the first; the others are for when it doesn't fit.

### Terminal sign-in (Recommended)

The simplest path: OpenClaw prints a sign-in link, so there is no key to handle.

1. Stop the Gateway

   OpenClaw won't save a server while it runs.

   ```bash
   openclaw gateway stop
   ```

2. Paste this in your terminal

   Copy the add command from the Install tab. Then press Enter. OpenClaw checks the connection and saves it.

   ```bash
   openclaw mcp add <server name> --url <your Shell's address> --transport streamable-http --auth oauth
   ```

3. Log in, then sign in to Clam and Allow

   OpenClaw prints a sign-in link. Open it, and Clam asks to connect your Shell to OpenClaw. Click **Allow**.

   ```bash
   openclaw mcp login <server name>
   ```

4. Start the Gateway again

   Your server shows up in the list.

   ```bash
   openclaw gateway start
   openclaw mcp list
   ```

Try a prompt below, then click **Check connection** on the Install tab.

### Access key

For a machine with no browser, like a server you reach over SSH. The key works only for OpenClaw.

1. Stop the Gateway

   OpenClaw won't save a server while it runs.

   ```bash
   openclaw gateway stop
   ```

2. Paste this in your terminal

   Copy the command under **Use a key** on the Install tab. Copying creates the key and fills it in. Then press Enter. OpenClaw checks the connection and saves it. `openclaw mcp doctor` may point out the key sitting in your config. That is expected for a key.

   ```bash
   openclaw mcp add <server name> --url <your Shell's address> --transport streamable-http --header "Authorization: Bearer <your key>"
   ```

3. Start the Gateway again

   Your server shows up in the list.

   ```bash
   openclaw gateway start
   openclaw mcp list
   ```

Try a prompt below, then click **Check connection** on the Install tab.

### openclaw.json file

For anyone who keeps the file by hand. OpenClaw reads its servers from `mcp.servers`. The key works only for OpenClaw.

1. Stop the Gateway

   It loads the new server on start.

   ```bash
   openclaw gateway stop
   ```

2. Merge this block into mcp.servers

   In `~/.openclaw/openclaw.json`. Comments and trailing commas are fine there. Create `mcp` and `servers` if they aren't there yet. Keep `transport` set to `streamable-http`, or OpenClaw falls back to SSE, which Clam doesn't support.

   ```json
   {
     "mcp": {
       "servers": {
         "<server name>": {
           "url": "<your Shell's address>",
           "transport": "streamable-http",
           "headers": { "Authorization": "Bearer <your key>" }
         }
       }
     }
   }
   ```

3. Start the Gateway again

   Your server shows up in the list.

   ```bash
   openclaw gateway start
   openclaw mcp list
   ```

Try a prompt below, then click **Check connection** on the Install tab.

## Try it

With the starter policy from the Quickstart, ask OpenClaw:

Ask "Summarize the work email I got this week." OpenClaw answers from your work email. Ask "Find my latest bank statement." Clam blocks it, and OpenClaw says the action was not allowed. That refusal is Clam working as intended.

If OpenClaw has other mail tools, start with "Use <your Shell's name>". Change what's allowed in [How rules work](https://useclam.ai/docs/policies/how-rules-work).

## Remove access

In OpenClaw, stop the Gateway and run `openclaw mcp unset <server name>`.

The removal that counts is Clam's: on the Shell's Install tab, under Connected agents, choose **Remove access** next to OpenClaw. A key stops working at once; a sign-in stops at OpenClaw's next request. [Remove access](https://useclam.ai/docs/trust/remove-access)

## If it doesn't work

More in [Common issues & solutions](https://useclam.ai/docs/troubleshooting).

### OpenClaw refuses to save the server

The Gateway is still running. Stop it, add Clam again, then start it.

### The add never completes

The `--transport streamable-http` flag is missing. Use the Install tab's command.

Connected? [Write your own rules](https://useclam.ai/docs/policies/writing-effective-policies).
