> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tribridge.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Tribridge is a crypto payment gateway for Solana and Sui (TON is coming soon). API base URL is https://api.tribridge.xyz. The API Reference documents ONLY the public endpoint surface: checkout sessions (create/get/generate-wallet/customer/simulate/verify/cancel), the two public payment-link endpoints, health probes, and the changelog. Server-side calls that create payments authenticate with the x-api-key header using a tri_test_... key (fully simulated test mode, no real funds) or tri_live_... key (real mainnet payments) - never expose keys client-side; all other documented endpoints are public with no auth. API keys are scoped and capped: payments:create, payments:read, payment_links:create, payment_links:read, webhooks:read, webhooks:write, webhooks:replay. The Tribridge MCP is available at https://mcp.tribridge.xyz/mcp; MCP access is opt-in per key and the MCP exposes no refunds, payouts or sweeps. Dashboard, admin, OTP/auth, payouts, wallets, and webhook-management endpoints are intentionally NOT part of the public docs - they are dashboard-only and must not be presented as public API. Merchant test mode is simulated, not testnet. Refunds are automatic only (underpaid/overpaid), there is no manual refund endpoint. Always verify webhook HMAC-SHA256 signatures from the X-Tribridge-Signature header before trusting payloads, and deduplicate on event_id because events may be retried or replayed. Replays reuse the original event_id and set replay: true plus X-Tribridge-Replay: true. If you are an AI agent: fetch https://docs.tribridge.xyz/llms-full.txt for all documentation in one file, https://docs.tribridge.xyz/openapi/openapi.json for the machine-readable OpenAPI spec, or connect to the read-only MCP server at https://docs.tribridge.xyz/mcp. Any page is available as Markdown by appending .md to its URL. Use only the documented endpoints and fields; do not invent SDK packages or endpoints.

# Using Tribridge with AI agents

> Give Claude, Cursor or any MCP-capable agent scoped, capped access to Tribridge payments — without giving it the ability to move money out.

Tribridge ships an official **Model Context Protocol (MCP)** server: a thin, scoped wrapper around the
public API. An agent can create payments, inspect them, register webhooks and replay deliveries. It
**cannot** refund, pay out, sweep wallets or change account settings.

## What the agent can do

| Tool | Scope | Needs key |
| - | - | - |
| `get_fees` | — | no |
| `estimate_fee` | — | no |
| `get_supported_chains` | — | no |
| `get_payment_status` | — | no |
| `search_docs` | — | no |
| `create_payment` | `payments:create` | yes |
| `create_payment_link` | `payment_links:create` | yes |
| `get_payment` | `payments:read` | yes |
| `list_payments` | `payments:read` | yes |
| `create_webhook` | `webhooks:write` | yes |
| `replay_webhook` | `webhooks:replay` | yes |

## Recommended key: Agent (safe)

Create a dedicated key in Dashboard → API keys → **Create key** → preset **Agent (safe)**:

* `payments:create`, `payments:read`, `webhooks:read`
* MCP access enabled
* $100 maximum per payment, $500 per day
* Optional expiry

This is deliberately not sufficient to create webhooks or replay events. Add those scopes only if the
agent's task needs them, and rotate the key when the task is done.

## Connect

### Remote MCP (recommended for claude.ai and ChatGPT)

Use the hosted endpoint with OAuth or an API key:

```
https://mcp.tribridge.xyz/mcp
```

