npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sparkpesa/mcp-server

v1.2.0

Published

SparkPesa MCP Server for AI IDE integration — enables AI assistants to interact with the SparkPesa payment API

Readme

SparkPesa MCP Server

An MCP (Model Context Protocol) server that lets AI assistants in IDEs like Windsurf, Cursor, and VS Code + Copilot interact with the SparkPesa payment API.

What It Does

The MCP server exposes SparkPesa's payment capabilities as tools that AI assistants can call directly:

Payment Tools

| Tool | Description | |---|---| | request_payment_kenya | Collect M-Pesa payment via STK Push (KES) | | send_payment_kenya | Send M-Pesa B2C payout (KES) | | buy_goods | Pay to M-Pesa Till Number (KES) | | paybill | Pay to M-Pesa PayBill Number (KES) | | request_payment_uganda | Collect Mobile Money payment (UGX) | | send_payment_uganda | Send Mobile Money payout (UGX) |

Wallet Management Tools

| Tool | Description | |---|---| | list_wallets | List all wallets for your organization | | get_wallet | Get wallet details and recent transactions | | create_wallet | Create a new wallet (auto-generates 8-digit code) | | update_wallet | Rename a wallet or update its description/webhook URL | | delete_wallet | Deactivate a wallet (soft-delete, must have zero balance) |

Utility Tools

| Tool | Description | |---|---| | generate_signature | Generate HMAC signature for debugging | | generate_webhook_handler | Generate webhook handler code (Express, Next.js, Flask, FastAPI) | | generate_client_sdk | Generate full client SDK (TypeScript, JavaScript, Python, cURL) |

It also provides resources (reference docs) the AI can read:

  • sparkpesa://docs/overview — API overview, endpoints, auth
  • sparkpesa://docs/webhooks — Webhook events, payloads, signature verification
  • sparkpesa://docs/errors — Error codes and troubleshooting

Setup

1. Install Dependencies

cd mcp-server
pnpm install

2. Build

pnpm build

3. Configure Environment

Set your SparkPesa API credentials:

export SPARKPESA_API_KEY="sk_live_your_api_key"
export SPARKPESA_API_SECRET="ss_live_your_api_secret"
export SPARKPESA_BASE_URL="https://www.sparkpesa.io/api/v1"  # optional

4. Add to Your IDE

Windsurf

Add to your ~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "sparkpesa": {
      "command": "node",
      "args": ["/absolute/path/to/bb_merchant/mcp-server/dist/index.js"],
      "env": {
        "SPARKPESA_API_KEY": "sk_live_your_api_key",
        "SPARKPESA_API_SECRET": "ss_live_your_api_secret"
      }
    }
  }
}

Cursor

Add to your .cursor/mcp.json:

{
  "mcpServers": {
    "sparkpesa": {
      "command": "node",
      "args": ["/absolute/path/to/bb_merchant/mcp-server/dist/index.js"],
      "env": {
        "SPARKPESA_API_KEY": "sk_live_your_api_key",
        "SPARKPESA_API_SECRET": "ss_live_your_api_secret"
      }
    }
  }
}

VS Code (GitHub Copilot)

Add to your .vscode/mcp.json:

{
  "servers": {
    "sparkpesa": {
      "type": "stdio",
      "command": "node",
      "args": ["/absolute/path/to/bb_merchant/mcp-server/dist/index.js"],
      "env": {
        "SPARKPESA_API_KEY": "sk_live_your_api_key",
        "SPARKPESA_API_SECRET": "ss_live_your_api_secret"
      }
    }
  }
}

Usage Examples

Once configured, you can ask your AI assistant:

  • "Collect KES 500 from 254712345678 for order ORDER-001 using wallet 12345678"
  • "Send KES 5000 salary payment to 254712345678"
  • "Pay KPLC electricity bill — paybill 320320, account 12345678901, KES 3500"
  • "List all my wallets"
  • "Create a new UGX wallet called Uganda Operations"
  • "Rename wallet abc-123 to Main KES Wallet"
  • "Delete the test wallet"
  • "Generate a Next.js webhook handler for SparkPesa"
  • "Generate a Python client SDK for SparkPesa"
  • "What's the signature format for SparkPesa API requests?"

The AI will use the appropriate tool or resource to fulfill the request.

Development

# Run in development mode
pnpm dev

# Build for production
pnpm build

# Test the server
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | node dist/index.js

Architecture

mcp-server/
├── src/
│   ├── index.ts        # Entry point — creates MCP server and stdio transport
│   ├── api-client.ts   # SparkPesa API client (auth, signing, requests)
│   ├── resources.ts    # MCP resources (static reference documentation)
│   └── tools.ts        # MCP tools (payment operations + code generation)
├── package.json
├── tsconfig.json
└── README.md