mpesa-mcp

v0.7.3
io.github.gabrielmahia/mpesa-mcp Checked 2 days ago Published 22 days ago

M-Pesa Daraja and Africa's Talking MCP server: 24 tools; live payments and SMS need confirmation.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

mpesa_stk_push M-Pesa STK Push

Send an M-PESA payment prompt (STK Push) to a customer's phone for them to approve with their PIN. Use when a customer is to pay your business shortcode. The customer must approve on the handset: nothing is taken without their PIN. Returns success, checkout_request_id, merchant_request_id, response code, message and the sandbox flag; success means the prompt was SENT, not that the customer paid, so poll mpesa_stk_query. In live mode it prompts a real phone.

ParameterTypeDescription
account_ref *stringAccount reference shown to customer on phone (max 12 chars)
amount *integerAmount in KES (whole number, min 1, max 150000)
phone *stringCustomer phone (any Kenyan format: +254..., 07..., 254...)
descriptionstringTransaction description (max 13 chars)

mpesa_stk_query M-Pesa STK Query

Check the status of an STK Push using its checkout_request_id. Use 10 to 30 seconds after mpesa_stk_push to learn whether the customer paid, cancelled or the request is still processing. Returns the Daraja status for that request with the sandbox flag. Read-only.

ParameterTypeDescription
checkout_request_id *stringCheckoutRequestID from mpesa_stk_push response

mpesa_ratiba_create M-Pesa Ratiba (standing order)

Create an M-PESA Ratiba standing order: a recurring payment from a customer's M-PESA to your paybill or till (subscriptions, loan or SACCO repayments, school fees). Use when a customer has agreed to pay the same amount on a schedule. Safaricom sends the customer a PIN prompt; nothing is created until they approve on their phone, and the final result arrives at the callback URL. Returns success (the request was ACCEPTED, not yet approved), the response reference, and the schedule: frequency, dates, number of payments and total commitment in KES (null where Safaricom's frequency is ambiguous). R…

ParameterTypeDescription
account_ref *stringAccount reference the customer sees, e.g. a loan or member number (1 to 12 characters)
amount *integerAmount in KES taken on EACH payment (whole number, 1 to 150000)
end_date *stringLast date the order may run, YYYY-MM-DD or YYYYMMDD; on or after the start date
phone *stringCustomer phone that pays, any Kenyan format (+254..., 07..., 254...)
standing_order_name *stringName of the standing order; must be unique for this customer (Safaricom rejects a repeat), 1 to 60 characters
start_date *stringFirst payment date, YYYY-MM-DD or YYYYMMDD; today or later
descriptionstringShort description; Safaricom keeps the first 13 characters
frequencystringHow often: one_off, daily, weekly, monthly, bi_monthly, quarterly, half_year or yearly; Safaricom's codes 1 to 8 are also accepted
receiver_typestringWhere the money goes: paybill (your MPESA_SHORTCODE as a PayBill) or till (as a Buy Goods till)

mpesa_b2c M-Pesa B2C

Send money from your business shortcode to a customer's phone (Business to Customer). Use only when the user has explicitly approved this exact payment. MOVES MONEY: in live mode the person approves this exact payment through the client (a client that cannot show that prompt is refused by default; only in the opt-in param and auto modes is confirm_send=true, set only after the user approves, the fallback), and it refuses amounts above the per-transaction cap (MPESA_MAX_AMOUNT_KES, default KES 20,000); the sandbox is never restricted. Returns success, the Daraja response and the sandbox flag, o…

ParameterTypeDescription
amount *integerAmount in KES to send
phone *stringRecipient phone number (any Kenyan format)
command_idstringSalaryPayment | BusinessPayment | PromotionPayment
confirm_sendbooleanRequired in live mode: set true ONLY after the user has explicitly approved this exact payment (recipient and amount). Ignored in sandbox.
occasionstringOptional occasion label
remarksstringRemarks (max 100 chars)

mpesa_business_paybill Business Pay Bill (B2B)

