# 05 · MCP Tools, Usage & Rate Limits Reference

> **SSOT Status**: Authoritative Specification  
> **Machine Source**: [`spec/fiderail.manifest.json`](../spec/fiderail.manifest.json) (`schemaVersion: 1.0.0`)  
> **Release**: `v2.3.5`

---

## 1. Transport Modes & Tool Availability Matrix

FideRail ships a dual-mode Model Context Protocol (MCP) server supporting JSON-RPC 2.0 across protocol versions `2025-06-18`, `2025-03-26`, and `2024-11-05`:

- **Remote Streamable HTTP (`POST https://api.fiderail.com/mcp`)**: Zero-install hosted endpoint exposing the **5 stateless** trust, firewall, discovery, and diagnostic tools. Supports `Mcp-Session-Id` (validated against `/^[A-Za-z0-9._:-]{1,128}$/`), `Mcp-Protocol-Version`, `DELETE /mcp` (`204`), and returns `405` (`Allow: POST, DELETE, OPTIONS`) on `GET /mcp`.
- **Local `stdio` MCP (`npx -y @fiderail/mcp`)**: Full **6-tool** local server pairing remote cloud intelligence (`FIDERAIL_API_URL`) with a local SQLite WAL spend ledger (`FIDERAIL_SPEND_LEDGER_PATH`) and immutable host-side `FIDERAIL_HOST_*` policy clamping.

| Tool Name | Remote HTTP `/mcp` | Local `stdio` `@fiderail/mcp` | Outbound Network Probe | Rate-Limit Bucket (Public Node) |
|---|---|---|---|---|
| `check_agent_trust` | Yes | Yes | No | General (`120 req/min/IP`) |
| `preflight_payment_guard` | Yes | Yes | No | General (`120 req/min/IP`) |
| `list_audited_agents` | Yes | Yes | No | General (`120 req/min/IP`) |
| `discover_trusted_services` | Yes | Yes | No | General (`120 req/min/IP`) |
| `diagnose_x402_endpoint` | Yes | Yes | Yes (fail-closed Worker proxy) | Diagnose (`6 req/min/IP`, conc. `4`) |
| `guarded_x402_fetch` | Disabled (local-only) | Yes | Local client `fetch` only | N/A (`isError: true` on `/mcp`) |

> **Why is `guarded_x402_fetch` local-only?** Maintaining per-buyer spend ledgers, circuit-breaker state, and payment signing belongs strictly on the caller's edge machine (`ZERO_CUSTODY`), and keeping arbitrary fetch proxy execution off the public node prevents open-proxy abuse. Calling `guarded_x402_fetch` on `POST https://api.fiderail.com/mcp` returns `isError: true` with zero outbound requests.

---

## 2. Tool-by-Tool Reference

### 2.1 `check_agent_trust`

Look up the cross-chain anti-sybil `trust-v2` score, confidence, dual HHI payer concentration, USD volume, associated credit isolation, and risk flags for an agent/payee wallet before paying.

- **Availability**: Remote `/mcp` & Local `stdio`

