# MCP protocol details

Endpoint, headers, transport, versions, message examples, error model and minimal Python and Node.js clients for engineers integrating with the FineProxy MCP server directly.

- Canonical: https://fineproxy.org/developers/docs/mcp/protocol/

This page is for engineers who build their own MCP client or call the server from code. It describes exactly how the FineProxy MCP server behaves on the wire. If you only want to connect an existing client, see the [MCP quickstart](/developers/docs/mcp/quickstart/).

## Endpoint and headers

| Item | Value |
| --- | --- |
| URL | `https://fineproxy.org/account_new/api/v1/mcp` |
| Method | `POST` only. `GET` and `DELETE` return `405` with `Allow: POST`. |
| `Authorization` | `Bearer fb_...`, required on **every** request, including notifications |
| `Content-Type` | `application/json` |
| `Accept` | `application/json, text/event-stream` (recommended; the server replies with JSON either way) |
| Message format | One JSON-RPC 2.0 message per request |

Every response carries `x-request-id` and the rate-limit headers `x-ratelimit-limit`, `x-ratelimit-remaining` and `x-ratelimit-reset` (unix time). See [Rate limits](/developers/docs/rate-limits/).

## Transport

The server implements the MCP **Streamable HTTP** transport in its stateless form:

- Each request is independent. The server sends no `Mcp-Session-Id` header and expects none.
- Responses are always a single `application/json` body. The server never opens an SSE stream, even if `Accept` lists only `text/event-stream`.
- Notifications (`notifications/initialized`) are accepted with `202 Accepted` and an empty body.
- Because no session state is kept, `tools/call` works without a prior `initialize`. Call `initialize` anyway, once per client session, to negotiate the version and read the server `instructions`.
- You can reuse HTTP connections (keep-alive) freely.

## Protocol versions

| Client sends `protocolVersion` | Server answers |
| --- | --- |
| `2025-06-18` | `2025-06-18` |
| `2025-03-26` | `2025-03-26` |
| `2024-11-05` | `2024-11-05` |
| Any other value | `2025-06-18` |

## Capabilities

| Feature | Supported |
| --- | --- |
| `tools/list`, `tools/call` | Yes. 57 tools, returned in one page (no `nextCursor`). |
| `ping` | Yes, returns `{}` |
| `tools.listChanged` notifications | No (`listChanged: false`). The tool list changes only with server releases. |
| `resources/*`, `prompts/*` | No. These methods return JSON-RPC error `-32601`. |
| JSON-RPC batches (arrays) | No. A batch returns `-32600`; send one message per request. |
| SSE streaming, sessions, resumability | No |
| OAuth | No. Use an API key in the `Authorization` header. |

## Initialize

```bash
curl -sS -X POST "https://fineproxy.org/account_new/api/v1/mcp" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"my-client","version":"1.0"}}}'
```