Pay from your business shortcode directly to another paybill number (B2B PayBill). Use only when the user has explicitly approved this exact payment. MOVES MONEY: in live mode the person approves this exact payment through the client (a client that cannot show that prompt is refused by default; only in the opt-in param and auto modes is confirm_send=true, set only after the user approves, the fallback), and it refuses amounts above the per-transaction cap (MPESA_MAX_AMOUNT_KES, default KES 20,000); the sandbox is never restricted. Returns success, the Daraja response and the sandbox flag, or a…

ParameterTypeDescription
account_reference *stringAccount number at destination paybill
amount *integerAmount in KES
receiver_paybill *stringDestination paybill shortcode
confirm_sendbooleanRequired in live mode: set true ONLY after the user has explicitly approved this exact payment (recipient and amount). Ignored in sandbox.
remarksstringTransaction remarks

mpesa_business_buygoods Business Buy Goods (B2B)

Pay from your business shortcode to a till (Buy Goods) number. Use only when the user has explicitly approved this exact payment. MOVES MONEY: in live mode the person approves this exact payment through the client (a client that cannot show that prompt is refused by default; only in the opt-in param and auto modes is confirm_send=true, set only after the user approves, the fallback), and it refuses amounts above the per-transaction cap (MPESA_MAX_AMOUNT_KES, default KES 20,000); the sandbox is never restricted. Returns success, the Daraja response and the sandbox flag, or a refusal saying what…

ParameterTypeDescription
amount *integerAmount in KES
till_number *stringDestination till number (Buy Goods)
confirm_sendbooleanRequired in live mode: set true ONLY after the user has explicitly approved this exact payment (recipient and amount). Ignored in sandbox.
remarksstringTransaction remarks

mpesa_business_pochi Business to Pochi la Biashara

Pay from your business shortcode to a Pochi la Biashara micro-business wallet by phone number. Use only when the user has explicitly approved this exact payment. MOVES MONEY: in live mode the person approves this exact payment through the client (a client that cannot show that prompt is refused by default; only in the opt-in param and auto modes is confirm_send=true, set only after the user approves, the fallback), and it refuses amounts above the per-transaction cap (MPESA_MAX_AMOUNT_KES, default KES 20,000); the sandbox is never restricted. Returns success, the Daraja response and the sandbo…

ParameterTypeDescription
amount *integerAmount in KES
phone *stringPochi wallet owner phone number
confirm_sendbooleanRequired in live mode: set true ONLY after the user has explicitly approved this exact payment (recipient and amount). Ignored in sandbox.
remarksstringRemarks

mpesa_transaction_status M-Pesa Transaction Status

Query the status of any M-PESA transaction by its receipt number. Use when you need to confirm what happened to a payment, or to reconcile one against your records after an STK Push, B2C or reversal. Returns the Daraja response for that transaction, whose full details can arrive asynchronously on your result URL. Read-only; it changes nothing.

ParameterTypeDescription
transaction_id *stringM-Pesa receipt number e.g. QKL8XXXXXX

mpesa_account_balance M-Pesa Account Balance

Query the balance of your business M-PESA account (shortcode or till). Use when someone asks how much is in the account. identifier_type 4 (default) means an organisation shortcode. Returns the Daraja response, with the balance delivered on your result URL. Read-only.

ParameterTypeDescription
identifier_typestring1=MSISDN, 2=Till, 4=Shortcode/Paybill
remarksstringQuery remarks

mpesa_query_org_info Query Org Info

Validate a shortcode and return its registered organisation name and tariff type. Use before paying a paybill or till to confirm who will actually receive the money, which helps catch a mistyped number or a lookalike business name. Returns the Daraja organisation details (registered name and tariff type). Read-only; it changes nothing.

ParameterTypeDescription
shortcode *stringShortcode to validate (paybill or till number)

mpesa_pull_transactions Pull C2B Transactions

Pull C2B transactions in a date range for reconciliation. Use when reconciling payments received. start_date and end_date use YYYY-MM-DD HH:MM:SS; offset pages through results from 0. Returns count, the transactions, the response code and message. Read-only.

ParameterTypeDescription
end_date *stringEnd date YYYY-MM-DD HH:MM:SS
start_date *stringStart date YYYY-MM-DD HH:MM:SS
offsetintegerPagination offset (0-based)

mpesa_reversal M-Pesa Reversal

