Mpesa MCP logo

Mpesa MCP

by gabrielmahia

Connects AI agents to Safaricom M-PESA and Africa's Talking for payments, reconciliation, SMS, airtime, and fraud checks.

Install Mpesa MCP

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "gabrielmahia-mpesa-mcp": {
      "command": "uvx",
      "args": [
        "mpesa-mcp"
      ],
      "env": {
        "MPESA_CONSUMER_KEY": "YOUR_VALUE_HERE",
        "MPESA_CONSUMER_SECRET": "YOUR_VALUE_HERE",
        "MPESA_SHORTCODE": "YOUR_VALUE_HERE",
        "MPESA_PASSKEY": "YOUR_VALUE_HERE",
        "MPESA_CALLBACK_URL": "YOUR_VALUE_HERE",
        "MPESA_SANDBOX": "YOUR_VALUE_HERE",
        "AT_USERNAME": "YOUR_VALUE_HERE",
        "AT_API_KEY": "YOUR_VALUE_HERE"
      }
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Values are written into the snippet above so you can paste it as is. They never leave your browser.

Claude Code command
claude mcp add --env MPESA_CONSUMER_KEY=YOUR_VALUE_HERE --env MPESA_CONSUMER_SECRET=YOUR_VALUE_HERE --env MPESA_SHORTCODE=YOUR_VALUE_HERE --env MPESA_PASSKEY=YOUR_VALUE_HERE --env MPESA_CALLBACK_URL=YOUR_VALUE_HERE --env MPESA_SANDBOX=YOUR_VALUE_HERE --env AT_USERNAME=YOUR_VALUE_HERE --env AT_API_KEY=YOUR_VALUE_HERE --transport stdio gabrielmahia-mpesa-mcp -- uvx mpesa-mcp

Run in your terminal. Add --scope project to share it with your team through .mcp.json.

We couldn’t confirm it starts correctly

We hit an unexpected error while testing this listing automatically.

uvx mpesa-mcp

Rate limit exceeded, please try again later - you have reached the maximum number of concurrent E2B sandboxes (20). If you need more, please visit 'https://e2b.dev/docs/billing'

This is an experimental automated check and can have false negatives — missing environment variables, a slow cold install, etc. It doesn’t necessarily mean something’s wrong. Last checked .

Overview

gabrielmahia/mpesa-mcp connects MCP-compatible agents to Safaricom's Daraja API and Africa's Talking. It exposes tools for M-PESA collections, disbursements, account queries, reconciliation, recurring payments, Bill Manager, SIM-risk checks, SMS, and airtime. Install it with pip or run it through uvx, then configure provider credentials and sandbox or production mode. Reach for it when an agent needs to perform or verify East African mobile-money and communications tasks, with human confirmation for live money-moving operations.

Use cases

  • Collect customer payments with STK Push
  • Reconcile C2B transactions by date range
  • Disburse payroll or field-agent incentives
  • Send SMS alerts and airtime rewards
  • Screen recipients for recent SIM swaps

Key features

  • Safaricom Daraja M-PESA payment tools
  • Africa's Talking SMS and airtime delivery
  • Bill Manager and recurring Ratiba payments
  • Transaction reconciliation and reversal support
  • SIM-swap and IMSI-based risk queries
  • Sandbox mode with configurable spend limits

Tools23

What Mpesa MCP lets your agent do. Expand a tool for its parameters.

Verified live~3.5k tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

14/14 checks healthy over the last 118d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 17d ago via OSV.dev · mpesa-mcp (PyPI)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars7Stargazers on the source repository.
Last commit10d agoMost recent push to the default branch.
Install checkInconclusiveWe hit an unexpected error running the automated check.
Tools exposed23Callable tools this server registers over MCP.
Directory activity1 viewsConfig copies, upvotes, and views on AllMCPs.

How Mpesa MCP works

What gabrielmahia/mpesa-mcp does

gabrielmahia/mpesa-mcp gives an MCP client access to Kenya's Safaricom Daraja API and Africa's Talking services. Its M-PESA coverage includes STK Push collections, B2C disbursements, business payments to paybills, tills, and Pochi la Biashara wallets, transaction and balance queries, reversals, dynamic QR codes, tax remittance, recurring Ratiba payments, and Bill Manager invoices.

The server also supports operational and risk workflows. Agents can validate destination shortcodes, pull C2B transactions for reconciliation, check SIM-swap history, and retrieve Safaricom number data such as registration date, SIM age, last swap, and hashed IMSI. Africa's Talking tools send SMS to recipients across multiple African countries and deliver airtime to supported mobile networks.

How it works

The server runs as a local MCP process, commonly launched with uvx mpesa-mcp, and exposes the provider operations as tools. M-PESA access uses Safaricom Daraja credentials; SMS and airtime use Africa's Talking credentials. Daraja OAuth tokens are cached and refreshed automatically, while API errors are returned as structured results.

STK Push is asynchronous. After calling mpesa_stk_push, retain the returned checkout request ID and query mpesa_stk_query after 10–30 seconds. The STK interaction has an approximately 60-second window, and a dismissed prompt may not produce a callback, so several status checks are appropriate before concluding that it failed. Other asynchronous operations deliver results through MPESA_RESULT_URL.

Setup and configuration

Install the package with:

Terminal
pip install mpesa-mcp

Alternatively, run it directly with uvx mpesa-mcp. Configure the M-PESA consumer key and secret, shortcode, passkey, callback URL, and sandbox flag. SMS and airtime require an Africa's Talking username and API key. The sandbox uses Safaricom's test shortcode and Africa's Talking's sandbox username; production use requires live provider credentials and an appropriate callback endpoint.

Claude Desktop can start the server through its MCP configuration, while Claude Code can add it with claude mcp add mpesa -- uvx mpesa-mcp. Environment variables may be set in the client configuration or the shell.

Tools and capabilities

  • Start and query STK Push payments.
  • Send B2C disbursements and business-to-business payments.
  • Query transactions, balances, shortcode details, and C2B records.
  • Reverse transactions and generate payment QR codes.
  • Create, manage, and cancel Ratiba and Bill Manager payments.
  • Remit KRA tax using a payment registration number.
  • Check SIM swaps and Safaricom identity data for risk workflows.
  • Send SMS and airtime across supported African networks.

Limitations and notes

Live money-moving, SMS, and airtime tools require confirmation and are subject to configured payment, session, recipient, and SMS-recipient limits. mpesa_b2c, business payment, status, balance, and reversal operations require initiator and security-credential configuration. Airtime is not actually sent when Africa's Talking runs with AT_USERNAME=sandbox, and currency is checked against the recipient's country.

The server validates Kenyan phone numbers, uses HTTPS for Daraja calls, and logs tool activity with phone numbers represented by truncated SHA-256 hashes. Sandbox testing should be completed before production use, and a person should approve live financial or messaging actions.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Mpesa MCP

gabrielmahia/mpesa-mcp is an MCP server that connects AI agents to Safaricom's Daraja M-PESA API and Africa's Talking. Its main tools handle STK Push payments, transaction queries, disbursements, SMS, airtime, reconciliation, reversals, Bill Manager, recurring payments, and SIM-risk checks across supported African services.

Install it with `pip install mpesa-mcp` or run it directly with `uvx mpesa-mcp`. Configure the provider environment variables before starting the MCP process. Claude Desktop can launch it from its MCP configuration, and Claude Code can add it with `claude mcp add mpesa -- uvx mpesa-mcp`.

Set the M-PESA consumer key, consumer secret, shortcode, passkey, callback URL, and `MPESA_SANDBOX=true`. The documented sandbox shortcode is `174379`, and each developer must create a Safaricom developer app to obtain consumer credentials. Use a publicly reachable HTTPS callback URL for callback-based operations.

Call `mpesa_stk_query` with the checkout request ID returned by `mpesa_stk_push` after waiting 10–30 seconds. Poll two or three times during the roughly 60-second STK window because a dismissed prompt may not trigger a callback. Result code 0 indicates success, 1032 cancellation, and 1037 timeout.

Yes, it runs as a standard MCP process and can be used by MCP-compatible clients such as Cursor. Start it with `uvx mpesa-mcp` and provide the required environment variables through the client's MCP configuration. The documented examples specifically show Claude Desktop and Claude Code configuration.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewMpesa MCP AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/gabrielmahia-mpesa-mcp?style=directory)](https://allmcps.com/mcp/gabrielmahia-mpesa-mcp)
HTML Embed
<a href="https://allmcps.com/mcp/gabrielmahia-mpesa-mcp"><img src="https://allmcps.com/api/badge/gabrielmahia-mpesa-mcp?style=directory" alt="Mpesa MCP on AllMCPs" /></a>