icon for mcp server

Paystack

STDIO

Paystack支付API集成自动化MCP服务器

Paystack MCP Server

This project is a Model Context Protocol server for the Paystack API. It provides a set of tools that can be used by AI assistants and other automated systems to interact with Paystack in a structured way. This allows for the automation of tasks suchs as creating customers, managing products, initiating transactions, and many other tasks.

Paystack MCP Server

This server is built using the official paystack-sdk for Python and FastMCP for the server implementation.

Features

  • A comprehensive set of tools for interacting with the Paystack API.
  • Easy to extend with new tools and functionality.
  • Includes a Dockerfile for easy containerization and deployment.

Installation

This project uses uv for dependency management. To install the necessary packages, follow these steps:

  1. Clone the repository:

    git clone https://github.com/thisishaykins/paystack-python-mcp cd paystack-python-mcp
  2. Create a virtual environment:

    uv venv
  3. Activate the virtual environment:

    source .venv/bin/activate
  4. Install the dependencies:

    uv pip install -e .

Setup

To use the Paystack MCP server, you need to provide your Paystack API key. The server is configured to read the API key from an environment variable.

  1. Create a .env file in the root of the project.
  2. Add your API key to the .env file:
    PAYSTACK_API_KEY=sk_your_secret_key
    

Running the Server

To run the MCP server, execute the following command from the root of the project:

uv run main.py # or python main.py

The server will start and listen for requests on stdio.

Or run using MCP inspector or in dev mode

uv run mcp dev main.py
Paystack MCP Server running on Inspector

Available Tools

The following tools are available through the MCP server:

ToolDescription
balance.readRetrieves the balance from a Paystack account.
balance.ledgerRetrieves the balance ledger from a Paystack account.
customer.createCreates a new customer.
customer.listRetrieves a list of all customers.
customer.readFetches the details of a specific customer.
customer.updateUpdates the details of a specific customer.
dispute.add_evidenceAdds evidence to a dispute.
dispute.listRetrieves a list of all disputes.
dispute.readFetches the details of a specific dispute.
dispute.downloadDownloads a list of disputes with optional filters.
dispute.resolveResolves a dispute.
invoice.createCreates a new invoice.
invoice.listRetrieves a list of all invoices.
payment_page.createCreates a new payment page.
payment_page.listRetrieves a list of all payment pages.
payment_page.readFetches the details of a specific payment page.
payment_page.updateUpdates the details of a specific payment page.
payment_page.disableDisables a specific payment page.
payment_page.enableEnables a specific payment page.
payment_page.add_productsAdds products to a specific payment page.
plan.createCreates a new subscription plan.
plan.listRetrieves a list of all subscription plans.
plan.readFetches the details of a specific subscription plan.
product.createCreates a new product.
product.listRetrieves a list of all products.
product.readFetches the details of a specific product.
product.updateUpdates the details of a specific product.
product.deleteDeletes a specific product.
refund.createCreates a new refund.
subscription.disableDisables a subscription.
subscription.listRetrieves a list of all subscriptions.
transaction.initializeInitializes a new transaction.
transaction.listRetrieves a list of all transactions.
transaction.readFetches the details of a specific transaction.
transaction.verifyVerifies the status of a transaction.
transaction.timelineRetrieves the timeline of a specific transaction.
transaction.downloadDownloads a list of transactions with optional filters.
verification.fetch_banksFetches a list of banks.
verification.list_avsLists all available account verification services.
verification.list_countriesRetrieves a list of all countries.
verification.resolve_account_numberResolves an account number to get the account holder's name.
verification.resolve_bvnResolves a BVN to get the associated account details.
verification.resolve_card_binResolves a card BIN to get the associated card details.

Usage with an AI Assistant (e.g., Claude)

You can connect this MCP server to an AI assistant like Claude to allow it to perform actions on your behalf. The assistant can call the tools by sending a JSON-RPC request to the server.

Usage with Claude Desktop, cursor, or any other Agent

Add the following to your claude_desktop_config.json. See here for more details.

{ "mcpServers": { "paystack": { "command": "uv", "args": [ "--directory", "/path/to/paystack-python-mcp", "run", "main.py" ] } } }

Here is an example of how Claude could use the customer.create tool:

User: "Please create a new customer with the email address '[email protected]' and the name 'Test User'."

Claude's Thought Process: "The user wants to create a new customer. I will use the customer.create tool. I need to extract the email, first name, and last name from the user's request."

Claude's Tool Call:

{ "tool_name": "customer.create", "parameters": { "email": "[email protected]", "first_name": "Test", "last_name": "User" } }

The MCP server would then execute the tool and return the result to Claude.

Build using Docker

This project includes a Dockerfile to make it easy to build and run the server in a container.

  1. Build the Docker image:

    docker build -t paystack-mcp-server .
  2. Run the Docker container:

    docker run -it --rm -e PAYSTACK_API_KEY=sk_your_secret_key paystack-mcp-server

This will start the server inside a Docker container.

Debugging the Server

To debug your server, you can use the MCP Inspector.

Run the following command in your terminal:

# Start MCP Inspector and server with all tools uv run mcp dev main.py

Instructions

  1. Replace PAYSTACK_API_KEY with your actual Paystack API secret key.
  2. Run the command to start the MCP Inspector.
  3. Open the MCP Inspector UI in your browser and click Connect to start the MCP server.
  4. You can see the list of tools you selected and test each tool individually.

Advanced Usage

This Paystack MCP Server can be extended to covering more primitives, capabilities available on the MCP Server.

MCP Primitives

The MCP protocol defines three core primitives that servers can implement:

PrimitiveControlDescriptionExample Use
PromptsUser-controlledInteractive templates invoked by user choiceSlash commands, menu options
ResourcesApplication-controlledContextual data managed by the client applicationFile contents, API responses
ToolsModel-controlledFunctions exposed to the LLM to take actionsAPI calls, data updates

Server Capabilities

MCP servers declare capabilities during initialization:

CapabilityFeature FlagDescription
promptslistChangedPrompt template management
resourcessubscribe
listChanged
Resource exposure and updates
toolslistChangedTool discovery and execution
logging-Server logging configuration
completions-Argument completion suggestions

Documentation

Contributing

We are passionate about supporting contributors of all levels of experience and would love to see you get involved in the project. See the contributing guide to get started.

License

This project is licensed under the MIT License - see the LICENSE file for details.

MCP Now 重磅来袭,抢先一步体验