# Connect n8n to FineProxy MCP

Give an n8n AI Agent the FineProxy tools with the MCP Client Tool node, a Bearer Auth credential and the HTTP Streamable transport.

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

This page shows how to use the FineProxy MCP server from an n8n workflow. The **MCP Client Tool** node connects to the server and exposes its tools to an **AI Agent** node, which decides when to call them.

## Requirements

- n8n **1.104.0 or later** — the version that added the HTTP Streamable transport to the MCP Client Tool node.
- An AI Agent workflow with a chat model sub-node (any model the AI Agent node supports).
- 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

There is no config file: the server settings live in the node, and the key lives in an n8n credential.

### 1. Create the credential

1. In n8n, create a new credential of type **Bearer Auth**.
2. In the token field, paste the **raw** key: `fb_your_api_key`. Do **not** type `Bearer ` — n8n adds the prefix itself.
3. Save the credential with a clear name, for example `FineProxy read-only`.

If you prefer a generic header credential, use **Header Auth** with name `Authorization` and value `Bearer fb_your_api_key` (here the value includes `Bearer `).

### 2. Add the MCP Client Tool node

Open your AI Agent node, click **+** under **Tool** and add **MCP Client Tool**. Set its parameters:

| Parameter | Value |
| --- | --- |
| Endpoint | `https://fineproxy.org/account_new/api/v1/mcp` |
| Server Transport | **HTTP Streamable** |
| Authentication | **Bearer Auth**, then select the credential from step 1 |
| Tools to Include | **Selected** with the tools you need, or **All** (see [Tips](#tips)) |

> **Note:** If the node shows only an **SSE Endpoint** field and no transport choice, your n8n is older than 1.104.0. The FineProxy server speaks Streamable HTTP, so update n8n first.

### Example workflow

A minimal "proxy assistant" workflow has four nodes:

1. **When chat message received** (Chat Trigger) — gives you a chat window to talk to the agent.
2. **AI Agent** — the agent itself. In its system message, describe the job, for example: "You help manage FineProxy proxies. Before any purchase, quote the order and ask the user to confirm the total."
3. **Chat model** sub-node connected to the AI Agent's **Chat Model** input.
4. **MCP Client Tool** sub-node connected to the AI Agent's **Tool** input, configured as above, with **Tools to Include** set to **Selected**: `wallet_balance`, `list_countries`, `quote_composite`.

With this setup the agent can check the balance, list countries with available IPs and quote orders, but it cannot buy anything. Add `order_composite` to the selected tools (and `wallet:spend` to the key) only when you want the workflow to place orders.

## Keep your key out of the config

- Store the key only in an n8n credential. The workflow refers to the credential; the key itself is not part of the workflow JSON.
- Restrict who can use and edit the credential and the workflow in n8n.
- Before you share or export a workflow, check that no key was pasted into a node field or the system message.

## Verify the connection

1. Open the chat of the Chat Trigger and send:

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

2. The execution log shows the AI Agent calling the MCP Client Tool with the `wallet_balance` tool. The tool returns:

   ```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.

To rule out n8n settings, test the endpoint and key from a terminal with the MCP Inspector:

```bash
npx -y @modelcontextprotocol/inspector --cli \
  https://fineproxy.org/account_new/api/v1/mcp \
  --transport http \
  --header "Authorization: Bearer $FINEPROXY_API_KEY" \
  --method tools/call \
  --tool-name wallet_balance
```

## Tips

- **There is no approval step.** Unlike chat-based IDE agents, an n8n AI Agent runs tools without asking. Use **Tools to Include → Selected** (or **All Except**) to expose only what the workflow needs, and keep spending tools out unless the workflow is meant to buy.
- **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.** Use a separate credential with a `wallet:spend` key for purchasing workflows. 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 |
| --- | --- |
| `401` with a Bearer Auth credential | The token field contains `Bearer fb_...`, so n8n sends `Bearer Bearer fb_...`. Paste only the raw key. |
| Connection fails although the endpoint is right | Check that **Server Transport** is **HTTP Streamable**. On some builds the setting doesn't stick — select it again and save the node. |
| Only an **SSE Endpoint** field is shown | n8n is older than 1.104.0. Update n8n. |
| The agent picks the wrong tools or too many | Narrow **Tools to Include** and describe the task more precisely in the AI Agent's system message. |
| `429 Too Many Requests` | Many executions started at the same moment. Space out runs or limit concurrency. |

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