Логотип Daraja MCP

Daraja MCP

Спільнота
jameskanyiri

A Model Context Protocol (MCP) server designed to integrate AI applications with Safaricom's Daraja API, enabling seamless interaction with M-Pesa services.

Видавецьjameskanyiri
РепозиторійDarajaMCP
МоваPython
Форки
7
Зірки
14
Доступні інструменти
0
Тип транспортуstdio
Категорії
Посилання
  • Підключайте інструменти до робочих процесів із ШІ

    Daraja MCP надає можливості MCP, які можуть використовувати сумісні клієнтські ШІ-застосунки та агенти.

  • Доступні інструменти: 0

    Нижче ви можете переглянути дії, які можна викликати, а також їхні назви й описи, якщо сервер їх надає.

  • Готова конфігурація для копіювання

    Скористайтеся прикладами конфігурації, щоб налаштувати цей сервер у вибраному клієнті MCP.

  • Показники інтересу до проєкту з відкритим кодом

    У пов’язаному репозиторії: зірки — 14, форки — 7.

Daraja MCP

🚨 Important Notice: Repository Moved

This project has moved to a new repository. If you're looking to contribute or access the latest version, please visit:

https://github.com/paylinkmcp/paylink

A Model Context Protocol (MCP) server designed to integrate AI applications with Safaricom's Daraja API, enabling seamless interaction with M-Pesa services.

⚠️ Warning: Not Production Ready

This project is currently in development and is not recommended for production use. It's designed for:

  • Learning and experimentation
  • Development and testing environments
  • Proof of concept implementations

For production use, please ensure:

  • Thorough security testing
  • Proper error handling
  • Complete implementation of all planned features
  • Compliance with Safaricom's production requirements

What is an MCP Server?

MCP (Model Context Protocol) servers provide capabilities for LLMs to interact with external systems. MCP servers can provide three main types of capabilities:

  • Resources: File-like data that can be read by clients (like API responses)
  • Tools: Functions that can be called by the LLM (with user approval)
  • Prompts: Pre-written templates that help users accomplish specific tasks

Daraja MCP specifically leverages this architecture to connect AI systems with Safaricom's Daraja M-Pesa API.

Overview

Daraja MCP is a bridge between AI, fintech, and M-Pesa, making AI-driven financial automation accessible and efficient. By standardizing the connection between LLMs (Large Language Models) and financial transactions, Daraja MCP allows AI-driven applications to process payments, retrieve transaction data, and automate financial workflows effortlessly.

Key Capabilities

  • ✅ AI-Powered M-Pesa Transactions – Enable LLMs to handle B2C, C2B, and B2B payments
  • ✅ Standardized Integration – MCP ensures compatibility with multiple AI tools
  • ✅ Secure & Scalable – Implements OAuth authentication and supports enterprise-grade transaction handling
  • ✅ Flexible Automation – AI agents can query account balances, generate invoices, and automate reconciliation

Requirements

  • Python 3.12
  • Safaricom Daraja API Credentials (Consumer Key and Secret)

Installation

Step 1: Setting Up Your Environment

  1. Install uv Package Manager

    For Mac/Linux:

    bash
    curl -LsSf https://astral.sh/uv/install.sh | sh

    For Windows (PowerShell):

    powershell
    powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
  2. Clone the Repository

    bash
    git clone https://github.com/jameskanyiri/DarajaMCP.git
    cd DarajaMCP
  3. Create and Activate a Virtual Environment

    bash
    uv venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate

    ✅ Expected Output: Your terminal prompt should change, indicating the virtual environment is activated.

  4. Install Dependencies

    bash
    uv sync

Step 2: Setting up Environment Variables

  1. Copy the example environment file:

    bash
    cp .env.example .env
  2. Update the .env file with your actual credentials and configuration values.

Note: For development, use the sandbox environment. Switch to the production URL when ready.

Usage

Testing with Claude Desktop

  1. Install Claude Desktop

    • Download and install the latest version from Claude Desktop
    • Make sure you're running the latest version
  2. Configure Claude Desktop

    • Open your Claude Desktop configuration file:

      bash
      # On MacOS/Linux
      code ~/Library/Application\ Support/Claude/claude_desktop_config.json
      
      # On Windows
      code %APPDATA%\Claude\claude_desktop_config.json
    • Create the file if it doesn't exist

  3. Add Server Configuration Choose one of the following configurations:

    Anthropic's Recommended Format

    json
    {
      "mcpServers": {
        "daraja": {
          "command": "uv",
          "args": [
            "--directory",
            "/ABSOLUTE/PATH/TO/PARENT/FOLDER/DarajaMCP",
            "run",
            "main.py"
          ]
        }
      }
    }

    Working Configuration (Tested)

    json
    {
      "mcpServers": {
        "DarajaMCP": {
          "command": "/ABSOLUTE/PATH/TO/PARENT/.local/bin/uv",
          "args": [
            "--directory",
            "/ABSOLUTE/PATH/TO/PARENT/FOLDER/DarajaMCP",
            "run",
            "main.py"
          ]
        }
      }
    }

    Note:

    • Replace /ABSOLUTE/PATH/TO/PARENT with your actual path
    • To find the full path to uv, run:
    bash
    # On MacOS/Linux
    which uv
    
    # On Windows
    where uv
  4. Verify Configuration

    • Save the configuration file
    • Restart Claude Desktop
    • Look for the hammer 🔨 icon in the interface
    • Click it to see the available tools:
      • generate_access_token
      • stk_push (Future Implementation)
      • query_transaction_status (Future Implementation)
      • b2c_payment (Future Implementation)
      • account_balance (Future Implementation)