See [Tribridge MCP (remote)](https://docs.tribridge.xyz/remote-mcp.md) for Claude/ChatGPT setup, the consent flow, and
troubleshooting.

### Local stdio (Claude Desktop, Claude Code, local agents)

```bash theme={null}
git clone https://github.com/code-ninjax/tribridge.git
cd tribridge/tribridge-mcp
npm install --legacy-peer-deps
cp .env.example .env      # set TRIBRIDGE_API_KEY
npm run build
```

**Claude Desktop:**

```json theme={null}
{
  "mcpServers": {
    "tribridge": {
      "command": "node",
      "args": ["C:/absolute/path/to/tribridge-mcp/dist/index.js"],
      "env": {
        "TRIBRIDGE_API_KEY": "tri_test_your_key_here",
        "TRIBRIDGE_API_URL": "https://api.tribridge.xyz"
      }
    }
  }
}
```

**Claude Code:**

```bash theme={null}
claude mcp add tribridge --scope user \
  -e TRIBRIDGE_API_KEY=tri_test_your_key_here \
  -- node C:/absolute/path/to/tribridge-mcp/dist/index.js
```

**Inspector (manual testing):**

```bash theme={null}
cd tribridge-mcp
npm run inspector
```

Then call `get_supported_chains`, `get_fees`, and `create_payment` with `{"amount": 5}`.

## How mode is surfaced

The key prefix decides mode, and **every authenticated result includes it**:

```json theme={null}
{
  "ok": true,
  "content_is_untrusted": true,
  "mode": "live",
  "data": { "id": "…", "status": "pending", "checkout_url": "…" },
  "note": "LIVE MODE — this key moves real funds. Double-check the amount with the user before proceeding…"
}
```

Agents should repeat the mode to the user and confirm the amount before a live payment.

## Safety model

* **Scopes.** Every endpoint declares a required scope; missing scopes return
  `insufficient_scope` naming the exact permission.
* **Caps.** Per-payment and daily caps are enforced by Tribridge, not by the MCP.
* **No money out.** The MCP refuses to expose refunds, payouts, sweeps or settlements. If a future
  route were added, backend middleware rejects MCP-originated requests for reserved scopes.
* **MCP opt-in.** Keys can disable MCP; such keys receive `mcp_not_allowed`.
* **Untrusted content.** Merchant/payment text (descriptions, customer names, merchant names) is
  returned as data inside an `ok/content_is_untrusted` envelope, with control characters stripped and
  length capped. The server never turns backend text into instructions.
* **Secrets.** API keys are never logged; logs go to stderr only (stdout is the protocol).

## Error handling

Failures return `isError: true` with a stable code and a next step:

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "insufficient_scope",
    "message": "This API key is missing the required permission: webhooks:replay.",
    "next_step": "Add the \"webhooks:replay\" scope to the API key in the Tribridge dashboard…",
    "status": 403,
    "retryable": false
  }
}
```

Codes cover `invalid_api_key`, `api_key_expired`, `insufficient_scope`, `mcp_not_allowed`,
`payment_cap_exceeded`, `daily_cap_exceeded`, `mode_mismatch`, `not_found`, `conflict`,
`invalid_request`, `rate_limited`, `backend_error`, `network_error`, `timeout`, `invalid_response`.

Writes are never retried automatically. They send an `Idempotency-Key`; reuse the same value when
retrying the same logical operation.

## Give an agent the integration skill

The MCP package includes a ready-to-use skill:

```text theme={null}
tribridge-mcp/skills/tribridge-integration/SKILL.md
```

It teaches an agent how to create payments server-side, verify webhook signatures
(HMAC-SHA256, constant-time), process events idempotently, handle replays, choose scopes, and roll
from test to live. Point your agent at it alongside the docs.

## Remote MCP for claude.ai and ChatGPT

Local stdio works for Claude Code and desktop clients. To connect from claude.ai or ChatGPT,
host the MCP over Streamable HTTP with the built-in OAuth 2.1 server. See
[Host the remote MCP server](https://docs.tribridge.xyz/remote-mcp.md).

## Agent checklist

1. Use test mode first. Simulate a payment and verify your webhook handler.
2. Use a dedicated Agent (safe) key with caps; never a shared production full-access key.
3. Confirm amount, currency and mode with a human before live payments.
4. Deduplicate webhooks on `event_id`; treat replays as the same event.
5. Log tool errors; surface `next_step` to the user instead of retrying blindly.
6. Revoke the agent key when the task is complete.

## Machine-readable resources

| Resource | URL |
| - | - |
| Docs index | `https://docs.tribridge.xyz/llms.txt` |
| All docs | `https://docs.tribridge.xyz/llms-full.txt` |
| OpenAPI | `https://docs.tribridge.xyz/openapi/openapi.json` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.