# AI assistants (MCP)

> Let Claude, ChatGPT, Cursor or VS Code build and check your integration with KetaPay's MCP server.

KetaPay's [Model Context Protocol](https://modelcontextprotocol.io) server lets an AI assistant work with your KetaPay account. It can answer questions from these docs, create test payment links and pay them, look up escrows, disputes and events, check your fees and set up webhooks.

> **Note:** The server is in pre-release and takes **sandbox keys only** (`sk_test_`). No tool moves money.

## Connect

### Hosted server

Use `https://mcp.ketapay.com/mcp`, with a sandbox secret key as the bearer token.

**Claude Code**

```sh
claude mcp add --transport http ketapay https://mcp.ketapay.com/mcp \
  --header "Authorization: Bearer sk_test_..."
```

**Cursor (mcp.json)**

```json
{
  "mcpServers": {
    "ketapay": {
      "url": "https://mcp.ketapay.com/mcp",
      "headers": { "Authorization": "Bearer sk_test_..." }
    }
  }
}
```

In any other app, add a remote MCP server (Streamable HTTP) with that address and an `Authorization` header.

### On your machine

Run the server locally with `npx`, and the key stays on your machine:

```json
{
  "mcpServers": {
    "ketapay": {
      "command": "npx",
      "args": ["-y", "@ketapay/mcp"],
      "env": { "KETAPAY_API_KEY": "sk_test_..." }
    }
  }
}
```

### Sign in with KetaPay (coming soon)

Soon you won't need a key: you'll copy your business's address from **AI assistants** in the [business dashboard](https://business.ketapay.com), add it to Claude, ChatGPT, Cursor or VS Code, sign in to KetaPay and choose what the assistant may do. Each connection shows on that page with the member who made it, and you can disconnect it there at any time.

## Choose what your assistant can do

The assistant can never do more than your key allows. Make a key with just the [scopes](https://docs.ketapay.com/api-basics/authentication) it needs, and narrow it further with options on the address:

| Option | Values |
| --- | --- |
| `features` | Comma-separated: `docs`, `checkout`, `escrows`, `disputes`, `webhooks` (events included), `payouts`. A bare group can view and change; add `:read` (for example `checkout:read`) to only view. |
| `read_only` | `true` hides every tool that changes something. |

```sh
claude mcp add --transport http ketapay \
  "https://mcp.ketapay.com/mcp?features=docs,checkout,webhooks:read" \
  --header "Authorization: Bearer sk_test_..."
```

Running locally, set `KETAPAY_FEATURES` and `KETAPAY_READ_ONLY` instead. A value the server doesn't know is refused with the list of valid ones.

## Tools

| Tool | What it does | Key scopes |
| --- | --- | --- |
| `search_docs`, `get_doc_page` | Answers from these docs and the API reference, with links | none |
| `retrieve_pricing` | Your plan's fees, VAT and who pays them | `checkout_sessions:read` |
| `create_checkout_session` | A payment link; nobody is charged until the buyer pays | `checkout_sessions:write` |
| `list_checkout_sessions`, `get_checkout_session` | Payment links by status or your reference, and what each became | `checkout_sessions:read` |
| `cancel_checkout_session` | Closes an unpaid link | `checkout_sessions:write` |
| `test_pay_checkout_session` | Test mode only: pays a link as the buyer would | `checkout_sessions:write`, `test_helpers:write` |
| `list_escrows`, `get_escrow` | Escrows with milestones, fees and timeline | `escrows:read` |
| `get_money_action` | Where a refund or release already under way stands | `escrows:read` |
| `deliver_milestone` | Marks a milestone of your own sale delivered | `escrows:act` |
| `flag_escrow` | Asks KetaPay to review a deal you think is fraudulent | `escrows:flag` |
| `list_disputes`, `get_dispute`, `list_chargebacks`, `get_chargeback` | Disputes and card chargebacks, with deadlines | `escrows:read` |
| `list_events`, `get_event` | What happened in the last 30 days, the same events webhooks deliver | `events:read` |
| `list_webhook_endpoints`, `get_webhook_endpoint` | Your webhook URLs and whether they are failing | `webhook_endpoints:read` |
| `create_webhook_endpoint`, `update_webhook_endpoint` | Add or change a webhook URL | `webhook_endpoints:write` |
| `test_webhook_endpoint` | Sends a signed sample event and reports what your server answered | `webhook_endpoints:write` |
| `list_banks` | Banks a payout can go to, for your payout form | `payout_accounts:read` |

Every docs page is also an MCP resource (`https://docs.ketapay.com/<page>.md`) that you can attach to a conversation yourself.

## What needs your approval

- **Asked in your app.** Adding or changing a webhook endpoint, and marking a milestone delivered (which starts the buyer's inspection period), each show you the exact change first. Nothing is sent until you approve it, and an approval covers only those exact details.
- **Approved on a KetaPay page.** When an assistant is connected by signing in, KetaPay itself enforces this: a refund, a new webhook endpoint or a change to one needs a person on your team to open the link the assistant gives them, check what KetaPay will do and approve it with their code. Without that approval the API refuses with `confirmation_required` and changes nothing. Refunds through an assistant are not offered yet.
- **Never through an assistant.** Releasing a buyer's money, opening or answering a dispute, deciding a dispute, payouts and bank accounts, deleting a webhook endpoint, and anything that would show a signing secret or release code. Those stay in the dashboard, with the buyer, or in your own code.

## Safety

- No tool takes or returns a key, a webhook signing secret, a release code or bank details.
- Text your buyers and sellers typed comes back marked as untrusted, so the assistant treats it as data, not as instructions.
- Every change an assistant makes is an ordinary API request with your key, so it sends the same webhooks and events as any other.
