# Connect Gemini CLI to FineProxy MCP

Add the FineProxy MCP server to Gemini CLI with httpUrl and an Authorization header that reads the API key from an environment variable.

- Canonical: https://fineproxy.org/developers/docs/mcp/clients/gemini-cli/

This page shows how to connect [Gemini CLI](https://geminicli.com/docs/tools/mcp-server/) to the FineProxy MCP server. Gemini CLI connects directly over Streamable HTTP and sends your API key in the `Authorization` header.

## Requirements

- Gemini CLI, `gemini` 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

### Where the config lives

| Scope | Path |
| --- | --- |
| User | `~/.gemini/settings.json` |
| Project | `.gemini/settings.json` in the project folder |

`~` is your home folder.

### 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 to your user settings:

   ```bash
   gemini mcp add --transport http --scope user \
     -H 'Authorization: Bearer $FINEPROXY_API_KEY' \
     fineproxy https://fineproxy.org/account_new/api/v1/mcp
   ```

   The single quotes keep `$FINEPROXY_API_KEY` as a reference in `settings.json`; Gemini CLI resolves it when it loads the settings. With double quotes, your shell would write the key value itself into the file.

> **Important:** The default scope of `gemini mcp add` is `project`, which writes `.gemini/settings.json` inside the current folder. Pass `--scope user` unless you really want a project entry.

### Option 2: edit settings.json

Add the `fineproxy` entry under `mcpServers`:

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

Use `httpUrl` for Streamable HTTP. The `url` field is for SSE servers.

## Keep your key out of the config

- Gemini CLI resolves `$VAR_NAME`, `${VAR_NAME}` and `${VAR_NAME:-default}` in string values of `settings.json` when it loads the settings, so `headers` can reference `FINEPROXY_API_KEY` instead of holding the key.
- A variable that isn't set resolves to an empty string, and the server then answers `401`.

> **Warning:** `.gemini/settings.json` in a project folder is easy to commit. Keep only variable references in it, never a literal `fb_...` key.

## Verify the connection

Check the connection from your shell:

```bash
gemini mcp list
```

A working entry shows `fineproxy: https://fineproxy.org/account_new/api/v1/mcp (http) - Connected`. In an interactive session, run `/mcp` to see the server status and its tools, then ask:

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

Gemini CLI asks you to confirm the `wallet_balance` tool call, runs it and answers with your balance, for example `"balance_cents": 5000` — money values are integer cents, so that is $50.00.

## Tips

- **Approve tool calls.** Gemini CLI asks for confirmation before each tool call. Don't set `"trust": true` for the FineProxy server and don't add it with `--trust`: both skip all confirmations, including for purchases.
- **Expose only what you need.** `includeTools` and `excludeTools` in the server entry limit which FineProxy tools the model can see.
- **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 Gemini CLI 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 |
| --- | --- |
| Connection errors with a correct URL | The entry uses `url` (SSE) instead of `httpUrl`. Rename the field. |
| `401` | `FINEPROXY_API_KEY` isn't set in the shell that starts `gemini`, so the header becomes `Bearer ` with no key. |
| The server is only available in one folder | It was added with the default `project` scope. Remove it with `gemini mcp remove --scope project fineproxy` and add it again with `--scope user`. |
| "MCP issues detected" at startup | Run `/mcp list` or `gemini mcp list` to see the connection error. |
| `429 Too Many Requests` | Too many sessions connecting at once. Wait a moment and start again. |

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