Reverse an erroneous M-PESA transaction by its receipt number. Use only when the user has explicitly approved reversing this exact transaction. MOVES MONEY: in live mode the person approves this exact payment through the client (a client that cannot show that prompt is refused by default; only in the opt-in param and auto modes is confirm_send=true, set only after the user approves, the fallback), and it refuses amounts above the per-transaction cap (MPESA_MAX_AMOUNT_KES, default KES 20,000); the sandbox is never restricted. Returns success, the Daraja response and the sandbox flag, or a refus…

ParameterTypeDescription
amount *integerAmount to reverse in KES
transaction_id *stringM-Pesa receipt to reverse e.g. QKL8XXXXXX
confirm_sendbooleanRequired in live mode: set true ONLY after the user has explicitly approved this exact payment (recipient and amount). Ignored in sandbox.
remarksstringReason for reversal

mpesa_dynamic_qr Dynamic QR Code

Generate a dynamic M-PESA QR code for a specific amount and reference. Use when a customer should pay by scanning. Returns qr_base64 (a PNG), qr_data_url usable in an HTML img tag, and the merchant, amount and reference. The QR encodes the amount you pass, so check it before showing it to a customer. Read-only; it changes nothing.

ParameterTypeDescription
amount *integerAmount in KES to encode in QR
merchant_name *stringBusiness/merchant name to display on QR
ref_no *stringTransaction reference number
qr_sizeintegerQR image size in pixels (300-1000)
trx_codestringBG=Buy Goods, PB=Paybill, WA=Wallet, SM=Send Money, SB=Lipa Shortcode

mpesa_tax_remittance Tax Remittance to KRA

Remit tax from your M-PESA business account to the Kenya Revenue Authority. Use only when the user has explicitly approved this exact remittance. MOVES MONEY: in live mode the person approves this exact payment through the client (a client that cannot show that prompt is refused by default; only in the opt-in param and auto modes is confirm_send=true, set only after the user approves, the fallback), and it refuses amounts above the per-transaction cap (MPESA_MAX_AMOUNT_KES, default KES 20,000); the sandbox is never restricted. Returns success, the Daraja response and the sandbox flag, or a ref…

ParameterTypeDescription
account_reference *stringKRA Payment Registration Number (PRN)
amount *integerTax amount in KES
confirm_sendbooleanRequired in live mode: set true ONLY after the user has explicitly approved this exact payment (recipient and amount). Ignored in sandbox.
remarksstringRemittance remarks

mpesa_b2b_express_checkout B2B Express Checkout

Start a B2B Express Checkout: a USSD push to another merchant's till so they approve a payment from your account. Use only when the user has explicitly approved this exact payment. MOVES MONEY: in live mode the person approves this exact payment through the client (a client that cannot show that prompt is refused by default; only in the opt-in param and auto modes is confirm_send=true, set only after the user approves, the fallback), and it refuses amounts above the per-transaction cap (MPESA_MAX_AMOUNT_KES, default KES 20,000); the sandbox is never restricted. Returns success, the Daraja resp…

ParameterTypeDescription
account_reference *stringAccount reference for the transaction
amount *integerAmount in KES
receiver_till *stringRecipient till number
confirm_sendbooleanRequired in live mode: set true ONLY after the user has explicitly approved this exact payment (recipient and amount). Ignored in sandbox.
remarksstringRemarks

mpesa_bill_manager_optin Bill Manager — Opt In

Enrol your business in M-PESA Bill Manager, a one-time setup for sending invoices with payment links. Use before creating invoices. Takes the notification email and an optional logo and callback URL. Returns the Daraja response. Changes your Bill Manager registration.

ParameterTypeDescription
email *stringBusiness email for Bill Manager notifications
callback_urlstringCallback URL for Bill Manager events
logo_urlstringHTTPS URL to your business logo (PNG/JPG)

mpesa_bill_manager_invoice Bill Manager — Create Invoice

Create a Bill Manager invoice: the customer receives an SMS with the amount and a way to pay. Use when billing a customer. Sends an SMS to the customer's phone in live mode, so have the user approve the customer, amount and due date first. Returns the Daraja response for the invoice.

ParameterTypeDescription
amount *numberInvoice amount in KES
billing_ref *stringCustomer billing account reference
due_date *stringPayment due date YYYY-MM-DD
external_ref *stringYour internal invoice/reference number
invoice_name *stringInvoice description shown to customer
phone *stringCustomer phone to receive SMS notification
account_refstringAccount reference for the payment