| Parameter | Type | Required | Default / Constraints |
|---|---|---|---|
| `chain` | string | Yes | One of `base`, `solana`, `arbitrum`, `polygon` |
| `address` | string | Yes | `0x...` EVM address or Base58 Solana public key |

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "check_agent_trust",
    "arguments": {
      "chain": "base",
      "address": "0x7284d41b5b852f2bd4c99bdf95043d84452d299c"
    }
  }
}
```

- **Key Output Fields**: `found`, `creditScore`, `tier`, `confidence`, `riskLevel`, `riskFlags`, `dataCoverage`, `payerHhi`, `volumeHhi`, `txCount`, `totalVolumeUsd`, `bazaarServices`, `liveness`, `modelHash`.

---

### 2.2 `preflight_payment_guard`

Deterministic pre-flight payment firewall evaluating a planned stablecoin spend against hard single-transaction and daily caps, counterparty `trust-v2` score, reciprocal wash-trading loops, single-payer concentration, isolated payer farms, and non-x402 whale channels.

- **Availability**: Remote `/mcp` & Local `stdio`

| Parameter | Type | Required | Default / Constraints |
|---|---|---|---|
| `chain` | string | Yes | One of `base`, `solana`, `arbitrum`, `polygon` |
| `counterparty` | string | Yes | Recipient EVM `0x...` or Solana Base58 wallet |
| `amountUsdc` | number | Yes | Planned spend in USD/USDC (e.g. `0.05`) |
| `spentTodayUsdc` | number | No | `0` (cumulative USD spent today) |
| `maxSingleTxUsdc` | number | No | `1.0` (clamped by `FIDERAIL_HOST_MAX_SINGLE_USDC`) |
| `maxDailyUsdc` | number | No | `10.0` (clamped by `FIDERAIL_HOST_MAX_DAILY_USDC`) |
| `minTrustScore` | number | No | `40` (clamped by `FIDERAIL_HOST_MIN_TRUST_SCORE`, `0-100`) |

```json
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "preflight_payment_guard",
    "arguments": {
      "chain": "base",
      "counterparty": "0x7284d41b5b852f2bd4c99bdf95043d84452d299c",
      "amountUsdc": 0.05,
      "spentTodayUsdc": 0.2
    }
  }
}
```

- **Key Output Fields**: `decision` (`ALLOW`, `WARN`, `BLOCK`), `reasons`, `creditScore`, `tier`, `remainingDailyBudgetUsdc`, `effectivePolicy`, `modelHash`.

---

### 2.3 `list_audited_agents`

Browse indexed x402 payee profiles across Base, Solana, Arbitrum, and Polygon sorted by `trust-v2` score.

- **Availability**: Remote `/mcp` & Local `stdio`

| Parameter | Type | Required | Default / Constraints |
|---|---|---|---|
| `chain` | string | No | `"all"` (or `base`, `solana`, `arbitrum`, `polygon`) |
| `minScore` | number | No | `0` (`0-100`) |
| `excludeFlagged` | boolean | No | `false` |
| `limit` | number | No | `15` (range `1-100`) |

```json
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "list_audited_agents",
    "arguments": {
      "chain": "base",
      "minScore": 70,
      "excludeFlagged": true,
      "limit": 10
    }
  }
}
```

- **Key Output Fields**: `count`, `items[]` (address, chain, `creditScore`, `tier`, `riskFlags`, `txCount`, `totalVolumeUsd`).

---

### 2.4 `discover_trusted_services`

Search Coinbase CDP Bazaar, PayAI Discovery, and Open Bazaar capabilities joined with live cross-chain `trust-v2` scores and L1/L2 liveness health.

- **Availability**: Remote `/mcp` & Local `stdio`

| Parameter | Type | Required | Default / Constraints |
|---|---|---|---|
| `query` | string | No | `""` (keyword across name, description, tags, URL) |
| `chain` | string | No | `"all"` (or `base`, `solana`, `arbitrum`, `polygon`) |
| `maxPriceUsdc` | number | No | `null` (optional per-call USD ceiling) |
| `minTrustScore` | number | No | `null` (`0-100`) |
| `excludeFlagged` | boolean | No | `true` |
| `limit` | number | No | `15` (range `1-100`) |

```json
{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "tools/call",
  "params": {
    "name": "discover_trusted_services",
    "arguments": {
      "query": "weather",
      "maxPriceUsdc": 0.05,
      "excludeFlagged": true,
      "limit": 5
    }
  }
}
```

- **Key Output Fields**: `count`, `services[]` (`resourceUrl`, `serviceName`, `chain`, `priceUsdc`, `creditScore`, `livenessStatus`, `headerBytes`).

---

### 2.5 `diagnose_x402_endpoint`

Zero-payment HTTP 402 compliance grader checking `PAYMENT-REQUIRED` header limits (`8 KB` aiohttp / `16 KB` Node crash thresholds for `x402#3803`), Bazaar `inputSchema` quirks, HTTPS usage, and quoted price consistency.

