# OpenClaw

> Add Alexein to OpenClaw with one command and sign in, so your agents search your memory and save what they learn.

Your OpenClaw agents search your Alexein memory before they answer, and save what you tell them.

## 1. Add Alexein

**Your own memory**

1. Run this command:

   ```bash title="Terminal"
   npx @alexein/cli connect --only openclaw
   ```

   It adds the `alexein` server to OpenClaw's settings, asks before it changes anything, and offers the sign-in after
   it. To add it yourself instead, see the entry below.
2. Sign in, while OpenClaw's Gateway runs. In a terminal, run:

   ```bash title="Terminal"
   openclaw mcp login alexein
   ```

   Follow the address it prints: Alexein's sign-in opens in your browser. In the Control UI, you can also open
   **Settings › MCP** and select **Sign in** on `alexein`.
3. Sign in, keep **Read and save** so your agents can save, and select **Allow**. There is no key to copy.

By hand, add the `alexein` entry to OpenClaw's settings, under `mcp.servers`, and sign in as above:

```json5 title="~/.openclaw/openclaw.json"
{
  mcp: {
    servers: {
      alexein: {
        url: "https://api.alexein.ai/v1/mcp",
        transport: "streamable-http",
        auth: "oauth",
      },
    },
  },
}
```

OpenClaw gives its agents the start of the instructions Alexein sends (it keeps the first 2,000 characters), so
they know to search first. To disconnect,
run `openclaw mcp unset alexein`, or select **Disconnect** on it in
[My memory › AI assistants](https://memory.alexein.ai/memory/assistants).

### Or with a key

Where nobody is there to sign in, use a personal key instead.

1. Open [My memory › Personal keys](https://memory.alexein.ai/memory/keys) and select **Create key**. Label it `OpenClaw`,
   choose **Read and write** so your agents can save, and copy the key. It is shown once.
2. Set the key in the environment OpenClaw starts from:

```bash title="Terminal"
export ALEXEIN_API_KEY="ax_..."
```

3. Add the `alexein` entry with the key's headers, in place of `auth`:

```json5 title="~/.openclaw/openclaw.json"
{
  mcp: {
    servers: {
      alexein: {
        url: "https://api.alexein.ai/v1/mcp",
        transport: "streamable-http",
        headers: {
          Authorization: "Bearer ${ALEXEIN_API_KEY}",
          "X-Alexein-User": "me",
        },
      },
    },
  },
}
```

OpenClaw fills in `${ALEXEIN_API_KEY}` from the environment
([environment variables](https://docs.openclaw.ai/gateway/configuration/environment-variables)), so the key is not
written into the file. `X-Alexein-User: me` names your own memory.
**App user**

This tab is for the [Console](/developer-platform), at app.alexein.ai, not My memory. To give OpenClaw the memory of one
user of an app you build on Alexein, use an API key from the Console's [API keys](https://app.alexein.ai/console/keys) page, and name the [app user](/concepts/app-users).
Set the key in the environment OpenClaw starts from, as `export ALEXEIN_API_KEY="ax_..."`, and add:

```json5 title="~/.openclaw/openclaw.json"
{
  mcp: {
    servers: {
      alexein: {
        url: "https://api.alexein.ai/v1/mcp",
        transport: "streamable-http",
        headers: {
          Authorization: "Bearer ${ALEXEIN_API_KEY}",
          "X-Alexein-User": "user_42",
        },
      },
    },
  },
}
```

To see what it saved, open the app user under [App users](https://app.alexein.ai/console/users).

## 2. Check it works

1. Run `openclaw mcp doctor alexein --probe`. It shows that `alexein` answers, with its tools.
2. Ask an agent: "What do you remember about me?" It calls `memory_search`.
3. Tell it something new about you. Then open [My memory](https://memory.alexein.ai/memory): it is
   there within a few minutes.

## Troubleshooting

- **`authentication refused (401)`.** Run `openclaw mcp login alexein` again, while the Gateway runs. With a key:
  check `ALEXEIN_API_KEY` is set where OpenClaw starts, with the key copied whole.
- **The tools do not reach an agent that is running.** A Gateway or agent running elsewhere needs its own reload:
  run `openclaw mcp reload` there, or restart it.
- **`memory_add` is missing.** You chose **Read only** when you signed in, or the key is **Read**. Sign in again
  with **Read and save**, or create a **Read and write** key.

More in [Troubleshooting](/mcp/troubleshooting).

