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.

Cursor
{
  "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.

Claude
{
  "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

  1. 1Ask the assistant to call setup_instructions if you have not created a key yet.
  2. 2Call check_connection. A balance object means the key is valid.
  3. 3Call create_payment with amount 500.00, currency TZS, the customer phone, and an idempotency_key you choose.

Tools

ToolWhat it does
setup_instructionsPrints the account and key steps. No key required.
register_accountCreates the merchant. No key required.
check_connectionReads the balance to prove the key.
create_paymentMobile-money prompt or control number.
get_payment / list_paymentsRead one payment or a list.
create_payoutMobile money or bank.
get_payout / list_payoutsRead payouts.
get_balanceAvailable, pending, and reserved.
list_balance_transactionsLedger lines.
create_customerSaves a phone number.
create_webhookRegisters an endpoint and returns the signing secret once.
list_eventsRecent 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.