# Connect Claude Code

Claude Code connects to a gateway as an HTTP MCP server, added with one command. A person signs in with a gateway user. A headless run, such as a CI job, sends an API key.

## Before you begin

- A gateway that serves at least one API. See [Create a gateway](https://docs.faustine.ai/agent-gateway/create-a-gateway/).
- A [gateway user](https://docs.faustine.ai/agent-gateway/gateway-users/) or an [API key](https://docs.faustine.ai/agent-gateway/api-keys/) in the environment you connect to.
- Claude Code installed. See [Connect Claude Code to tools via MCP](https://docs.claude.com/en/docs/claude-code/mcp) in the Claude Code docs.

The commands on this page are in the gateway's **Connect** tab, under **Claude Code**, with your gateway's values filled in.

## Add the gateway

**Gateway user**

Register the server. `<gateway>` is the name Claude Code shows for it. The portal uses the gateway's slug.

```bash
claude mcp add --transport http <gateway> https://gateway.faustine.ai/<workspace>/<gateway>/mcp
```

Then sign in:

1. In Claude Code, run `/mcp`.
2. Select the gateway, then **Authenticate**. A browser window opens on the gateway's sign-in page.
3. Enter the username and password of the gateway user.

**API key**

Register the server with the key in a header. Replace `<GATEWAY_KEY>` with the key you saved when you created it.

```bash
claude mcp add --transport http <gateway> https://gateway.faustine.ai/<workspace>/<gateway>/mcp --header "Authorization: Bearer <GATEWAY_KEY>"
```

## Make the first call

Ask Claude Code what it can do with the gateway, or ask for something the API returns, such as a list of contacts.

In the portal, the request appears in the gateway's **Logs** tab, and the **Claude Code** card in the **Connect** tab shows when the client was last seen.

For an operation that requires confirmation, Claude Code asks in a dialog when the credential is set to **Ask the person**. A gateway user created in the **Access** tab and an API key both start on **Refuse**. See [Confirmation](https://docs.faustine.ai/agent-gateway/confirmation/).

## Give Claude Code the gateway's skill file

A gateway also serves a `SKILL.md` that tells an agent what the gateway is and how to call it. To add it to a project:

```bash
curl -o .claude/skills/<gateway>/SKILL.md --create-dirs https://gateway.faustine.ai/<workspace>/<gateway>/skill.md
```

## Next steps

- [Scope a key or user](https://docs.faustine.ai/agent-gateway/scope-a-credential/): limit what Claude Code can call.
- [Serving modes: Code and Tools](https://docs.faustine.ai/agent-gateway/serving-modes/): which tools the gateway gives Claude Code.
- [Faustine CLI](https://docs.faustine.ai/apps/cli/): call operations from a shell without MCP.
