VOOZH about

URL: https://pypi.org/project/mpesa-mcp/

โ‡ฑ mpesa-mcp ยท PyPI


Skip to main content

mpesa-mcp 0.1.9

pip install mpesa-mcp

Latest release

Released:

MCP server for M-Pesa (Safaricom Daraja) and Africa's Talking APIs

Navigation

Verified details

These details have been verified by PyPI
Maintainers
๐Ÿ‘ Avatar for gmahia from gravatar.com
gmahia
Meta

Unverified details

These details have not been verified by PyPI
Project links
Meta
  • License Expression: MIT
    SPDX License Expression
  • Tags mcp , model-context-protocol , mpesa , m-pesa , safaricom , daraja , africastalking , kenya , africa , fintech , payments , sms
  • Requires: Python >=3.10
  • Provides-Extra: dev

Project description

mpesa-mcp

MCP server for East African fintech APIs โ€” M-Pesa (Safaricom Daraja) and Africa's Talking

Give your AI agent the ability to trigger M-Pesa payments, check transaction status, send SMS, and top up airtime across 20+ African telecom networks.

๐Ÿ‘ Tests
๐Ÿ‘ PyPI
๐Ÿ‘ License: MIT
๐Ÿ‘ Glama Score
๐Ÿ‘ Glama
๐Ÿ‘ NSA MCP Compliant

๐Ÿ‘ mpesa-mcp MCP server

Why this exists

M-Pesa processes more transactions per day than PayPal does in Africa. Africa's Talking reaches users in 20+ countries on basic phones via SMS and USSD. Neither has an MCP server.

This means every AI agent built today โ€” Claude, GPT, Gemini, or any MCP-compatible runtime โ€” cannot trigger an M-Pesa payment or send a Kiswahili SMS without custom integration work.

mpesa-mcp closes that gap in one pip install.

Tools

Tool Description
mpesa_stk_push Trigger STK Push payment prompt on customer's M-Pesa phone
mpesa_stk_query Check status of an STK Push request
mpesa_transaction_status Query any M-Pesa transaction by receipt number
sms_send Send SMS to 1โ€“1,000 recipients across African networks
airtime_send Send airtime top-up to any subscriber (KES, NGN, GHS, UGX, etc.)

Coverage

  • M-Pesa: Kenya (Safaricom Daraja v3) โ€” STK Push, C2B, transaction status
  • SMS/Airtime: Kenya, Nigeria, Ghana, Tanzania, Uganda, Rwanda, South Africa, and 15+ more via Africa's Talking

Glama (hosted MCP)

mpesa-mcp is available as a hosted MCP server on Glama:

๐Ÿ‘ mpesa-mcp MCP server
๐Ÿ‘ mpesa-mcp score

Security โ€” NSA MCP Guidance Compliant

mpesa-mcp was updated in response to NSA CSI U/OO/6030316-26 (May 2026) โ€” the NSA Artificial Intelligence Security Center's Cybersecurity Information Sheet on Model Context Protocol security.

This makes mpesa-mcp the first African MCP server to document compliance against the NSA's MCP security framework.

NSA Control Implementation
Parameter validation KE phone regex ^254[17]\d{8}$ + amount bounds [1โ€“150,000 KES]
Audit logging Structured log per tool call; phone numbers SHA-256 hashed
Token lifecycle OAuth token cached with expiry; auto-refreshed
Error containment Structured error dicts; no raw exception propagation
HTTPS enforcement All Daraja API calls HTTPS-only
No hardcoded secrets All credentials via environment variables

See SECURITY.md for the full compliance table.

Reference: NSA CSI_MCP_SECURITY.pdf โ€” May 2026, UNCLASSIFIED

Install

pipinstallmpesa-mcp

Or run directly with uvx:

uvxmpesa-mcp

Configuration

Set these environment variables before starting the server:

# M-Pesa (Safaricom Daraja)
MPESA_CONSUMER_KEY=your_consumer_key
MPESA_CONSUMER_SECRET=your_consumer_secret
MPESA_SHORTCODE=174379# sandbox test shortcode
MPESA_PASSKEY=your_passkey
MPESA_CALLBACK_URL=https://yourdomain.com/mpesa/callback
MPESA_SANDBOX=true# set false for production

