# Connect CLI & editor clients (API key)

Customermates is the source-available, AI-native CRM. Once connected, your coding agent reads and writes contacts, deals, and notes without leaving the terminal. Every client here authenticates the same way: an API key in the `x-api-key` header against `<BASE_URL>/api/v1/mcp`, where `<BASE_URL>` is the address you open Customermates at, in the cloud or on your own instance. The snippets below already carry the address of the site showing this page; if you open Customermates elsewhere, replace that address as well as `YOUR_KEY`.

> Using Claude's or ChatGPT's **app** instead? Those connect with [the custom connector](/docs/connect-custom-connector) (OAuth, no key).

## Create an API key

In Customermates, open [API keys & connectors](https://customermates.com/dashboard?open=%2Fsettings%2Fconnections), click [Add](https://customermates.com/dashboard?open=%2Fsettings%2Fconnections%3Ffocus%3Dcontrol%253Asettings-api-keys-generate) and choose **Standard API key**. Name it for the client (for example `Claude Code`); without an **Expires in** date it never expires. The 64-character key is shown once, so copy it immediately. **Quick connections** in the same dialog does this for you: it names the key after the client, sets it to expire after 365 days, and shows the setup snippet with the key filled in and its expiry below.

Creating a key needs **Create** on the **API & Webhooks** row of your role, and the page itself needs **Read access** **All** on that row; the built-in **Admin** role has both. A key inherits the permissions of the user who created it; there is no per-key scoping. Create one key per client so you can revoke one without touching the others; the activity log records the user a key belongs to, not the key itself. API keys and MCP work on every plan and on self-hosted instances. Details: [API keys](/docs/api-keys).

## Claude Code

Claude Code adds MCP servers via its CLI. One command does the setup. Run this in any terminal, replacing `YOUR_KEY`:

```
claude mcp add --transport http customermates https://customermates.com/api/v1/mcp \
  --header "x-api-key: YOUR_KEY"
```

There is no restart or config-file edit. Claude Code connects automatically. Run `claude mcp list` to confirm `customermates` shows up.

**Scope:** the command defaults to local scope. Add `--scope user` to make Customermates available everywhere on your machine, or `--scope project` to write it to a repo's `.mcp.json` so teammates pick it up.

## Codex

Codex connects directly to Customermates over Streamable HTTP. `codex mcp add customermates --url <BASE_URL>/api/v1/mcp` adds the server URL, but the CLI command has no option for a custom `x-api-key` header. For API-key access, open `~/.codex/config.toml` (create it if missing) and add the complete block below, replacing `YOUR_KEY`:

```
[mcp_servers.customermates]
enabled = true
url = "https://customermates.com/api/v1/mcp"
http_headers = { "x-api-key" = "YOUR_KEY" }
```

To pull the key from your environment instead of storing it in the file, replace the `http_headers` line of the block above with:

```toml
env_http_headers = { "x-api-key" = "CUSTOMERMATES_API_KEY" }
```

Then export `CUSTOMERMATES_API_KEY` in your shell profile. New sessions pick the server up, so end the current one and start fresh.

The same HTTP endpoint also accepts OAuth. If you prefer to sign in, add the URL with `codex mcp add customermates --url <BASE_URL>/api/v1/mcp`, then run `codex mcp login customermates`. The stdio bridge described below is for Claude Desktop clients that need one.

## Cursor

For the Cursor setup, open **Settings → Tools & MCP → Add new MCP server** and paste this, replacing `YOUR_KEY`:

```
{
  "customermates": {
    "url": "https://customermates.com/api/v1/mcp",
    "headers": {
      "x-api-key": "YOUR_KEY"
    }
  }
}
```

Cursor hot-reloads, so no restart is needed. The tools appear in Composer right away. To edit the file directly, the same block goes in `~/.cursor/mcp.json` (global) or `<project>/.cursor/mcp.json` (per-project), wrapped under `mcpServers`.

## Gemini CLI

The Gemini CLI loads MCP servers from `~/.gemini/settings.json`. Merge this in, replacing `YOUR_KEY`:

```
{
  "mcpServers": {
    "customermates": {
      "httpUrl": "https://customermates.com/api/v1/mcp",
      "headers": {
        "x-api-key": "YOUR_KEY"
      }
    }
  }
}
```

If `mcpServers` already has entries, add `customermates` alongside the existing ones rather than overwriting the object.

## Claude Desktop (config file)

The recommended path for Claude Desktop is the [connector path](/docs/connect-custom-connector#claude): OAuth, no key, synced across your devices. On a free plan, or if you prefer a static key, the config file below works too.

Open **Claude → Settings → Developer → Edit Config**, or the file directly:

- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`

Merge this in, replacing `YOUR_KEY`:

```
{
  "mcpServers": {
    "customermates": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://customermates.com/api/v1/mcp",
        "--header",
        "x-api-key:YOUR_KEY"
      ]
    }
  }
}
```

`mcp-remote` is a shim that lets Claude Desktop talk to a remote HTTP MCP server over stdio. It downloads on first run via `npx`, so you need Node 18+ on `PATH`.

Then restart: fully quit (⌘Q on macOS, not just close the window) and reopen. Customermates appears in the tools panel with the CRM tools listed.

## Try your first prompt

The server provides connection instructions describing its tool surface, safety rules, and how to retrieve relevant Knowledge Base pages. Clients decide whether to pass those instructions to their agent. If yours does not, add the Knowledge Base retrieval rule to that client's persistent instructions. In clients that support MCP prompts (like Claude Code), you can run the built-in `get-started` prompt for a guided kickoff: it reads your workspace and relevant Knowledge Base pages first, then asks only for missing information.

- _"Set the Acme deal's Status field to 'Won' and add a note that the contract was signed today."_
- _"Pull the last ten contacts I created. Any without an email address?"_
- _"Create a contact for Jane Doe at Initech, link it to the Initech organization, and start a deal for 12 hours of consulting."_
- _"Which client conversations are waiting for my reply? Draft an answer to the oldest one and save it as a draft."_

The reply prompt needs a channel connected on Customermates Cloud from Pro; the draft waits in the conversation until you review and send it.

Each workspace defines its own record types, such as contacts, deals or tasks, and attributes such as a deal's stage or a task's priority depend on the workspace configuration too. Call `discover_record_types` and then `get_record_model` for the relevant type IDs before writing.

## Troubleshooting

| Client         | Symptom                                                                                                     | Cause                                                                                                                                                                                                                                                                                                         | Fix                                                                                                                                              |
| -------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| Claude Desktop | `npx: command not found`                                                                                    | No Node on `PATH`                                                                                                                                                                                                                                                                                             | Install Node 18+ from [nodejs.org](https://nodejs.org/en)                                                                                        |
| Claude Desktop | Tools panel empty after a config edit                                                                       | Claude Desktop does not hot-reload MCP configs                                                                                                                                                                                                                                                                | Fully quit (⌘Q) and reopen                                                                                                                       |
| Codex          | TOML parse error                                                                                            | Inline-table values use `=`, not `:`                                                                                                                                                                                                                                                                          | Check the `env_http_headers = { ... }` line                                                                                                      |
| All            | The client cannot connect or lists no tools; the server answers HTTP `401`                                  | The key is wrong or truncated, or a key that worked has expired (keys from **Quick connections** expire after 365 days) or was deleted. The server checks the `x-api-key` header on every request and answers `401` with a `WWW-Authenticate` header before it lists any tool, documentation lookups included | Create a new key under [API keys & connectors](https://customermates.com/dashboard?open=%2Fsettings%2Fconnections), paste the full 64 characters, and update the client                                    |
| All            | A connection that worked now fails with "Your user account is inactive. Contact a workspace administrator." | The key's owner was set to **Inactive**                                                                                                                                                                                                                                                                       | A member with **Edit** on **Users & Roles** sets them back to **Active** under [Members](https://customermates.com/dashboard?open=%2Fsettings%2Fmembers), and the existing key works again |
| All            | Relationship update rejected                                                                                | A relationship ID or endpoint is missing or inaccessible                                                                                                                                                                                                                                                      | Ask the agent to read `get_record_model`, then use `mutate_crm_record` with `link` or `unlink` and stable record references                      |

## Next

- [Custom connector](/docs/connect-custom-connector): the OAuth path for Claude and ChatGPT apps.
- [MCP tool catalog](/docs/mcp#tool-catalog): every tool the agent can call.
- [Webhooks](/docs/webhooks): subscribe other systems to CRM changes.