- **Availability**: Remote `/mcp` (routed exclusively through the fail-closed outbound Worker proxy) & Local `stdio`

| Parameter | Type | Required | Default / Constraints |
|---|---|---|---|
| `url` | string | Yes | Public `http://` or `https://` URL (`<= 2048` chars; control/CRLF/BiDi chars, `%00`/`%0a`/`%0d`, and private/loopback DNS IPs rejected) |
| `method` | string | No | `"GET"` (strictly `"GET"` or `"POST"`) |

```json
{
  "jsonrpc": "2.0",
  "id": 5,
  "method": "tools/call",
  "params": {
    "name": "diagnose_x402_endpoint",
    "arguments": {
      "url": "https://x402.clashofcoins.com/x402/cheap-health",
      "method": "GET"
    }
  }
}
```

- **Key Output Fields**: `grade` (`A`, `B`, `C`, `F`), `healthy`, `livenessStatus` (`LIVE_402`, `DOWN`, etc.), `httpStatus`, `latencyMs`, `headerBytes`, `aiohttpSafe`, `nodeHttpSafe`, `observedPriceUsdc`, `accepts[]`, `diagnosticFlags`, `recommendations`.

---

### 2.6 `guarded_x402_fetch` (Local `stdio` Only)

Full non-custodial Guard-and-Pay probe featuring atomic SQLite WAL budget reservation, outbound secret/PII scrubbing, immutable host policy clamping, 3-tier HITL approval gate, Quote-to-Pay digest binding, 60s idempotency deduplication, HTTP 5xx circuit breaker, and salted `fiderail-sar-v2` receipt generation.

- **Availability**: **Local `stdio` MCP (`@fiderail/mcp`) or `@fiderail/guard` SDK only.** Disabled on public `POST /mcp`.

| Parameter | Type | Required | Default / Constraints |
|---|---|---|---|
| `url` | string | Yes | Target x402 HTTP endpoint URL |
| `method` | string | No | `"GET"` (strictly `"GET"` or `"POST"`) |
| `preferredChain` | string | No | `"base"` (`base`, `solana`, `arbitrum`, `polygon`) |
| `maxSingleTxUsdc` | number | No | `1.0` (clamped by `FIDERAIL_HOST_MAX_SINGLE_USDC`) |
| `maxDailyUsdc` | number | No | `10.0` (clamped by `FIDERAIL_HOST_MAX_DAILY_USDC`) |
| `minTrustScore` | number | No | `40` (clamped by `FIDERAIL_HOST_MIN_TRUST_SCORE`) |

---

## 3. Public Hosted Node Limits, Quotas & Error Codes

The public hosted node (`https://api.fiderail.com`) runs on a best-effort community basis with zero SLA and enforces both edge (Cloudflare) and origin (Node API) protections:

| Scope | Limit / Rule | Notes |
|---|---|---|
| General REST & MCP (`POST /mcp`, `/v1/*`) | `120 req/min` per IP | Sliding 60s window across general API & MCP calls |
| Endpoint Diagnostics (`diagnose_x402_endpoint` & `POST /v1/diagnose`) | `6 req/min` per IP + global concurrency cap `4` | Shared bucket between REST grader and remote MCP |
| Open Bazaar `autoRegister` (`POST /v1/diagnose`) | `5 registrations / host / 24h` | Prevents directory spam on voluntary listing |
| L2 Delivery Telemetry (`POST /v1/telemetry/delivery`) | `10 req/min` per IP | `fiderail-sar-v2` required + `receiptHash` deduplication; unverified negative claims quarantined |
| Cloudflare Edge Burst Shield | `30 req / 10s` per IP (`Block 10s`) | Protects `/v1/diagnose`, `/v1/telemetry/delivery`, and `/mcp` |
| Cloudflare API Agent Compatibility | Browser Integrity Check **Off** on `api.fiderail.com`; Bot Fight Mode **Off** | Prevents false `403` blocks on `Python-urllib`, `curl`, and Node `fetch` agents |
| JSON-RPC Batch (`POST /mcp`) | Max `5` items per batch; max `1` `diagnose_x402_endpoint` call per batch | Prevents single-request amplification |
| Request Body & URL Caps | Max `64 KB` (`65,536` bytes) JSON body; max `2,048` chars URL | Null bytes, CRLF, BiDi overrides, and prototype-pollution keys stripped/rejected |