# Africa's Talking
AT_USERNAME=sandbox# your AT username (sandbox for testing)
AT_API_KEY=your_at_api_key

Sandbox credentials

M-Pesa sandbox: https://developer.safaricom.co.ke โ€” create a free app to get test credentials.

  • Test shortcode: 174379
  • Test passkey: bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919

Africa's Talking sandbox: https://account.africastalking.com โ€” use username=sandbox, any API key.

Usage with Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):

{
"mcpServers":{
"mpesa":{
"command":"uvx",
"args":["mpesa-mcp"],
"env":{
"MPESA_CONSUMER_KEY":"your_key",
"MPESA_CONSUMER_SECRET":"your_secret",
"MPESA_SHORTCODE":"174379",
"MPESA_PASSKEY":"your_passkey",
"MPESA_CALLBACK_URL":"https://yourdomain.com/mpesa/callback",
"MPESA_SANDBOX":"true",
"AT_USERNAME":"sandbox",
"AT_API_KEY":"your_at_key"
}
}
}
}

Usage with Claude Code

claudemcpaddmpesa--uvxmpesa-mcp

Set env vars in your shell before running claude.

Example prompts

Once connected, you can ask your AI agent:

"Send KES 500 STK Push to +254712345678 for order #1234"

"Check if the payment QKL8ABC123 has been received"

"Send an SMS to these 50 farmers with today's maize price: [list]"

"Top up KES 50 airtime for our field agents: [list of numbers]"

Real-world scenarios

Field agent payment dispatch

"Send KES 300 STK Push to each of these 12 field agents for today's data collection: [list]"

The agent triggers 12 sequential STK pushes, tracks each checkout_request_id, and polls for confirmation โ€” without any code from you.

Farmer alert + airtime

"SMS these 200 Garissa farmers that the river is rising. Then top up KES 20 airtime each so they can call in reports."

One prompt โ†’ 200 SMS messages and 200 airtime top-ups across Safaricom, Airtel, and Telkom.

Payment reconciliation

"Check whether receipt OKL8M3B2HF was a successful payment and how much it was for"

Useful for support agents using Claude to verify M-Pesa transactions in real time.

Tool annotations

All tools declare MCP tool annotations so clients can gate calls appropriately:

Tool readOnly destructive idempotent
mpesa_stk_push โŒ โœ… โŒ
mpesa_stk_query โœ… โŒ โœ…
mpesa_transaction_status โœ… โŒ โœ…
sms_send โŒ โœ… โŒ
airtime_send โŒ โœ… โŒ

Claude Desktop and other MCP clients will request confirmation before triggering payment, SMS, or airtime operations.

Server discovery

Capabilities are advertised via .well-known/mcp.json โ€” the emerging MCP Server Cards standard. Registries and browsers can index this server's tools without connecting to it.

# Check capabilities
curlhttps://raw.githubusercontent.com/gabrielmahia/mpesa-mcp/main/.well-known/mcp.json

Testing and accuracy

The MCP ecosystem benchmark (CData, 2026) found most MCP servers accurate 60โ€“75% of the time on complex queries โ€” particularly silent failures on write operations and partial parameter application.

mpesa-mcp is tested against all three Kenyan phone number formats, boundary amount values, and missing optional fields:

pytesttests/-v# run full suite
pytesttests/test_phone_formats.py# format normalization
pytesttests/test_boundary_amounts.py# min/max amount edge cases

Write operations (STK push, SMS, airtime) have explicit validation before any API call is made.

Ecosystem context โ€” Mojaloop + MCP

Mojaloop (funded by the Gates Foundation) handles payment interoperability โ€” connecting banks, mobile money wallets, and merchants across DFSPs in East Africa and beyond.

mpesa-mcp handles the AI agent tooling layer โ€” enabling AI coding assistants to trigger and query M-Pesa payments programmatically.