mpesa_bill_manager_cancel Bill Manager — Cancel Invoice

Cancel an outstanding Bill Manager invoice by its external reference. Use when an invoice was raised in error or is no longer due. Returns the Daraja response. Cancels the invoice, so have the user approve it first; the customer will no longer be able to pay it, and a cancelled invoice cannot be restored through this tool.

ParameterTypeDescription
external_reference *stringThe externalReference used when creating the invoice

mpesa_sim_swap_query SIM Swap Query

Check whether a phone number's SIM was recently swapped, a fraud signal before sending money. Use before a disbursement to an unfamiliar or high-value recipient. This queries personal data about a subscriber: do so only with a lawful basis and any consent required under the Data Protection Act 2019. Returns phone, swap_detected, last_swap_date, a risk level (HIGH if swapped) and a recommendation. Read-only.

ParameterTypeDescription
phone *stringPhone number to check for SIM swap activity

mpesa_imsi_query IMSI Query — Phone Verification

Verify a Safaricom number: registration date, SIM age, last swap date and a hashed IMSI, with risk indicators (recently swapped; SIM age below 30 as returned by the API). Use for identity or fraud checks before onboarding or paying. This queries personal data about a subscriber: do so only with a lawful basis and any consent required under the Data Protection Act 2019. Returns those fields and the risk indicators. Read-only.

ParameterTypeDescription
phone *stringPhone number to verify

sms_send Send SMS

Send an SMS to a list of recipients through Africa's Talking (at most MPESA_MAX_SMS_RECIPIENTS per call, default 50). Use only when the user has explicitly approved this exact message and recipient list. SENDS TO REAL PEOPLE: in live mode the person approves this exact message and recipient list through the client (a client that cannot show that prompt is refused by default; only in the opt-in param and auto modes is confirm_send=true, set only after the user approves, the fallback), and it refuses more recipients than the per-call cap (MPESA_MAX_SMS_RECIPIENTS, default 50); the sandbox is nev…

ParameterTypeDescription
message *stringSMS message text. Unicode supported (Kiswahili etc.)
recipients *arrayPhone numbers in E.164 format e.g. ['+254712345678']
confirm_sendbooleanRequired in live mode: set true ONLY after the user has explicitly approved sending this exact message to these recipients.
sender_idstringOptional pre-registered alphanumeric sender ID

airtime_send Send Airtime

Send airtime to a phone (Safaricom, Airtel, MTN, Vodafone and others) in a currency. Use only when the user has explicitly approved this exact top-up. MOVES MONEY: in live mode the person approves this exact top-up through the client (a client that cannot show that prompt is refused by default; only in the opt-in param and auto modes is confirm_send=true, set only after the user approves, the fallback), and it refuses amounts above the per-transaction cap (MPESA_MAX_AMOUNT_KES, default KES 20,000); the sandbox is never restricted. Returns the Africa's Talking response or a refusal saying what…

ParameterTypeDescription
amount *stringAmount as string e.g. '50'. Denominated in currency_code, NOT always KES.
phone *stringRecipient phone in E.164 format e.g. '+254712345678'
confirm_sendbooleanRequired in live mode: set true ONLY after the user has explicitly approved this exact payment (recipient and amount). Ignored in sandbox.
currency_codestringISO currency: KES, TZS, UGX, RWF, NGN, GHS, ZAR, ETB, MWK, ZMW. MUST match the recipient's country — a mismatch is rejected, not silently sent.

get_model_hint Model Hint

Returns neutral guidance on choosing a model for these tools; no model is recommended and no benchmark or pricing claims are made. Use when someone asks which model to pair with this server. Takes no arguments. Returns a null recommendation, guidance, a deprecation note and the tool count (23). Read-only.

mpesa_session_report M-Pesa Session Report

Report this server session's spending limits and what the server itself has authorised so far. Use before a payment to check the budget left, or after one to verify what was actually authorised, from the server's own record and not the model's account. Returns the per-payment cap, the session budget, spent and remaining, whether a recipient allowlist is active, counts, and the last ten authorisations or refusals with recipients masked. Read-only.