Mpesa Daraja MCP Server

by jameskanyiri

235 downloads
Not rated
GitHub

Description

# Mpesa Daraja MCP Server A Python-based server that implements the Mpesa Daraja API functionality using FastMCP. This server provides a simple interface to interact with Safaricom's Mpesa Daraja API, starting with access token generation. ## Features - OAuth token generation…

About

# Mpesa Daraja MCP Server A Python-based server that implements the Mpesa Daraja API functionality using FastMCP. This server provides a simple interface to interact with Safaricom's Mpesa Daraja API, starting with access token generation. ## Features - OAuth token generation for Mpesa Daraja API - Secure credential…

Details

Author
jameskanyiri
Downloads
235
Categories
Other

- OAuth token generation for Mpesa Daraja API
- Secure credential management via environment variables
- Comprehensive error handling and logging
- FastMCP-based server implementation

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Mpesa Daraja MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

1. Install Python 3.7+, clone the repository, create and activate a virtual environment, and install dependencies with pip install -r requirements.txt. 2. Create a .env file with your Mpesa Daraja credentials: MPESA_CONSUMER_KEY, MPESA_CONSUMER_SECRET, PASSKEY, BUSINESS_SHORTCODE, and CALLBACK_URL. 3. Start the server by running python server.py. The server then listens for FastMCP client requests.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mpesa daraja mcp server": {
            "mpesa_mcp_server": {
                "command": "python",
                "args": [
                    "-m",
                    "venv",
                    "venv"
                ]
            }
        }
    }
}

McpServers

{
    "mpesa_mcp_server": {
        "command": "python",
        "args": [
            "-m",
            "venv",
            "venv"
        ]
    }
}

Mpesa Daraja MCP Server

A Python-based server that implements the Mpesa Daraja API functionality using FastMCP. This server provides a simple interface to interact with Safaricom's Mpesa Daraja API, starting with access token generation.

Features

- OAuth token generation for Mpesa Daraja API
- Secure credential management using environment variables
- Comprehensive error handling and logging
- FastMCP-based server implementation

Prerequisites

- Python 3.7 or higher
- Mpesa Daraja API credentials (Consumer Key and Secret)
- pip (Python package installer)

Installation

1. Clone the repository:

git clone https://github.com/yourusername/mpesa_mcp_server.git
cd mpesa_mcp_server

2. Create and activate a virtual environment (recommended):

python -m venv venv
source venv/bin/activate  # On Windows, use: venv\Scripts\activate

3. Install dependencies:

pip install -r requirements.txt

4. Create a .env file in the project root with your Mpesa Daraja credentials:

MPESA_CONSUMER_KEY="your_consumer_key"
MPESA_CONSUMER_SECRET="your_consumer_secret"
PASSKEY="your_passkey"
BUSINESS_SHORTCODE="your_business_shortcode"
CALLBACK_URL="your_callback_url"

Usage

1. Start the server:

python server.py

2. The server will start and listen for requests. You can interact with it using the FastMCP client.

API Endpoints

Generate Access Token

Generates an OAuth access token for authenticating Mpesa Daraja API requests.

```python

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.