Tools and Prompts

Payment Tools

stk_push

Initiate an M-Pesa STK push request to prompt the customer to authorize a payment on their mobile device.

Inputs:

  • amount (int): The amount to be paid
  • phone_number (int): The phone number of the customer

Returns: JSON formatted M-PESA API response

generate_qr_code

Generate a QR code for a payment request that customers can scan to make payments.

Inputs:

  • merchant_name (str): Name of the company/M-Pesa Merchant Name
  • transaction_reference_no (str): Transaction reference number
  • amount (int): The total amount for the sale/transaction
  • transaction_type (Literal["BG", "WA", "PB", "SM", "SB"]): Transaction type
  • credit_party_identifier (str): Credit Party Identifier (Mobile Number, Business Number, Agent Till, Paybill, or Merchant Buy Goods)

Returns: JSON formatted M-PESA API response containing the QR code data

Payment Prompts

stk_push_prompt

Generate a prompt for initiating an M-Pesa STK push payment request.

Inputs:

  • phone_number (str): The phone number of the customer
  • amount (int): The amount to be paid
  • purpose (str): The purpose of the payment

Returns: Formatted prompt string for STK push request

generate_qr_code_prompt

Generate a prompt for creating an M-Pesa QR code payment request.

Inputs:

  • merchant_name (str): Name of the merchant/business
  • amount (int): Amount to be paid
  • transaction_type (str): Type of transaction (BG for Buy Goods, WA for Wallet, PB for Paybill, SM for Send Money, SB for Send to Business)
  • identifier (str): The recipient identifier (till number, paybill, phone number)
  • reference (str, optional): Transaction reference number. If not provided, a default will be used.

Returns: Formatted prompt string for QR code generation

Document Processing Tools

create_source

Create a connector from data source to unstructured server for processing.

Inputs:

  • connector_name (str): The name of the source connector to create

Returns: Source connector details including name and ID

create_destination

Create a connector from unstructured server to destination for data storage.

Inputs:

  • connector_name (str): The name of the destination connector to create

Returns: Destination connector details including name and ID

create_workflow

Create a workflow to process data from source connector to destination connector.

Inputs:

  • workflow_name (str): The name of the workflow to create
  • source_id (str): The ID of the source connector
  • destination_id (str): The ID of the destination connector

Returns: Workflow details including name, ID, status, type, sources, destinations, and schedule

run_workflow

Execute a workflow.

Inputs:

  • workflow_id (str): The ID of the workflow to run

Returns: Workflow execution status

get_workflow_details

Get detailed information about a workflow.

Inputs:

  • workflow_id (str): The ID of the workflow to get details

Returns: Workflow details including name, ID, and status

fetch_documents

Fetch documents analyzed during workflow execution.

Inputs: None

Returns: List of analyzed documents

Prompts

create_and_run_workflow_prompt

Generate a prompt to create and run a workflow for document processing.

Inputs:

  • user_input (str): The user's processing requirements

Returns: Formatted prompt for workflow creation and execution

Example:

python
# Example usage
prompt = await create_and_run_workflow_prompt(
    user_input="Process all PDF invoices from the invoices folder and store them in the processed folder"
)
# Returns: "The user wants to achieve Process all PDF invoices from the invoices folder and store them in the processed folder. Assist them by creating a source connector and a destination connector, then setting up the workflow and executing it."

Resources

Currently, no resources are available.

License

MIT License

Acknowledgments

  • Safaricom for providing the Daraja API
  • Anthropic for the MCP framework
  • Contributors to the project

Contact

For any inquiries, please open an issue on the GitHub repository.

Встановлення

TypingMind
Передумови:

Node.js 18+

{
  "mcpServers": {
    "jameskanyiri-darajamcp": {
      "command": "",
      "args": []
    }
  }
}

Використовуйте MCP Daraja MCP з різними моделями ШІ

TypingMind підключає інструменти MCP на рівні робочого простору, тож після підключення Daraja MCP ви можете використовувати це підключення з різними моделями ШІ в TypingMind, не налаштовуючи його окремо для кожної моделі. Ця інтеграція MCP працює локально через конектор MCP TypingMind на вашому пристрої.

Інструкція з налаштування локального конектора

Виберіть цей варіант, якщо серверу MCP потрібен доступ до локальних файлів, програм або приватних ресурсів на вашому комп’ютері.

1

Відкрийте налаштування MCP