Response (`instructions` shortened):

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "protocolVersion": "2025-06-18",
    "capabilities": {
      "tools": { "listChanged": false }
    },
    "serverInfo": { "name": "...", "version": "2.0.0" },
    "instructions": "... All money amounts are integer cents.\n\n## Buying proxies (composite multi-country constructor)\n1. list_countries — discover available countries with live IP stock ...\n2. quote_composite — price a mix of {country, count} segments ...\n3. order_composite — purchase: pass the same segments, whitelist_ips ..., a fresh idempotency_key, and the quote's total_price_cents as expected_total_cents. ..."
  }
}
```

The `instructions` text explains the buying flow, service management, diagnostics, billing and the rules for money and destructive tools. Pass it to the model as system context: it is what makes agents quote before buying and confirm before cancelling. Then send the notification:

```bash
curl -sS -X POST "https://fineproxy.org/account_new/api/v1/mcp" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"notifications/initialized"}'
```

The server answers `202` with an empty body.

## List tools

```bash
curl -sS -X POST "https://fineproxy.org/account_new/api/v1/mcp" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","method":"tools/list","id":2}'
```

Each tool has `name`, `description`, `inputSchema` (JSON Schema, `additionalProperties: false`) and `annotations`:

```json
{
  "name": "wallet_balance",
  "description": "Get the prepaid wallet balance of the account (integer cents + currency). [requires scopes: wallet:read]",
  "inputSchema": {
    "type": "object",
    "properties": {},
    "additionalProperties": false
  },
  "annotations": {
    "readOnlyHint": true,
    "destructiveHint": false,
    "idempotentHint": false
  }
}
```

What to watch:

- The required scopes are at the end of each `description` in the form `[requires scopes: ...]`.
- `annotations` contain `readOnlyHint`, `destructiveHint` and `idempotentHint`; `openWorldHint` is not set. Several state-changing tools (for example `set_auto_renew`, `rotate_proxy_credentials`, `add_whitelist_ip`, `create_ticket`) carry `readOnlyHint: true`, so don't build auto-approval on annotations. Use an explicit allowlist of tool names; see [Safety for AI agents](/developers/docs/mcp/safety/#prompt-injection).
- All tools with their full schemas are in the [MCP tools reference](/developers/docs/mcp/tools/).

## Call a tool

```bash
curl -sS -X POST "https://fineproxy.org/account_new/api/v1/mcp" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","method":"tools/call","id":3,"params":{"name":"quote_composite","arguments":{"segments":[{"country":"DE","count":100}],"period_months":1}}}'
```

A successful result has `structuredContent` (the parsed object) and `content[0].text` (the same data serialized as JSON):

```json
{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\n  \"total_ip\": 100,\n  \"total_price_cents\": 1200,\n  ...\n}"
      }
    ],
    "structuredContent": {
      "binding": false,
      "segments": [
        { "country_code": "DE", "count": 100, "segment_price_cents": 1200, "available": true }
      ],
      "errors": [],
      "total_ip": 100,
      "total_price_cents": 1200,
      "period_months": 1,
      "discount_pct": 0,
      "monthly_price_cents": 1200
    }
  }
}
```

Read `structuredContent` when it's present and fall back to parsing `content[0].text` as JSON. Be lenient: in some captured responses `text` arrived as an object rather than a string.

A tool-level failure is still HTTP `200`, with `isError: true` and a plain-text explanation:

```json
{
  "jsonrpc": "2.0",
  "id": 4,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "Invalid arguments: Total order IP count (5) is below the tenant minimum of 100 IPs per order"
      }
    ],
    "isError": true
  }
}
```

## Error model

Errors come from three layers. Check them in this order:

| Layer | Signal | When | What to do |
| --- | --- | --- | --- |
| HTTP | `401`, `WWW-Authenticate: Bearer`, `{"detail": "Missing or malformed Authorization header. Expected: Bearer <api_key>."}` | No or malformed `Authorization` header | Send `Authorization: Bearer fb_...` |
| HTTP | `401`, `{"detail": "Invalid or revoked API key."}` | Wrong or revoked key | Create a new key in the dashboard |
| HTTP | `405`, `Allow: POST` | `GET` or `DELETE` | Use `POST` |
| HTTP | `429`, `{"detail": "Too Many Requests"}` | Request bursts | Back off and retry; see below |
| JSON-RPC | `error.code: -32600` | Batch (array) request | Send one message per request |
| JSON-RPC | `error.code: -32601` | Unknown method, `resources/*`, `prompts/*` | Use only `initialize`, `ping`, `tools/list`, `tools/call` |
| Tool | `result.isError: true` + text | Unknown tool, invalid arguments, business rules (minimum order, price mismatch, cooldowns), not-found objects | Show the text to the model or user; don't retry unchanged |

Invalid tool arguments are reported as `isError` results, not as JSON-RPC `-32602`. Typical texts start with `Invalid arguments:`, `Request rejected (404):` or an error code such as `SERVICE_CANCEL_COOLDOWN:`. More examples are in [Troubleshooting](/developers/docs/mcp/troubleshooting/#common-tool-errors).

## Rate limits and timeouts

- Bursts above about 2 requests per second return HTTP `429`, including bursts of `initialize`. Keep to 2 requests per second or less per account and retry with exponential backoff, using `x-ratelimit-reset` to decide how long to wait.
- Typical tool calls take 0.5–0.8 seconds. `list_countries` takes about 10 seconds; a first `order_composite` took about 40 seconds in testing. Use a request timeout of at least 120 seconds for tool calls.
- Retrying a paid tool after a timeout is safe only with the **same** `idempotency_key`: the server then returns the original result instead of charging again.

## Minimal clients without an SDK

The server needs nothing beyond HTTP and JSON, so a few dozen lines are enough. Both clients read the key from `FINEPROXY_API_KEY`, retry on `429` and turn `isError` results into exceptions.

```python
import json
import os
import time
import uuid

import requests

MCP_URL = "https://fineproxy.org/account_new/api/v1/mcp"
HEADERS = {
    "Authorization": f"Bearer {os.environ['FINEPROXY_API_KEY']}",
    "Content-Type": "application/json",
    "Accept": "application/json, text/event-stream",
}


class McpError(Exception):
    pass


def rpc(method, params=None, notify=False, retries=3):
    message = {"jsonrpc": "2.0", "method": method}
    if params is not None:
        message["params"] = params
    if not notify:
        message["id"] = str(uuid.uuid4())
    for attempt in range(retries + 1):
        response = requests.post(MCP_URL, headers=HEADERS, json=message, timeout=120)
        if response.status_code == 429 and attempt < retries:
            time.sleep(2 ** (attempt + 1))
            continue
        response.raise_for_status()
        break
    if notify:
        return None  # 202, empty body
    body = response.json()
    if "error" in body:
        raise McpError(f"JSON-RPC {body['error']['code']}: {body['error'].get('message')}")
    return body["result"]


def call_tool(name, arguments=None):
    result = rpc("tools/call", {"name": name, "arguments": arguments or {}})
    text = result["content"][0]["text"] if result.get("content") else ""
    if result.get("isError"):
        raise McpError(text)
    if "structuredContent" in result:
        return result["structuredContent"]
    return json.loads(text) if isinstance(text, str) else text


init = rpc("initialize", {
    "protocolVersion": "2025-06-18",
    "capabilities": {},
    "clientInfo": {"name": "my-client", "version": "1.0"},
})
rpc("notifications/initialized", notify=True)
print(init["protocolVersion"])                # 2025-06-18
print(len(rpc("tools/list")["tools"]))        # 57
print(call_tool("wallet_balance"))            # {'balance_cents': 2800, 'currency': 'USD', ...}
```

```javascript
// Node.js 18+ (built-in fetch), ES module
import { randomUUID } from 'node:crypto';

const MCP_URL = 'https://fineproxy.org/account_new/api/v1/mcp';
const HEADERS = {
  Authorization: `Bearer ${process.env.FINEPROXY_API_KEY}`,
  'Content-Type': 'application/json',
  Accept: 'application/json, text/event-stream',
};

async function rpc(method, params, { notify = false, retries = 3 } = {}) {
  const message = { jsonrpc: '2.0', method };
  if (params !== undefined) message.params = params;
  if (!notify) message.id = randomUUID();
  for (let attempt = 0; ; attempt++) {
    const response = await fetch(MCP_URL, {
      method: 'POST',
      headers: HEADERS,
      body: JSON.stringify(message),
      signal: AbortSignal.timeout(120_000),
    });
    if (response.status === 429 && attempt < retries) {
      await new Promise((resolve) => setTimeout(resolve, 2 ** (attempt + 1) * 1000));
      continue;
    }
    if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
    if (notify) return null; // 202, empty body
    const body = await response.json();
    if (body.error) throw new Error(`JSON-RPC ${body.error.code}: ${body.error.message}`);
    return body.result;
  }
}

async function callTool(name, args = {}) {
  const result = await rpc('tools/call', { name, arguments: args });
  const text = result.content?.[0]?.text ?? '';
  if (result.isError) throw new Error(typeof text === 'string' ? text : JSON.stringify(text));
  if (result.structuredContent) return result.structuredContent;
  return typeof text === 'string' ? JSON.parse(text) : text;
}

const init = await rpc('initialize', {
  protocolVersion: '2025-06-18',
  capabilities: {},
  clientInfo: { name: 'my-client', version: '1.0' },
});
await rpc('notifications/initialized', undefined, { notify: true });
console.log(init.protocolVersion); // 2025-06-18
console.log((await rpc('tools/list')).tools.length); // 57
console.log(await callTool('wallet_balance')); // { balance_cents: 2800, currency: 'USD', ... }
```

To place an order from code, follow the same flow as an agent: `quote_composite`, then `order_composite` with the quote's `total_price_cents` as `expected_total_cents`, a non-empty `whitelist_ips` and an `idempotency_key` you store before the call. See [Safety for AI agents](/developers/docs/mcp/safety/#price-guards).

## Existing tools that work

If you'd rather not write a client, these were verified against the server:

- [MCP Inspector](https://github.com/modelcontextprotocol/inspector) CLI with `--transport http` and `--header "Authorization: Bearer ..."`; see [Test without a client](/developers/docs/mcp/quickstart/#test-without-a-client).
- [`mcp-remote`](https://github.com/punkpeye/mcp-remote) with `--transport http-only`, which exposes the server to stdio-only clients; see [Troubleshooting](/developers/docs/mcp/troubleshooting/#your-client-cant-send-headers).

## Related pages

- [MCP tools reference](/developers/docs/mcp/tools/): input schemas of all 57 tools.
- [Authentication](/developers/docs/authentication/): API keys and scopes.
- [Rate limits](/developers/docs/rate-limits/): limits shared with the REST API.
