mpesa-mcp
mpesa-mcp
東アフリカのフィンテックAPI用MCPサーバー — M-Pesa (Safaricom Daraja) および Africa's Talking
AIエージェントに、M-Pesa決済のトリガー、取引状況の確認、SMS送信、および20以上のアフリカの通信ネットワーク間での通信料チャージ機能を提供します。
なぜこれが必要なのか
M-Pesaは、アフリカにおいてPayPalよりも1日あたりの取引処理数が多いサービスです。Africa's Talkingは、SMSやUSSDを通じて20カ国以上のベーシックフォンユーザーにリーチできます。しかし、どちらもMCPサーバーを提供していません。
つまり、現在構築されているすべてのAIエージェント(Claude、GPT、Gemini、またはMCP互換ランタイム)は、カスタム統合作業なしではM-Pesa決済をトリガーしたり、スワヒリ語のSMSを送信したりすることができません。
mpesa-mcp は、pip install 一つでそのギャップを埋めます。
Related MCP server: M-Pesa MCP Server
ツール
ツール | 説明 |
| 顧客のM-Pesa電話機でSTKプッシュ決済プロンプトをトリガーする |
| STKプッシュリクエストのステータスを確認する |
| レシート番号でM-Pesaの取引を照会する |
| アフリカのネットワーク全体で1〜1,000人の受信者にSMSを送信する |
| あらゆる加入者に通信料をチャージする (KES, NGN, GHS, UGXなど) |
対応範囲
M-Pesa: ケニア (Safaricom Daraja v3) — STKプッシュ、C2B、取引ステータス
SMS/通信料: ケニア、ナイジェリア、ガーナ、タンザニア、ウガンダ、ルワンダ、南アフリカなど、Africa's Talking経由で15カ国以上
Glama (ホスト型MCP)
mpesa-mcpは、Glama 上でホスト型MCPサーバーとして利用可能です:
インストール
pip install mpesa-mcpまたは uvx で直接実行します:
uvx mpesa-mcp設定
サーバーを起動する前に、以下の環境変数を設定してください:
# 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サンドボックス認証情報
M-Pesaサンドボックス: https://developer.safaricom.co.ke — 無料アプリを作成してテスト用認証情報を取得してください。
テスト用ショートコード:
174379テスト用パスキー:
bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919
Africa's Talkingサンドボックス: https://account.africastalking.com — username=sandbox を使用し、APIキーは何でも構いません。
Claude Desktopでの使用方法
~/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"
}
}
}
}Claude Codeでの使用方法
claude mcp add mpesa -- uvx mpesa-mcpclaude を実行する前に、シェルで環境変数を設定してください。
プロンプト例
接続後、AIエージェントに以下のように依頼できます:
"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]"
実世界のシナリオ
フィールドエージェントへの支払い送金
"Send KES 300 STK Push to each of these 12 field agents for today's data collection: [list]"
エージェントは12件のSTKプッシュを順次トリガーし、各 checkout_request_id を追跡して確認をポーリングします。ユーザー側でコードを書く必要はありません。
農家へのアラート + 通信料チャージ
"SMS these 200 Garissa farmers that the river is rising. Then top up KES 20 airtime each so they can call in reports."
1つのプロンプトで、Safaricom、Airtel、Telkom全体で200件のSMS送信と200件の通信料チャージを行います。
支払い照合
"Check whether receipt OKL8M3B2HF was a successful payment and how much it was for"
Claudeを使用してM-Pesaの取引をリアルタイムで検証するサポートエージェントに役立ちます。
ツールのアノテーション
すべてのツールは MCPツールアノテーション を宣言しているため、クライアントは適切に呼び出しを制御できます:
ツール | readOnly | destructive | idempotent |
| ❌ | ✅ | ❌ |
| ✅ | ❌ | ✅ |
| ✅ | ❌ | ✅ |
| ❌ | ✅ | ❌ |
| ❌ | ✅ | ❌ |
Claude Desktopおよびその他のMCPクライアントは、支払い、SMS、または通信料操作をトリガーする前に確認を求めます。
サーバー検出
機能は、新しいMCPサーバーカード標準である .well-known/mcp.json を通じてアドバタイズされます。レジストリやブラウザは、サーバーに接続することなく、このサーバーのツールをインデックス化できます。
# Check capabilities
curl https://raw.githubusercontent.com/gabrielmahia/mpesa-mcp/main/.well-known/mcp.jsonテストと精度
MCPエコシステムのベンチマーク (CData, 2026) によると、ほとんどのMCPサーバーは複雑なクエリに対して60〜75%の精度であり、特に書き込み操作のサイレントエラーやパラメータの不完全な適用が課題となっています。
mpesa-mcpは、3つのケニアの電話番号形式すべて、境界値の金額、および欠落しているオプションフィールドに対してテストされています:
pytest tests/ -v # run full suite
pytest tests/test_phone_formats.py # format normalization
pytest tests/test_boundary_amounts.py # min/max amount edge cases書き込み操作(STKプッシュ、SMS、通信料)は、API呼び出しが行われる前に明示的な検証が行われます。
エコシステムの背景 — Mojaloop + MCP
Mojaloop (ゲイツ財団が出資) は、東アフリカおよびそれ以外の地域のDFSP間で銀行、モバイルマネーウォレット、加盟店を接続する、決済の相互運用性を扱います。
mpesa-mcp は、AIエージェントのツールレイヤーを扱います。これにより、AIコーディングアシスタントがプログラムでM-Pesa決済をトリガーおよび照会できるようになります。
これらは補完的な関係にあります:
Mojaloop: 金融プロバイダー間の相互運用性レール
mpesa-mcp: AIエージェントをそれらのレールに接続するMCPインターフェースレイヤー
このパターンの詳細については、Mojaloopドキュメントへの貢献 を参照してください。
MCP vs A2A — 2つの異なるプロトコル
mpesa-mcpは、AIエージェントがツールとどのように対話するかを定義する MCP (Model Context Protocol) を実装しています。
これとは別に、エージェント同士がどのように対話するかを処理する補完的なプロトコル A2A (Agent-to-Agent) があります。これらは異なる問題を解決し、連携して機能します:
MCP: AIエージェント → mpesa-mcp → Daraja API / Africa's Talking
A2A: オーケストレーターエージェント ↔ 支払いサブエージェント ↔ 通知サブエージェント
ほとんどの統合ではMCPのみで十分です。A2Aは、支払いワークフローが他の専門エージェントと調整を行うマルチエージェントシステムを構築する場合に関連してきます。
開発
git clone https://github.com/gabrielmahia/mpesa-mcp
cd mpesa-mcp
pip install -e ".[dev]"
pytest tests/ -vセキュリティ
APIキーをコミットしないでください。環境変数またはシークレットマネージャーを使用してください。 脆弱性の報告先: contact@aikungfu.dev
ライセンス
MIT — © 2026 Gabriel Mahia
最新情報の入手
新しいリリースや東アフリカのAPI開発に関する通知を受け取るには: 更新情報を購読する →
または、GitHubでこのリポジトリをウォッチしてリリース通知を受け取ってください。
関連パッケージ
パッケージ | インストール | 説明 |
| ケニアの干ばつインテリジェンスMCPサーバー | |
| 東アフリカの市民AI SDK |
関連パッケージ
すべてMITライセンス · すべて東アフリカ市民AIスタックの一部
パッケージ | インストール | 説明 |
| ケニアの干ばつインテリジェンスMCPサーバー | |
| ケニアの健康データMCP — NHIF、施設、母子保健、権利 | |
| 東アフリカの市民AI SDK |
ポートフォリオ全体: gabrielmahia.github.io
Available Tools
5 toolsairtime_sendSend AirtimeADestructive
Send airtime top-up to any MTN/Safaricom/Airtel/Vodafone subscriber. Common use: NGO field incentives, survey rewards, agent payouts. No real airtime sent in sandbox mode.
Inputs: phone (required), amount (required), currency_code. Returns: object
mpesa_stk_pushM-Pesa STK PushADestructive
Trigger an M-Pesa STK Push — sends a payment prompt to the customer's phone. The customer enters their M-Pesa PIN to complete payment. Returns a CheckoutRequestID to track the transaction with mpesa_stk_query. Async: use mpesa_stk_query after 10-30 seconds to check completion.
Inputs: phone (required), amount (required), account_ref (required), description. Returns: object
mpesa_stk_queryM-Pesa STK QueryARead-onlyIdempotent
Check the status of an STK Push request. Poll this 10-30 seconds after calling mpesa_stk_push. ResultCode 0 = success, 1032 = cancelled by user, 1037 = timed out.
Inputs: checkout_request_id (required). Returns: object
mpesa_transaction_statusM-Pesa Transaction StatusARead-onlyIdempotent
Query the status of any M-Pesa transaction by receipt number. Requires MPESA_INITIATOR_NAME and MPESA_SECURITY_CREDENTIAL env vars.
Inputs: transaction_id (required). Returns: object
sms_sendSend SMSADestructive
Send SMS to one or many recipients via Africa's Talking. Supports up to 1,000 recipients per call. Works across Kenya, Nigeria, Ghana, Tanzania, Uganda, and 15+ African markets. Returns per-recipient status and cost.
Inputs: message (required), recipients (required), sender_id. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct function: airtime sending, STK push initiation, STK push status query, transaction status by receipt, and SMS sending. There is no overlap or ambiguity.
Most tools follow a verb_noun or noun_verb pattern (e.g., airtime_send, sms_send, mpesa_stk_push), but mpesa_transaction_status lacks a verb, breaking the pattern slightly.
With 5 tools, the server is well-scoped for its purpose, covering core M-Pesa and SMS operations without being too few or too many.
The set covers STK push initiation/query and basic transaction status, but lacks airtime status, B2C/C2B transfers, or account balance queries, leaving notable gaps for a full M-Pesa integration.
Maintenance
Related MCP Connectors
South African MCP server for airtime, data, SMS, VAS, electricity, balance, and network lookup.
MCP Server for agents to onboard, pay, and provision services autonomously with InFlow
MCP server for Modern Treasury — payment orders, transactions, counterparties and ledgers.
MCP server for SuperPhone — contacts, conversations, tags and consent-based text messages.
Related MCP Servers
FlicenseNot gradedqualityDmaintenanceOpen-source MCP server that streamlines payment integration for AI agents and financial apps in Africa, providing unified tools for providers like M-Pesa.1-- FlicenseNot gradedqualityDmaintenanceAn experimental MCP server that lets AI agents interact with guarded payment workflows through typed tools, enabling safe agent-assisted payments with M-Pesa and mock Airtel Money.3-
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server that integrates Safaricom's M-PESA Daraja API with Claude, enabling natural language payment processing and real-time transaction notifications.3-
- AlicenseNot gradedqualityDmaintenanceMCP server for the Lipila payment gateway, enabling AI agents to initiate mobile money and card collections, disburse funds, check transaction statuses, and verify webhook callbacks.1ISC