Labsco
MCP SERVER

Daraja MCP

by jameskanyiri

Trigger M-Pesa payment prompts and payment QR codes through Safaricom's Daraja API.

Payments, Billing & Subscriptions
Summary
Built for the sandbox — the authors say it is not production ready.

The README asks you to do your own security testing, error handling and Safaricom compliance work before real money moves through it, and development has since moved to a different repository. Treat this as the version you experiment and learn with.

What it is

A Python server over Safaricom's Daraja API that lets an assistant start M-Pesa payment requests and generate payment QR codes, with a prompt for composing the request.

What you get
  • `stk_push` — send an STK push so the customer authorises the payment on their own phone; takes `amount` and `phone_number` and returns the M-Pesa API response
  • `generate_qr_code` — a scannable payment QR built from merchant name, transaction reference, amount, transaction type and the credit party identifier
  • An `stk_push_prompt` that assembles the payment request from a phone number, an amount and a stated purpose
  • OAuth authentication against Daraja handled by the server rather than by you
Requirements

Python 3.12 and Daraja API credentials — a consumer key and secret — in a `.env` copied from the example. Install with uv: `uv venv`, activate it, `uv sync`, then point your client at `uv --directory /path/to/DarajaMCP run main.py`. Use the sandbox environment for development and switch the URL for production.

Setup effort

One command plus a key — uvx daraja, then supply credentials