# Connect Claude Code to FineProxy MCP

Add the FineProxy MCP server to Claude Code with one CLI command or a shared .mcp.json file, and keep your API key in an environment variable.

- Canonical: https://fineproxy.org/developers/docs/mcp/clients/claude-code/

This page shows how to connect [Claude Code](https://code.claude.com/docs/en/mcp) to the FineProxy MCP server. Claude Code talks to the server directly over HTTP and sends your API key in the `Authorization` header — no bridge or Node.js package is needed.

## Requirements

- Claude Code installed, with `claude` on your `PATH`.
- A FineProxy API key (starts with `fb_`). Create one in [Settings → API keys](https://fineproxy.org/account_new/settings#api-keys). Start with read-only [scopes](/developers/docs/authentication/#scopes).

## Set up

### Choose a scope

Claude Code stores MCP servers in one of three scopes:

| Scope | Where it is stored | Available in |
| --- | --- | --- |
| `local` (default) | `~/.claude.json`, under the current project path | The current project only, for you |
| `user` | `~/.claude.json` | All your projects |
| `project` | `.mcp.json` in the repository root | Everyone who clones the repository |

`~` is your home folder. For personal use, `user` is the most convenient scope.

### Option 1: add the server with the CLI

1. Put your key in an environment variable:

   ```bash
   export FINEPROXY_API_KEY="fb_your_api_key"
   ```

2. Add the server:

   ```bash
   claude mcp add --transport http --scope user fineproxy \
     https://fineproxy.org/account_new/api/v1/mcp \
     --header "Authorization: Bearer $FINEPROXY_API_KEY"
   ```

   The command prints an `Added ...` line on success. Your shell expands `$FINEPROXY_API_KEY` when you run the command: the key value is saved in `~/.claude.json`, while this command in your shell history contains only the variable name.

### Option 2: share the server with your team in .mcp.json

Create `.mcp.json` in the repository root. Remote servers **must** include `"type": "http"`:

```json
{
  "mcpServers": {
    "fineproxy": {
      "type": "http",
      "url": "https://fineproxy.org/account_new/api/v1/mcp",
      "headers": {
        "Authorization": "Bearer ${FINEPROXY_API_KEY}"
      }
    }
  }
}
```

Each teammate sets `FINEPROXY_API_KEY` with their own key before starting `claude`. The first time you run `claude` in the repository, it asks you to approve the project server.

## Keep your key out of the config

- Claude Code expands `${VAR}` and `${VAR:-default}` in `url` and `headers` of `.mcp.json`. Use `${FINEPROXY_API_KEY}` and set the variable in the shell that starts `claude`.
- Use a dedicated variable such as `FINEPROXY_API_KEY`. Claude Code deliberately reads its own and cloud-provider credential variables (for example `ANTHROPIC_API_KEY`) as empty in remote `headers`, so the server would receive `Bearer ` with no key.
- If a `${VAR}` reference points to a variable that is not set, `claude mcp list` and `/mcp` warn about it and the server receives the text unexpanded.

> **Warning:** `.mcp.json` is meant to be committed. Never put a literal `fb_...` key in it — keep only the `${FINEPROXY_API_KEY}` reference.

## Verify the connection

Check the server status from your terminal:

```bash
claude mcp list
claude mcp get fineproxy
```

`claude mcp list` shows a status next to each server, for example `✔ Connected` or `✘ Failed to connect` with the HTTP status. A `.mcp.json` server shows `⏸ Pending approval` until you approve it in an interactive `claude` session.

Inside a session, run `/mcp` to see `fineproxy` with its tool count, then ask:

```text
What is my FineProxy balance?
```

Claude calls the `wallet_balance` tool and answers with your balance. The tool result looks like this:

```json
{
  "balance_cents": 5000,
  "currency": "USD",
  "wallet_id": "00000000-0000-0000-0000-000000000000",
  "has_wallet": true
}
```

Money values are integer cents: `5000` means $50.00.

## Tips

- **Approve tool calls.** Claude Code asks for permission before it uses a tool. Read the arguments of order, renewal and cancellation tools before you allow them, and don't allow money-moving tools permanently.
- **Use a read-only key first.** For exploring, a key with `customer:read`, `wallet:read`, `services:read` and `catalog:read` is enough. Without `wallet:spend`, the agent can't run tools that debit your wallet.
- **Add `wallet:spend` only for purchases.** Create a separate key with `wallet:spend` when you want the agent to buy or renew. Purchase tools carry a price guard and an idempotency key: a wrong total is rejected without a charge, and a retry with the same key never charges twice.
- Read [MCP safety](/developers/docs/mcp/safety/) and the [scopes reference](/developers/docs/authentication/#scopes) before you give an agent spending rights.

## Troubleshooting

| Symptom | Cause and fix |
| --- | --- |
| The server is missing when you work in another folder | It was added with the default `local` scope. Remove it and add it again with `--scope user`, or use `.mcp.json`. |
| The `.mcp.json` server is ignored | The entry has `url` but no `"type": "http"`, so it is treated as an invalid local server. Add the `type` field. |
| `✘ Failed to connect` with `401` | The key is missing, wrong or read as empty. Check that `FINEPROXY_API_KEY` is set in the shell that starts `claude` and that you don't reference an `ANTHROPIC_*` variable. |
| `⏸ Pending approval` | Run `claude` in the repository and approve the project server. |
| Warning about whitespace in `headers.Authorization` | The pasted key has a trailing space or newline. Remove it. |
| `! Needs authentication` / OAuth prompt | The `Authorization` header is missing. FineProxy MCP accepts API keys only; there is no OAuth sign-in. |
| `429 Too Many Requests` | Too many sessions connecting at once. Wait a moment and reconnect from `/mcp`. |

For server-side errors and tool failures, see [MCP troubleshooting](/developers/docs/mcp/troubleshooting/).