### Common Limit & Validation Errors

| HTTP Status | JSON-RPC Code | Meaning & Resolution |
|---|---|---|
| `413` | N/A | Request JSON body exceeds `64 KB`. Reduce payload or split calls. |
| `429` | `-32029` | Per-IP rate limit (`120/min` general or `6/min` diagnose) or concurrency cap (`4`) exceeded. Wait for the `Retry-After` header seconds. |
| `405` | N/A | `GET /mcp` is not supported on this stateless server. Use `POST /mcp` (`DELETE /mcp` returns `204`). |
| `200` / `400` | `-32600` | Invalid JSON-RPC payload, empty batch, batch `> 5` requests, or `> 1` `diagnose_x402_endpoint` call in a batch. |
| `200` | `isError: true` | Tool-level validation failure (e.g., invalid URL encoding/method, or calling `guarded_x402_fetch` on remote `/mcp`). |

---

## 4. Local `stdio` Configuration & Host Policy Guardrails

Run all 6 tools locally (including `guarded_x402_fetch` with persistent SQLite WAL budgets and immutable host policy clamping) via `npx -y @fiderail/mcp`:

```json
{
  "mcpServers": {
    "fiderail": {
      "command": "npx",
      "args": ["-y", "@fiderail/mcp"],
      "env": {
        "FIDERAIL_API_URL": "https://api.fiderail.com",
        "FIDERAIL_OUTAGE_POLICY": "fail-closed",
        "FIDERAIL_SPEND_LEDGER_PATH": "./edge-ledger.db",
        "FIDERAIL_HOST_MAX_SINGLE_USDC": "1.0",
        "FIDERAIL_HOST_MAX_DAILY_USDC": "10.0",
        "FIDERAIL_HOST_MIN_TRUST_SCORE": "40",
        "FIDERAIL_HOST_ALLOWED_ASSETS": "USDC",
        "FIDERAIL_HOST_BLOCK_LOOPS": "true"
      }
    }
  }
}
```

| Environment Variable | Default | Purpose |
|---|---|---|
| `FIDERAIL_API_URL` | `""` (local DB mode) | Point local `stdio` MCP to `https://api.fiderail.com` with zero local chain indexing |
| `FIDERAIL_OUTAGE_POLICY` | `fail-closed` | `fail-closed` (block on oracle outage) or `fail-open-micro` (bounded micro-probe fallback) |
| `FIDERAIL_SPEND_LEDGER_PATH` | `:memory:` | Path to `.db` SQLite WAL file for persistent atomic daily spend budgets & circuit breakers |
| `FIDERAIL_HOST_MAX_SINGLE_USDC` | Unset | Immutable host ceiling that prompt arguments can narrow (`clampPolicy`) but never raise |
| `FIDERAIL_HOST_MAX_DAILY_USDC` | Unset | Immutable daily budget ceiling enforced across concurrent tool calls |
| `FIDERAIL_HOST_MIN_TRUST_SCORE` | Unset | Immutable minimum `trust-v2` score floor (`0-100`) |
| `FIDERAIL_HOST_HITL_ABOVE_USDC` | Unset | Threshold requiring human-in-the-loop approval before local settlement |
| `FIDERAIL_HOST_ALLOWED_ASSETS` | Unset | Comma-separated allowlist (e.g. `USDC`, `EURC`, `USDT`) |
| `FIDERAIL_HOST_BLOCK_LOOPS` | `false` | Set `"true"` to force-block any counterparty flagged with `RECIPROCAL_LOOP` |

> Teams requiring higher throughput or custom limits beyond `120 req/min` / `6 diagnose/min` should self-host following the [Operations Runbook](./04-operations.md) or contact [`founder@fiderail.com`](mailto:founder@fiderail.com).
