The Paystack MCP server is a local process that exposes Paystack API operations as MCP tools. AI assistants like Claude Code call these tools; the server makes the actual Paystack API calls using your secret key stored in an environment variable. Tools typically include: list_transactions, get_transaction, verify_payment, create_payment_link, list_customers. Configure in Claude Code via Settings → MCP Servers, pointing to the server process and setting PAYSTACK_SECRET_KEY as an environment variable. Always run locally or on your own infrastructure — never use a third-party hosted MCP server with your live key.
Model Context Protocol (MCP) is an open standard that lets AI assistants use tools provided by external servers. The architecture has three parts:
The security model: the AI calls tools by name with parameters. The MCP server validates the call, uses the secret key from its environment, makes the Paystack API request, and returns the result. The AI never sees the key — only the result.
What a Paystack MCP server exposes:
| Tool Name | Paystack Endpoint | Use Case |
|---|---|---|
| list_transactions | GET /transaction | "Show my last 20 transactions" |
| get_transaction | GET /transaction/:id | "Get details of transaction 12345" |
| verify_payment | GET /transaction/verify/:ref | "Verify payment with reference PAY_abc123" |
| list_customers | GET /customer | "How many customers do I have?" |
| create_payment_link | POST /paymentrequest | "Create a NGN 5,000 payment link for consulting" |
| get_balance | GET /balance | "What is my current Paystack balance?" |
// Simple Paystack MCP server in Node.js
// Install: npm install @modelcontextprotocol/sdk
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
var PAYSTACK_BASE = 'https://api.paystack.co';
var headers = () => ({ Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY });
var server = new Server({ name: 'paystack', version: '1.0.0' }, { capabilities: { tools: {} } });
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [
{
name: 'list_transactions',
description: 'List Paystack transactions with optional status and date filters.',
inputSchema: { type: 'object', properties: { perPage: { type: 'number' }, status: { type: 'string' }, from: { type: 'string' }, to: { type: 'string' } } },
},
{
name: 'verify_payment',
description: 'Verify a Paystack payment by reference.',
inputSchema: { type: 'object', properties: { reference: { type: 'string' } }, required: ['reference'] },
},
{
name: 'get_balance',
description: 'Get the current Paystack account balance.',
inputSchema: { type: 'object', properties: {} },
},
],
}));
server.setRequestHandler(CallToolRequestSchema, async (req) => {
var args = req.params.arguments || {};
try {
if (req.params.name === 'list_transactions') {
var p = new URLSearchParams(args).toString();
var res = await fetch(PAYSTACK_BASE + '/transaction?' + p, { headers: headers() });
var data = await res.json();
return { content: [{ type: 'text', text: JSON.stringify(data.data, null, 2) }] };
}
if (req.params.name === 'verify_payment') {
var res = await fetch(PAYSTACK_BASE + '/transaction/verify/' + args.reference, { headers: headers() });
var data = await res.json();
return { content: [{ type: 'text', text: JSON.stringify(data.data, null, 2) }] };
}
if (req.params.name === 'get_balance') {
var res = await fetch(PAYSTACK_BASE + '/balance', { headers: headers() });
var data = await res.json();
return { content: [{ type: 'text', text: JSON.stringify(data.data, null, 2) }] };
}
} catch (err) {
return { content: [{ type: 'text', text: 'Error: ' + err.message }], isError: true };
}
});
var transport = new StdioServerTransport();
await server.connect(transport);
Add to Claude Code settings (~/.claude/settings.json):
{
"mcpServers": {
"paystack": {
"command": "node",
"args": ["/absolute/path/to/paystack-mcp-server/index.js"],
"env": {
"PAYSTACK_SECRET_KEY": "sk_test_your_key_here"
}
}
}
}
Get weekly developer tips
Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.
No spam. Unsubscribe anytime.
See connecting the Paystack MCP server to Claude Code for configuration walkthrough.
KES 2,999
The definitive guide to building payment systems with Paystack — from your first transaction to production-grade payment infrastructure across Africa. 9 modules, 47 lessons. Free preview available.
Start Paystack Course