These are complementary:

  • Mojaloop: the interoperability rails between financial providers
  • mpesa-mcp: the MCP interface layer that connects AI agents to those rails

See the Mojaloop documentation contribution for more on this pattern.

MCP vs A2A โ€” two different protocols

mpesa-mcp implements MCP (Model Context Protocol) โ€” how an AI agent talks to tools.

There is a complementary protocol, A2A (Agent-to-Agent), which handles how agents talk to each other. They solve different problems and work together:

  • MCP: Your AI agent โ†’ mpesa-mcp โ†’ Daraja API / Africa's Talking
  • A2A: Orchestrator agent โ†” payment sub-agent โ†” notification sub-agent

For most integrations you only need MCP. A2A becomes relevant when you're building multi-agent systems where a payment workflow coordinates with other specialized agents.


Development

gitclonehttps://github.com/gabrielmahia/mpesa-mcp
cdmpesa-mcp
pipinstall-e".[dev]"
pytesttests/-v

Security

Do not commit API keys. Use environment variables or a secrets manager.
Report vulnerabilities to: contact@aikungfu.dev

License

MIT โ€” ยฉ 2026 Gabriel Mahia

Stay updated

Get notified of new releases and East African API developments: Subscribe to updates โ†’

Or watch this repo on GitHub for release notifications.

Sibling packages

Package Install Description
wapimaji-mcp pip install wapimaji-mcp Kenya drought intelligence MCP server
civic-agent-kit pip install civic-agent-kit East African civic AI SDK

Related packages

All MIT ยท All part of the East African civic AI stack

Package Install Description
wapimaji-mcp pip install wapimaji-mcp Kenya drought intelligence MCP server
kenya-health-mcp pip install kenya-health-mcp Kenya health data MCP โ€” NHIF, facilities, maternal, rights
civic-agent-kit pip install civic-agent-kit East African civic AI SDK

Full portfolio: gabrielmahia.github.io

Project details

Verified details

These details have been verified by PyPI
Maintainers
๐Ÿ‘ Avatar for gmahia from gravatar.com
gmahia
Meta

Unverified details

These details have not been verified by PyPI
Project links
Meta
  • License Expression: MIT
    SPDX License Expression
  • Tags mcp , model-context-protocol , mpesa , m-pesa , safaricom , daraja , africastalking , kenya , africa , fintech , payments , sms
  • Requires: Python >=3.10
  • Provides-Extra: dev

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpesa_mcp-0.1.9.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

Filter files by name, interpreter, ABI, and platform.

If you're not sure about the file name format, learn more about wheel file names.

Copy a direct link to the current filters

mpesa_mcp-0.1.9-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file mpesa_mcp-0.1.9.tar.gz.

File metadata

  • Download URL: mpesa_mcp-0.1.9.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for mpesa_mcp-0.1.9.tar.gz
Algorithm Hash digest
SHA256 d1d89fbaebfdaad49cdf670bb901388415d77bdb0b2a8c9fe15a38dc72d1fb8d
MD5 ef5ef3ca1f06a537bfc6570df40d5683
BLAKE2b-256 2d2eeac4e9235860bb7719ffb5851f636554881e793dbe2a7f94554843cf4461

See more details on using hashes here.

File details

Details for the file mpesa_mcp-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: mpesa_mcp-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for mpesa_mcp-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 2bbd007e13f71233525e2b1fed74c488907783699438abd443596e12e2b3964f
MD5 78833f0d48d9f2bcfe1791f0de953f62
BLAKE2b-256 9a36dd907523f6c0d5736316967db0c26a49f3dc4b28de24d260c525bc8142e9

See more details on using hashes here.

Supported by

๐Ÿ‘ Image
AWS Cloud computing and Security Sponsor ๐Ÿ‘ Image
Datadog Monitoring ๐Ÿ‘ Image
Depot Continuous Integration ๐Ÿ‘ Image
Fastly CDN ๐Ÿ‘ Image
Google Download Analytics ๐Ÿ‘ Image
Pingdom Monitoring ๐Ÿ‘ Image
Sentry Error logging ๐Ÿ‘ Image
StatusPage Status page