# MCP proxy

Source: https://immiscible.fly.dev/docs/api/post-mcp-proxy-uid

`POST /mcp/proxy/:uid`

The gated path to one registered upstream tool server. `initialize` is answered locally, `tools/list` is filtered to what this agent may use, and every `tools/call` goes through the gate before anything is sent; the upstream's credential is injected only into an allowed call. See [the MCP proxy](https://immiscible.fly.dev/docs/guides/mcp-proxy.md).

Errors: `-32003` denied (with reasons), `-32006` already forwarded once. An approval needed comes back as a tool result with `isError: true` and the approval link.

## Authentication

Agent key. An agent-scoped key (`ask_...`) bound to exactly one agent, or an OAuth access token (`aat_...`) issued to an MCP client for that agent, sent as `Authorization: Bearer`. An agent key may ask, poll and settle. It can never approve, widen a mandate or lift a freeze.

## Path parameters

- `uid` (string, required): MCP upstream id

## Request

curl:

```bash
curl -X POST "https://immiscible.fly.dev/mcp/proxy/mcu_6c1d0e" \
  -H "authorization: Bearer $IMMISCIBLE_AGENT_KEY" \
  -H "content-type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 7,
    "method": "tools/call",
    "params": {
      "name": "create_pull_request",
      "arguments": {
        "owner": "acme",
        "repo": "api",
        "title": "Fix retry"
      }
    }
  }'
```

Node:

```ts
const res = await fetch('https://immiscible.fly.dev/mcp/proxy/mcu_6c1d0e', {
  method: 'POST',
  headers: {
    authorization: `Bearer ${process.env.IMMISCIBLE_AGENT_KEY}`,
    'content-type': 'application/json',
  },
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 7,
    method: 'tools/call',
    params: {
      name: 'create_pull_request',
      arguments: {
        owner: 'acme',
        repo: 'api',
        title: 'Fix retry',
      },
    },
  }),
});
const data = await res.json();
console.log(res.status, data);
```

Python:

```python
import os
import requests

res = requests.post(
    "https://immiscible.fly.dev/mcp/proxy/mcu_6c1d0e",
    headers={
        "authorization": f"Bearer {os.environ['IMMISCIBLE_AGENT_KEY']}",
        "content-type": "application/json",
    },
    json={
        "jsonrpc": "2.0",
        "id": 7,
        "method": "tools/call",
        "params": {
            "name": "create_pull_request",
            "arguments": {
                "owner": "acme",
                "repo": "api",
                "title": "Fix retry",
            },
        },
    },
)
print(res.status_code, res.json())
```
