# Connect VS Code to FineProxy MCP

Use the FineProxy MCP server from GitHub Copilot agent mode in VS Code, with the API key entered through a secure prompt or read from an environment variable.

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

This page shows how to connect GitHub Copilot in VS Code (agent mode) to the FineProxy MCP server. VS Code connects directly over HTTP and sends your API key in the `Authorization` header.

VS Code reads MCP servers from two kinds of files, and they use different formats:

| Configuration | Files | Top-level key | How to pass the key |
| --- | --- | --- | --- |
| **Editor-managed** | `.vscode/mcp.json`, user profile `mcp.json` | `servers` | Secure prompt `${input:...}` or `${env:NAME}` |
| **Copilot (portable)** | `~/.copilot/mcp-config.json`, `.mcp.json` in the workspace root | `mcpServers` | Environment variable `${NAME}` only |

Use the editor-managed configuration unless you share one MCP file between Copilot surfaces.

## Requirements

- VS Code **1.101 or later** (remote HTTP MCP servers) with GitHub Copilot and agent mode available to you.
- 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 | Location |
| --- | --- |
| Workspace (editor-managed) | `.vscode/mcp.json` |
| User profile (editor-managed) | Run **MCP: Open User Configuration** from the Command Palette (the path depends on your profile) |
| Copilot, global | `~/.copilot/mcp-config.json` (or `$COPILOT_HOME/mcp-config.json`) |
| Copilot, workspace | `.mcp.json` in the workspace root |

### Option 1: editor-managed config with a password prompt

1. Open `.vscode/mcp.json` (or your user configuration) and add:

   ```json
   {
     "servers": {
       "fineproxy": {
         "type": "http",
         "url": "https://fineproxy.org/account_new/api/v1/mcp",
         "headers": {
           "Authorization": "Bearer ${input:fineproxy_api_key}"
         }
       }
     },
     "inputs": [
       {
         "type": "promptString",
         "id": "fineproxy_api_key",
         "description": "FineProxy API key (fb_..., without Bearer prefix)",
         "password": true
       }
     ]
   }
   ```

2. Start the server. VS Code asks for the key the first time and stores it securely for later sessions.

> **Note:** Enter the raw key (`fb_...`) at the prompt. The header template already adds `Bearer `.

You can also add the server to your user configuration from a terminal:

```bash
code --add-mcp '{"name":"fineproxy","type":"http","url":"https://fineproxy.org/account_new/api/v1/mcp","headers":{"Authorization":"Bearer ${input:fineproxy_api_key}"}}'
```

The command doesn't create the `inputs` entry. Open the user configuration afterwards and add the `inputs` block from the example above.

### Option 2: Copilot config with an environment variable

Add the server to `~/.copilot/mcp-config.json` or the workspace `.mcp.json`:

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

Set `FINEPROXY_API_KEY` in the environment that starts VS Code. This format doesn't support `${input:...}` prompts, `envFile` or other editor-only fields.

## Keep your key out of the config

- **Editor-managed files:** use `${input:fineproxy_api_key}` (the value goes to VS Code's secret storage after the first prompt) or `${env:FINEPROXY_API_KEY}`.
- **Copilot files:** use `${FINEPROXY_API_KEY}` (`${NAME:-default}` also works). There is no way to forward a prompted secret into an HTTP header from these files.

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

> **Warning:** `.vscode/mcp.json` and `.mcp.json` live in the workspace and are easy to commit. Never put a literal `fb_...` key in them — keep only `${input:...}` or environment variable references.

## Verify the connection

1. Run **MCP: List Servers** from the Command Palette and check that `fineproxy` is running.
2. Open Copilot Chat, switch to **Agent** mode and open the tools picker: the FineProxy tools are listed under `fineproxy`.
3. Ask:

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

   Copilot calls the `wallet_balance` tool and answers with your balance, for example `"balance_cents": 5000` — money values are integer cents, so that is $50.00.

## Tips

- **Approve tool calls.** Copilot asks for confirmation before it runs an MCP tool. Read the arguments of order, renewal and cancellation tools before you continue, and don't auto-approve money-moving tools.
- **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 |
| --- | --- |
| You edit `.mcp.json` but chat doesn't pick up the change | Chat uses the editor-managed `.vscode/mcp.json` (or the other way round). Check which configuration your session uses — see VS Code's [migration guide](https://code.visualstudio.com/docs/agent-customization/migrate-customizations). |
| `${input:...}` is rejected or not resolved | Input prompts work only in editor-managed files. In `.mcp.json` / `mcp-config.json`, use `${FINEPROXY_API_KEY}`. |
| `401` | The prompt received `Bearer fb_...` instead of the raw key (the header becomes `Bearer Bearer ...`), or the environment variable isn't set for VS Code. |
| VS Code offers an OAuth sign-in | The `Authorization` header is missing. FineProxy MCP accepts API keys only. |
| `429 Too Many Requests` | Too many restarts in a short time. Wait a moment and start the server once. |

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