У TypingMind перейдіть до розділу «Налаштування», відкрийте «Розширені налаштування», потім «Протокол контексту моделі» й виберіть «Налаштувати конектор».

  1. Відкрийте TypingMind у браузері.
  2. Натисніть значок налаштувань.
  3. Перейдіть до розділу «Розширені налаштування».
  4. Відкрийте розділ «Протокол контексту моделі».
  5. Натисніть «Налаштувати конектор» і виберіть «Цей пристрій».
Екран налаштування конектора MCP у TypingMind з вибраним варіантом «Цей пристрій»
2

Виконайте команду конектора

Виберіть «Цей пристрій», скопіюйте команду з TypingMind і виконайте її в терміналі. Не зупиняйте процес, поки користуєтеся MCP.

  1. Скопіюйте команду налаштування, показану в TypingMind.
  2. Відкрийте «Термінал» у macOS або Windows Terminal у Windows.
  3. Вставте й виконайте команду.
  4. Підтвердьте встановлення пакета, якщо в терміналі з’явиться запит на підтвердження.
  5. Не закривайте вікно термінала й не зупиняйте процес, поки користуєтеся інструментами MCP.
3

Додайте Daraja MCP як сервер

Коли статус конектора зміниться на «Готово», натисніть «Редагувати сервери» та вставте конфігурацію сервера MCP.

  1. Зачекайте, доки статус конектора зміниться на «Готово».
  2. Натисніть «Редагувати сервери».
  3. Вставте конфігурацію сервера MCP Daraja MCP.
  4. Збережіть список серверів.
  5. Якщо хочете переконатися, що конектор досі готовий до роботи, оновіть дані.
Налаштування MCP у TypingMind з активним сервером і кнопкою «Редагувати сервери»
{
  "mcpServers": {
    "jameskanyiri-darajamcp": {
      "command": "npx",
      "args": [
        "-y",
        "daraja"
      ]
    }
  }
}
4

Використовуйте підключення з різними моделями

Збережіть список серверів, відкрийте «Плагіни», увімкніть інструменти MCP для Daraja MCP, а потім виберіть будь-яку підтримувану модель ШІ в TypingMind і використовуйте інструменти в чаті або призначте їх агенту ШІ.

  1. Відкрийте сторінку «Плагіни» в TypingMind.
  2. Увімкніть інструменти MCP для Daraja MCP.
  3. Почніть чат і виберіть модель ШІ, яку хочете використовувати.
  4. Використовуйте інструменти MCP у чаті або призначте їх агенту ШІ.
  5. За потреби перемикайтеся на іншу модель ШІ без повторного підключення MCP.
Чат TypingMind із використанням увімкнених інструментів MCP і вибраної моделі ШІ
Допоможете з цим завданням через Daraja MCP?
Daraja MCP
Звісно. Я це прочитав.
Ось що я знайшов за допомогою Daraja MCP.

Поширені запитання

Для чого використовується сервер MCP Daraja MCP?

Daraja MCP — це сервер MCP, який дає змогу сумісним клієнтам ШІ отримувати доступ до зовнішніх інструментів і контексту. У TypingMind ви можете додати цей сервер MCP один раз і зробити його інструменти доступними у своєму робочому просторі ШІ.

Чи можу я використовувати сервер MCP Daraja MCP з кількома моделями ШІ в TypingMind?

Так. TypingMind підключає інструменти MCP на рівні робочого простору, тому ви можете використовувати Daraja MCP з різними моделями ШІ, як-от Claude, ChatGPT, Gemini або іншими моделями, які ви налаштували в TypingMind, без окремого налаштування сервера MCP для кожної моделі.

Навіщо використовувати сервер MCP Daraja MCP із TypingMind?

TypingMind — один із найкращих інтерфейсів для чату з великими мовними моделями, адже він об’єднує різні моделі ШІ, промпти, плагіни, агентів ШІ, ключі API та інструменти MCP в одному робочому просторі. Підключивши Daraja MCP, ви зможете використовувати його інструменти MCP з вибраними моделями та впорядковано працювати з чатами в TypingMind.

Як підключити сервер MCP Daraja MCP до TypingMind?

Daraja MCP працює через локальний конектор MCP TypingMind. Це найкращий варіант, коли серверу MCP потрібен доступ до локальних файлів, настільних застосунків, інструментів командного рядка або приватних ресурсів на вашому комп’ютері.

Які інструменти надає сервер MCP Daraja MCP у TypingMind?

Daraja MCP надає можливості MCP, які можна ввімкнути на сторінці «Плагіни» в TypingMind і використовувати в чаті або призначати агентам ШІ.

Чи потрібно ділитися своїми ключами API з TypingMind, щоб використовувати сервер MCP Daraja MCP?

Ні. TypingMind орієнтований насамперед на локальну роботу й дає вам змогу самостійно обирати постачальників моделей і керувати ключами API, промптами та конфігурацією MCP. Якщо Daraja MCP потребує автентифікації, під час створення підключення додайте потрібні заголовки, налаштування OAuth або локальну конфігурацію для цього сервера MCP.

Схожі сервери MCP

Усі

Створіть власний робочий простір зі ШІ вже зараз

Підпишіться на нашу розсилку, щоб дізнаватися про нові функції та майбутні розіграші 👇