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

# AI Tools (MCP)

> Let Claude Code, Cursor, VS Code and other MCP clients work with your PalPluss account — balances, transactions, payment channels, STK Push and B2C payouts, with your approval on anything that moves money.

# PalPluss MCP Server (`@palpluss/mcp`)

`@palpluss/mcp` is the PalPluss [Model Context Protocol](https://modelcontextprotocol.io) server. Add it to an AI tool that supports MCP and you can ask, in plain language, things like:

* *"What's my PalPluss service wallet balance?"*
* *"Show my latest failed STK payments."*
* *"Add my KCB Paybill 522522, account 1188990011, as a payment channel."*
* *"Send KES 500 to 0712345678 as a refund for order 1042."*

> [!NOTE]
>
> Anything that moves money or changes where money lands **asks you to approve it first**. The approval request goes to your MCP client's interface, not to the AI model, so the model can't approve its own actions.

## Choose a key

For AI tools, create an **MCP key** in the [console](https://console.palpluss.com) under **API Keys → AI tools (MCP)**. PalPluss itself enforces the permissions, payout limits and approvals you choose for it, so they hold whichever tool uses the key. See [MCP keys and approvals](https://docs.palpluss.com/guides/mcp-keys.md).

To try things without real money, create the key in **test mode**. See [Test mode](https://docs.palpluss.com/guides/test-mode.md).

***

## Use the hosted server (no install)

Point any MCP client that supports remote servers at:

```text theme={null}
https://api.palpluss.com/mcp
```

Clients with sign-in support (OAuth) open the PalPluss console. You choose what the app may do, then allow it, and the app appears under **API Keys** as a connected app. You can change its permissions or revoke it there at any time. A connected app counts towards your limit of 10 API keys.

Clients without sign-in can send an MCP key instead: `Authorization: Bearer <your MCP key>`. The hosted server only accepts MCP keys and sign-ins, not standard keys.

```bash theme={null}
claude mcp add --transport http palpluss https://api.palpluss.com/mcp
```

***

## Or run it locally

You need Node.js 18 or later.

> [tab] Claude Code
>
> ```bash theme={null}
> claude mcp add palpluss -e PALPLUSS_API_KEY=your_api_key -- npx -y @palpluss/mcp
> ```

> [tab] Cursor
>
> Add this to `.cursor/mcp.json`:
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "palpluss": {
>       "command": "npx",
>       "args": ["-y", "@palpluss/mcp"],
>       "env": { "PALPLUSS_API_KEY": "your_api_key" }
>     }
>   }
> }
> ```

> [tab] VS Code
>
> Add this to `.vscode/mcp.json`. VS Code asks for the key and keeps it out of the file:
>
> ```json theme={null}
> {
>   "inputs": [
>     { "id": "palpluss-key", "type": "promptString", "description": "PalPluss API key", "password": true }
>   ],
>   "servers": {
>     "palpluss": {
>       "command": "npx",
>       "args": ["-y", "@palpluss/mcp"],
>       "env": { "PALPLUSS_API_KEY": "${input:palpluss-key}" }
>     }
>   }
> }
> ```

> [!WARNING]
>
> Your API key gives full access to your PalPluss account. Keep it in your editor's MCP configuration or an environment variable, and don't commit it to a repository.

***

## Tools

| Tool | Toolset | What it does | Needs approval |
| - | - | - | - |
| `palpluss_list_transactions` | read | List STK and B2C transactions, filtered by type or status | — |
| `palpluss_get_transaction` | read | One transaction: status, amount, receipt | — |
| `palpluss_get_wallet_balances` | read | Service wallet (fees) and B2C wallet (payout float) | — |
| `palpluss_list_payment_channels` | read | The Paybills and Tills money is collected into | — |
| `palpluss_get_payment_channel` | read | One channel | — |
| `palpluss_get_guardrails` | read | Enabled toolsets, limits and today's payout allowance | — |
| `palpluss_integration_guide` | read | Guidance for building PalPluss into an app | — |
| `palpluss_get_wallet_history` | read | Charges, top-ups, refunds and payouts on both wallets | — |
| `palpluss_estimate_fee` | read | The fee for an STK push or payout of a given amount | — |
| `palpluss_list_payment_links` | read | Your payment links | — |
| `palpluss_get_payment_link` | read | One payment link | — |
| `palpluss_list_approvals` | read | Payouts and channel changes held for, or past, approval | — |
| `palpluss_list_signing_domains` | read | Domains whose callbacks are [signed](https://docs.palpluss.com/guides/webhook-signing.md). Secrets are never returned | — |
| `palpluss_topup_service_wallet` | wallets | M-Pesa prompt to top up the service wallet | ✅ |
| `palpluss_topup_b2c_wallet` | wallets | M-Pesa prompt to top up the B2C wallet | ✅ |
| `palpluss_send_stk_push` | collect | Ask a customer to pay with an M-Pesa PIN prompt | ✅ |
| `palpluss_wait_for_payment` | collect | Wait up to 90 seconds for a final status | — |
| `palpluss_create_payment_link` | collect | Create a hosted payment page to share | — |
| `palpluss_disable_payment_link` | collect | Disable a link, or delete it to free a place under the 10-link limit | ✅ |
| `palpluss_create_payment_channel` | channels | Add a Paybill or Till, including a bank's Paybill | ✅ |
| `palpluss_update_payment_channel` | channels | Rename a channel or change its numbers | ✅ |
| `palpluss_set_default_payment_channel` | channels | Choose where STK payments go by default | ✅ |
| `palpluss_delete_payment_channel` | channels | Remove a channel | ✅ |
| `palpluss_send_payout` | payouts | Send money to an M-Pesa number | ✅ and limits |
| `palpluss_wait_for_approval` | payouts / channels | Wait for your decision on a held request | — |

### Who approves

* **MCP keys with approvals on:** payouts and channel changes wait for you in the console under **Approvals**. The tool reports that the request is waiting, and nothing happens until you approve it. Your editor doesn't ask as well.
* **Test keys:** nothing to approve, because the money is simulated.
* **Everything else:** your MCP client shows an approval prompt. If it can't (no MCP *elicitation* support), the action is refused.

### Choosing toolsets

`read` is always on. By default the server also enables `wallets` and `collect`. Channel changes and payouts stay off until you turn them on:

```bash theme={null}
PALPLUSS_MCP_TOOLSETS=read,wallets,collect,channels,payouts   # or: all
```

Set `PALPLUSS_MCP_READ_ONLY=true` to remove every tool that changes anything.

***

## How your account stays protected

Every call goes through the public PalPluss API, so the normal protections apply: rate limits, per-phone limits, STK abuse protection and the STK success-rate pause. On top of those, the MCP server adds:

**1. Your approval for every write**

Top-ups, STK pushes, payouts and channel changes send an approval request that your MCP client shows you. It includes the amount, the masked phone number and, for channels, what changes. If your client can't show approval requests (MCP *elicitation*), these tools refuse instead of going ahead.

**2. Payout limits**

Limits per payout, per day (total and count), and an optional allowlist of recipient numbers. They're checked before you're asked, and again just before the payout is sent. The MCP server enforces these limits itself, so each running copy keeps its own tally.

**3. No double payments**

Payouts and top-ups carry an idempotency key, so an AI retrying after a timeout can't pay twice. Give each separate payout its own reference.

**4. Protection against prompt injection**

Text written by customers or providers (references, descriptions, customer names, result messages) comes back marked `untrusted:`, and the server tells the AI never to act on instructions found in it.

**5. Privacy and an audit trail**

Phone numbers are masked in everything returned to the AI. Set `PALPLUSS_MCP_AUDIT_FILE` to record one JSON line per tool call; the API key is never logged.

***

## Configuration

| Variable | Default | Meaning |
| - | - | - |
| `PALPLUSS_API_KEY` | required | Your PalPluss API key |
| `PALPLUSS_MCP_TOOLSETS` | `read,wallets,collect` | Add `channels` and `payouts`, or use `all` |
| `PALPLUSS_MCP_READ_ONLY` | `false` | `true` removes every write tool |
| `PALPLUSS_MCP_APPROVAL` | `elicit` | `backend` relies on PalPluss: it needs an MCP key, and anything outside the key's permissions is refused. `none` turns approval requests off: use it only for automated tests against a fake or local API, never with a live key |
| `PALPLUSS_MCP_MAX_PAYOUT` | `5000` | Largest single payout (KES) |
| `PALPLUSS_MCP_DAILY_PAYOUT_TOTAL` | `20000` | Total payouts per day, Nairobi time (KES) |
| `PALPLUSS_MCP_DAILY_PAYOUT_COUNT` | `20` | Number of payouts per day |
| `PALPLUSS_MCP_PAYOUT_ALLOWLIST` | any number | Comma-separated phone numbers payouts may go to |
| `PALPLUSS_MCP_MAX_TOPUP` | `50000` | Largest wallet top-up (KES) |
| `PALPLUSS_MCP_MAX_STK` | `150000` | Largest STK push (KES) |
| `PALPLUSS_MCP_AUDIT_FILE` | not set | Path for the JSON-lines audit log |
| `PALPLUSS_MCP_STATE_FILE` | not set | Keep today's payout tally across restarts |

For example, to allow payouts of up to KES 2,000, only to two numbers:

```bash theme={null}
PALPLUSS_MCP_TOOLSETS=read,payouts \
PALPLUSS_MCP_MAX_PAYOUT=2000 \
PALPLUSS_MCP_PAYOUT_ALLOWLIST=0712345678,0722000111 \
npx -y @palpluss/mcp
```

***

## Running it over HTTP

For apps that connect over the network rather than starting a local process:

```bash theme={null}
PALPLUSS_MCP_HTTP_TOKEN=$(openssl rand -hex 24) \
PALPLUSS_API_KEY=your_api_key \
npx -y @palpluss/mcp --http --port 3333    # → http://127.0.0.1:3333/mcp
```

* Every request needs `Authorization: Bearer <PALPLUSS_MCP_HTTP_TOKEN>`.
* Each MCP client gets its own session, and approval requests work across the requests in it.
* With `PALPLUSS_MCP_HTTP_ALLOW_KEY_HEADER=true`, one endpoint can serve several PalPluss accounts. Each session starts with that account's key in `X-PalPluss-Api-Key` and stays bound to it.
* The server listens on `127.0.0.1` by default. Put it behind TLS before exposing it.

***

## Embedding in your own app

`createPalplussMcpServer()` runs the server inside your own Node.js app. Use an MCP key with `approval: 'backend'` to let PalPluss hold payouts for console approval, or pass an `approver` to show approvals in your own interface. For hosts running several instances, `handleStatelessMcpRequest()` serves one request at a time without sessions:

```ts theme={null}
import { createPalplussMcpServer } from '@palpluss/mcp';

const { server } = createPalplussMcpServer({
  apiKey: process.env.PALPLUSS_API_KEY!,
  toolsets: ['read', 'wallets', 'collect'],
});
await server.connect(transport); // stdio, Streamable HTTP, or an in-memory pair
```

The full embedding guide is in the [package repository](https://github.com/palpluss/palpluss-sdk/blob/main/packages/mcp/EMBEDDING.md).

***

## Troubleshooting

| What you see | What to do |
| - | - |
| `PALPLUSS_API_KEY is not set` | Add the key to the `env` block of your MCP configuration |
| `APPROVAL_UNAVAILABLE` | Your client can't show approval requests. Use a client that supports MCP elicitation, or do the action in the console |
| `APPROVAL_DECLINED` | You declined the request, so nothing was done |
| `AMOUNT_ABOVE_LIMIT`, `PAYOUT_DAILY_TOTAL_REACHED`, `PAYOUT_DAILY_COUNT_REACHED` | Limits set in your MCP configuration. Raise them there if you need to |
| `PAYOUT_RECIPIENT_NOT_ALLOWED` | The number isn't on `PALPLUSS_MCP_PAYOUT_ALLOWLIST` |
| `KYC_NOT_VERIFIED` | Payouts need approved KYC. Finish KYC in the console |
| `INSUFFICIENT_SCOPE` | The MCP key wasn't given that permission. Grant it under API Keys |
| `PAYOUT_ABOVE_KEY_LIMIT`, `PAYOUT_DAILY_TOTAL_REACHED` | Limits set on the MCP key in the console. Raise them there if you need to |
| `PENDING_APPROVAL` (in a result) | Waiting for you under **Approvals** in the console |
| `NOT_AVAILABLE_IN_TEST_MODE` | Test keys can't change channels or payment links. Use a live key |
| `INSUFFICIENT_FUNDS` | The B2C wallet doesn't have enough for the payout. Top it up first |

For PalPluss API errors in general, see [Errors](https://docs.palpluss.com/guides/errors.md).


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