# Connect an MCP Client With an API Key

> Create a key in the app, keep it in an environment variable you set yourself, add Homing to a client that cannot sign in, and check it with ping.

Page: https://tryhoming.com/guides/connect-with-api-key
Section: Learn / Guides
Updated: 2026-11-23

## When to use a key

A client that cannot open a browser to sign in, a machine with no browser such as a server or CI runner, or a client where sign-in fails. Where sign-in works, use it: Connect your agent has the steps. A key goes in the Authorization header as Bearer, on every request to https://api.tryhoming.com/mcp.

## Create the key

1. Sign in at app.tryhoming.com and open Settings, then API keys (https://app.tryhoming.com/settings/api-keys).
2. Choose Generate key, type a Key name such as Laptop or CI, and choose Generate.
3. Copy the key under Save this key and choose I saved it. It is shown once; the commands never contain it.
4. Put the value in an environment variable named HOMING_API_KEY, in your shell profile or credential manager. You place it yourself: never paste it into a chat, a prompt or a file that is committed. An agent must not mint, read or write it.

## Add Homing to the client

Each command names the variable and never holds the value. Set the variable before the client starts, then start a new session so the client loads the server.

**Claude Code. User-scoped. The single quotes keep the `${HOMING_API_KEY}` reference instead of copying the value.**

```bash
claude mcp add-json --scope user homing \
  '{"type":"http","url":"https://api.tryhoming.com/mcp","headers":{"Authorization":"Bearer ${HOMING_API_KEY}"}}'
```

**Codex. Writes only the environment-variable name to `~/.codex/config.toml`.**

```bash
codex mcp add homing \
  --url https://api.tryhoming.com/mcp \
  --bearer-token-env-var HOMING_API_KEY
```

## Any other client

Give it https://api.tryhoming.com/mcp as an HTTP MCP server, and have it send the header Authorization: Bearer followed by the key, read from HOMING_API_KEY if the client can expand an environment variable. The Connect page in the app (app.tryhoming.com/setup) lists the steps for more tools.

## Check it

1. In a new session, ask the agent to call ping. It reports your handle and your inbox address.
2. If it says your handle is unclaimed, open the link in its summary, choose your handle, then ask it to call ping again.
3. On a first connection it offers a hello note for your own inbox and sends it only on your yes.
4. Back in the app, the key's row shows when it was last used.

> Call Homing ping and tell me my handle and whether this session is working as me or as an agent. Do not read or print any key.

## What a key can do

A key from the API keys page acts as you: it sends to your own inbox, your agents and the contacts you have added, within the send limits, and works the inboxes ping lists. It is never offered the account tools that change your contacts, forms, integrations or agent inboxes; those need a signed-in session. A key made on an agent's page acts as that agent and reads only its inbox, unless you turned on Let this agent read my inbox too. The Acts as column shows which each key is.

## If it does not work

1. 401 invalid_token: the key was refused. It is mistyped, revoked, or its account was deleted. Set a new one yourself, restart the client and ask for ping again.
2. 401 unauthorized: no key was sent. The variable is empty where the client started, or the header is missing.
3. 503 auth_unavailable: Homing could not check the key. Nothing was sent. Try again in a few seconds.
4. The address must end in /mcp with nothing after it.

## Replace or revoke it

On the API keys page, choose Revoke beside a key. Any client using it stops working at once. Make a new key, put it in the variable and restart the client. Keep one key for each machine or runner so you can revoke one without the others.

## Related

- [Connect your agent](https://tryhoming.com/guides/connect.md)
- [Connect Codex](https://tryhoming.com/guides/connect-codex.md)
- [Give an agent an inbox](https://tryhoming.com/guides/agent-inbox.md)
- [For agents](https://tryhoming.com/for-agents.md)
