DEV Community

Cover image for Why M-Pesa, Africa's Talking, and USSD are missing from AI agent tooling — and what I did about it
Gabriel Mahia
Gabriel Mahia

Posted on

Why M-Pesa, Africa's Talking, and USSD are missing from AI agent tooling — and what I did about it

I spend a lot of time building tools for Kenya. Payment flows, agricultural alerts, county budget dashboards. The infrastructure layer — M-Pesa, Africa's Talking, USSD — is battle-tested and used by hundreds of millions of people across East Africa.

And yet, when I went to build AI-powered tools that interact with this infrastructure, I found almost nothing. The model context protocol (MCP) ecosystem, which is becoming the standard way AI agents interact with external services, had zero African fintech entries. The context-hub registry — Andrew Ng's project for sharing API documentation as AI-consumable context — had no African payment or telecom providers.

This is the canonical Africa tech gap, but appearing in a new form: the AI tooling layer.

What's actually missing

M-Pesa processes more transactions by volume than PayPal does in Kenya. Africa's Talking reaches developers building on 20+ African telecom networks — Safaricom, MTN, Airtel, Vodacom, Telkom — from a single SDK. USSD (Unstructured Supplementary Service Data) is the dominant self-service channel for banking and government services across the continent, accessible on any phone, no internet required.

When AI agents need to work with payments, they have Stripe, PayPal, Braintree. When they need to send messages, they have Twilio. When they need to understand merchant flows, they have Square.

For any agent building something that actually works in Kenya, Uganda, Ghana, Rwanda — there was nothing.

What I built

Over the past week, I contributed six API documentation sets to context-hub and built an MCP server that gives AI agents direct access to M-Pesa and Africa's Talking.

context-hub contributions (PR #52):

  • africastalking/sms — bulk send, delivery webhooks, Kiswahili Unicode, county targeting
  • africastalking/ussd — full session handling, Redis state, bilingual menus, 182-char budget rules
  • africastalking/airtime — 8-country currency table, NGO payout patterns
  • safaricom/daraja — STK Push with password generation, C2B, B2C, phone normalization
  • paystack/payments — Nigeria/Ghana/Kenya/SA, HMAC webhook, mobile money, split payments
  • mtn-momo/collections — 17-country coverage, async polling, PUT webhook pattern

If these get merged, any developer using Claude Code, Cursor, or Copilot who runs chub get safaricom/daraja will get production-quality documentation as structured context. The patterns for STK Push authentication (the base64 password generation with timestamp is non-obvious), webhook verification, and phone number normalization (every Kenyan format maps to a different E.164 variant) are exactly the things that aren't documented clearly anywhere.

mpesa-mcp:

The MCP server (pip install mpesa-mcp or uvx mpesa-mcp) gives AI agents five tools:

mpesa_stk_push           — trigger payment prompt on customer's phone
mpesa_stk_query          — check STK Push status
mpesa_transaction_status — query any M-Pesa transaction by receipt
sms_send                 — 1–1,000 recipients across 20+ African networks
airtime_send             — programmatic airtime top-up
Enter fullscreen mode Exit fullscreen mode

It's submitted to punkpeye/awesome-mcp-servers — the first African fintech entry in that list (82k stars).

Why this matters beyond the tools themselves

African developers are dramatically underrepresented as contributors to AI infrastructure. The tools being built to power the next generation of AI applications are being built by and for markets with credit cards, Stripe accounts, and Twilio numbers. The result is predictable: agents that can't operate in the markets where the infrastructure is completely different.

The gap isn't technical — the M-Pesa API is well-designed, Africa's Talking is developer-friendly. The gap is presence. Nobody put in the work to document these APIs in the formats that AI tooling consumes.

That's a fixable problem.

What's next

The context-hub PR needs to merge. If it does, the distribution is significant — every Claude Code and Cursor user who runs chub get will have access to it.

I'm also building out the library layer: daraja-mock (local test server so you can develop M-Pesa integrations without a Safaricom account), kenya-sms (bilingual EN/Kiswahili SMS templates), pesa-cli (command-line M-Pesa operations). These packages make building African fintech applications feel like building anything else — installable, testable, documented.

The goal is to make "I'm building an app in Kenya" feel like a first-class engineering problem rather than a research project.


Tools: mpesa-mcp · context-hub PR · awesome-mcp-servers PR

Full ecosystem: github.com/gabrielmahia

Top comments (0)