AI tools
MCP for Cursor and Claude
The AFRIPEI MCP server lets an assistant in Cursor, Claude, or another MCP client create collections, send payouts, read balances, and register webhooks. It calls https://api.afripei.co.tz. It does not talk to the database.
A live secret key moves real TZS. Tell the assistant the amount and the phone number yourself. The server will not invent an idempotency key.
1. Create the account
Register at merchant.afripei.co.tz, or ask the assistant to call register_account with your email, a password of at least 12 characters, your name, and the business name. That call does not send a phone code. Collections start after the account is active.
2. Create a secret key
In the merchant portal, open Developers and create a secret key. Copy it once. Keys that can collect need payments.create. Keys that can send need payouts.create. A read-only key can check status and cannot move money.
3. Connect Cursor
In the project, add .cursor/mcp.json. Restart Cursor after you save it. The command runs the remote server from a checkout of this repository.
{
"mcpServers": {
"afripei": {
"command": "npx",
"args": ["tsx", "apps/mcp/src/remote.ts"],
"env": {
"AFRIPEI_API_URL": "https://api.afripei.co.tz",
"AFRIPEI_API_KEY": "sk_live_..."
}
}
}
}Run it from the repository root so npx tsx can see apps/mcp/src/remote.ts.
4. Connect Claude
Claude Desktop and Claude Code use the same command. Save this as the MCP server named afripei. Claude Code reads .mcp.json in the project. Restart the app after you save it.
{
"mcpServers": {
"afripei": {
"command": "npx",
"args": ["tsx", "apps/mcp/src/remote.ts"],
"env": {
"AFRIPEI_API_URL": "https://api.afripei.co.tz",
"AFRIPEI_API_KEY": "sk_live_..."
}
}
}
}5. Confirm the connection
- 1Ask the assistant to call
setup_instructionsif you have not created a key yet. - 2Call
check_connection. A balance object means the key is valid. - 3Call
create_paymentwithamount500.00,currencyTZS, the customer phone, and anidempotency_keyyou choose.
Tools
| Tool | What it does |
|---|---|
| setup_instructions | Prints the account and key steps. No key required. |
| register_account | Creates the merchant. No key required. |
| check_connection | Reads the balance to prove the key. |
| create_payment | Mobile-money prompt or control number. |
| get_payment / list_payments | Read one payment or a list. |
| create_payout | Mobile money or bank. |
| get_payout / list_payouts | Read payouts. |
| get_balance | Available, pending, and reserved. |
| list_balance_transactions | Ledger lines. |
| create_customer | Saves a phone number. |
| create_webhook | Registers an endpoint and returns the signing secret once. |
| list_events | Recent events stored for the merchant. |
The same actions exist on the REST API. MCP is a client of that API, so scopes on the key still apply. A key without payouts.create cannot send a payout from the assistant.
What the assistant must be told
Give it the amount, the phone, and the idempotency key. It should not invent a phone number or a key. A collection still waits for the customer to confirm. A payout still reserves real balance. Ask it to read the payment back before anyone treats the order as paid.
Codex
Codex can follow the same REST examples on this site. Point it at the quickstart and the reference. If it has an MCP client, the Cursor configuration above is the server to add. The API it calls is still https://api.afripei.co.tz.