bonum-psp-mcp
v0.2.0
Published
Unofficial MCP server for Bonum PSP V2 — check payments, verify webhooks and test your webhook endpoint from Claude Code, Codex, Cursor and other MCP clients
Maintainers
Readme
bonum-psp-mcp
English | Монгол
An MCP server for Bonum PSP V2 and Bonum Gateway invoices. It lets your AI coding agent check payments, create invoices with a checkout link (QPay, cards and more), explain why a webhook was rejected, and test your webhook endpoint with genuine, forged, stale and duplicate webhooks. It works with Claude Code, Codex, Cursor, Claude Desktop, VS Code and any other MCP client. The server is the same everywhere; only the config differs.
It cannot submit Apple Pay or Google Pay payments, because wallet tokens only come from a real
device. To build the integration, use the
bonum-psp SDK.
- Quick start · Setup per client · Configuration · Tools · Resources and prompts
- Example requests · Safety model · Debugging · Use as a library
Quick start
You need Node.js 22.12 or later. Add the server to Claude Code with your sandbox credentials:
claude mcp add --env BONUM_MERCHANT_KEY=... --env BONUM_WEBHOOK_SECRET=... \
--env BONUM_GATEWAY_APP_SECRET=... --env BONUM_GATEWAY_TERMINAL_ID=... \
--env BONUM_GATEWAY_CHECKSUM_KEY=... --env BONUM_ENV=sandbox \
--transport stdio bonum -- npx -y bonum-psp-mcpThen ask: "Check my Bonum connection." or "Create a 5000 MNT invoice."
Payments and invoices use different credentials. Leave out the ones you don't use:
- Payments (PSP V2):
BONUM_MERCHANT_KEYandBONUM_WEBHOOK_SECRET. - Invoices (Bonum Gateway):
BONUM_GATEWAY_APP_SECRETandBONUM_GATEWAY_TERMINAL_IDforcreate_invoiceandlist_payment_providers, plusBONUM_GATEWAY_CHECKSUM_KEYforverify_invoice_webhook. All three come from the Bonum merchant portal.
Every variable is optional. A tool whose credentials are missing explains how to set them; the other tools still work.
Setup per client
Give the MCP server sandbox credentials only. See the safety model for why.
The examples for the other clients show the payment keys; add the BONUM_GATEWAY_* variables the
same way to use the invoice tools.
Claude Code
claude mcp add --env BONUM_MERCHANT_KEY=... --env BONUM_WEBHOOK_SECRET=... \
--env BONUM_GATEWAY_APP_SECRET=... --env BONUM_GATEWAY_TERMINAL_ID=... \
--env BONUM_GATEWAY_CHECKSUM_KEY=... --env BONUM_ENV=sandbox \
--transport stdio bonum -- npx -y bonum-psp-mcp- By default the server is added for the current project and only for you (
--scope local). Add--scope userto use it in all your projects. - Keep another option (here
--transport stdio) between the last--envand the namebonum. Otherwise the CLI reads the name as one moreKEY=valuepair. - Run
/mcpinside Claude Code to see the server's status and tools.
Changing the keys
claude mcp add never replaces a server that already exists: it stops with "MCP server bonum
already exists". Remove the server, then add it again with all the values you want. read -s
keeps the secrets out of your shell history. The terminal id is not a secret, so it is typed
directly. Drop the lines for the credentials you don't use:
claude mcp remove bonum -s local
read -s BONUM_MERCHANT_KEY # paste the key and press Enter; nothing is shown
read -s BONUM_WEBHOOK_SECRET
read -s BONUM_GATEWAY_APP_SECRET
read -s BONUM_GATEWAY_CHECKSUM_KEY
claude mcp add --env BONUM_MERCHANT_KEY="$BONUM_MERCHANT_KEY" \
--env BONUM_WEBHOOK_SECRET="$BONUM_WEBHOOK_SECRET" \
--env BONUM_GATEWAY_APP_SECRET="$BONUM_GATEWAY_APP_SECRET" \
--env BONUM_GATEWAY_TERMINAL_ID=... \
--env BONUM_GATEWAY_CHECKSUM_KEY="$BONUM_GATEWAY_CHECKSUM_KEY" --env BONUM_ENV=sandbox \
--transport stdio bonum -- npx -y bonum-psp-mcpThen restart Claude Code, or reconnect bonum in /mcp: a running server keeps its old values.
Ask "Check my Bonum connection." to see which values are set (never the values themselves).
Claude Code: team setup with .mcp.json
Commit this .mcp.json to the project root. Each developer keeps their own secrets in their shell
environment:
{
"mcpServers": {
"bonum": {
"type": "stdio",
"command": "npx",
"args": ["-y", "bonum-psp-mcp"],
"env": {
"BONUM_MERCHANT_KEY": "${BONUM_MERCHANT_KEY}",
"BONUM_WEBHOOK_SECRET": "${BONUM_WEBHOOK_SECRET}",
"BONUM_GATEWAY_APP_SECRET": "${BONUM_GATEWAY_APP_SECRET}",
"BONUM_GATEWAY_TERMINAL_ID": "${BONUM_GATEWAY_TERMINAL_ID}",
"BONUM_GATEWAY_CHECKSUM_KEY": "${BONUM_GATEWAY_CHECKSUM_KEY}",
"BONUM_ENV": "${BONUM_ENV:-sandbox}"
}
}
}
}Claude Code fills in ${VAR} from the environment it was started in, and asks each developer to
approve project servers before first use. If a variable is unset, Claude Code passes the literal
${VAR} text. The server recognizes that, ignores the value, and check_connection tells you which
variable to export. Don't use claude mcp add --scope project for secrets: it writes the values
into .mcp.json.
Codex
The Codex CLI, IDE extension and app share one configuration:
codex mcp add bonum --env BONUM_MERCHANT_KEY=... --env BONUM_WEBHOOK_SECRET=... --env BONUM_ENV=sandbox -- npx -y bonum-psp-mcpThat command stores the values in ~/.codex/config.toml. To keep secrets out of the file, edit
~/.codex/config.toml (or .codex/config.toml in a trusted project) instead, and forward them from
your shell:
[mcp_servers.bonum]
command = "npx"
args = ["-y", "bonum-psp-mcp"]
env_vars = ["BONUM_MERCHANT_KEY", "BONUM_WEBHOOK_SECRET"] # forwarded from your shell
default_tools_approval_mode = "writes" # read-only tools run without prompts
[mcp_servers.bonum.env]
BONUM_ENV = "sandbox"With "writes", Codex asks before tools that are not marked read-only. Here that is only
send_test_webhook, which sends requests to your endpoint.
Claude Desktop
Open Settings → Developer → Edit Config, or edit claude_desktop_config.json directly
(~/Library/Application Support/Claude/ on macOS, %APPDATA%\Claude\ on Windows):
{
"mcpServers": {
"bonum": {
"command": "npx",
"args": ["-y", "bonum-psp-mcp"],
"env": {
"BONUM_MERCHANT_KEY": "mk_test_example",
"BONUM_WEBHOOK_SECRET": "test_webhook_secret",
"BONUM_ENV": "sandbox"
}
}
}
}Replace the placeholders with your sandbox values; Claude Desktop does not expand variables. Restart
Claude Desktop afterwards. If it cannot find npx (common with nvm), use the absolute path from
which npx as the command.
Cursor
Use .cursor/mcp.json in the project, or ~/.cursor/mcp.json for every project. Cursor reads
${env:NAME} from your environment:
{
"mcpServers": {
"bonum": {
"type": "stdio",
"command": "npx",
"args": ["-y", "bonum-psp-mcp"],
"env": {
"BONUM_MERCHANT_KEY": "${env:BONUM_MERCHANT_KEY}",
"BONUM_WEBHOOK_SECRET": "${env:BONUM_WEBHOOK_SECRET}",
"BONUM_ENV": "sandbox"
}
}
}
}VS Code
VS Code's .vscode/mcp.json uses servers rather than mcpServers. It can prompt for secrets once
and store them securely:
{
"inputs": [
{
"type": "promptString",
"id": "bonum-merchant-key",
"description": "Bonum sandbox merchant key",
"password": true
},
{
"type": "promptString",
"id": "bonum-webhook-secret",
"description": "Bonum sandbox webhook secret",
"password": true
}
],
"servers": {
"bonum": {
"type": "stdio",
"command": "npx",
"args": ["-y", "bonum-psp-mcp"],
"env": {
"BONUM_MERCHANT_KEY": "${input:bonum-merchant-key}",
"BONUM_WEBHOOK_SECRET": "${input:bonum-webhook-secret}",
"BONUM_ENV": "sandbox"
}
}
}
}Any other MCP client
Run npx -y bonum-psp-mcp as a stdio server, with the environment variables below. Or install it
once with npm install -g bonum-psp-mcp and run bonum-psp-mcp.
Configuration
| Variable | Needed for | Default |
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | --------- |
| BONUM_MERCHANT_KEY | The payment tools (check_connection, get_payment*, wait_for_payment_result) | — |
| BONUM_WEBHOOK_SECRET | The webhook tools (verify_webhook, create_test_webhook, send_test_webhook) | — |
| BONUM_ENV | Which Bonum APIs the payment and invoice tools call: sandbox or production | sandbox |
| BONUM_BASE_URL | A proxy in front of Bonum's API (https:, or http: for localhost) | — |
| BONUM_MCP_ALLOW_REMOTE_WEBHOOK_TARGETS | Letting send_test_webhook reach hosts other than local ones | false |
| BONUM_GATEWAY_APP_SECRET | The invoice tools (create_invoice, list_payment_providers), with the terminal id; from the Bonum merchant portal | — |
| BONUM_GATEWAY_TERMINAL_ID | The invoice tools, with the app secret | — |
| BONUM_GATEWAY_CHECKSUM_KEY | verify_invoice_webhook | — |
| BONUM_GATEWAY_BASE_URL | A proxy in front of the Bonum Gateway API | — |
The server always starts. A missing or invalid value switches off only the tools that need it, and
those tools explain what to set. check_connection lists every configuration warning, and the
server prints them to stderr at startup. Values are trimmed, and are never printed.
Tools
| Tool | What it does | Needs | Hints |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ---------------------------- |
| check_connection | Shows the environment, base URL and which credentials are set (yes/no only). Proves the key works by looking up a random payment id: Bonum answers 404 for a valid key and 401 for an invalid one. Start here. | — | read-only, idempotent |
| get_payment | Gets a payment by Bonum paymentId (UUID), with isTerminal and a normalized currency. | key | read-only, idempotent |
| get_payment_by_order_id | The same, by your order_id. | key | read-only, idempotent |
| wait_for_payment_result | Waits up to waitMs (1–28 000, default 25 000) for the bank's answer to a PENDING payment. | key | read-only |
| verify_webhook | Checks a captured webhook (exact raw body, X-PSP-Signature, X-PSP-Timestamp) and explains any failure. ignoreTimestamp replays old captures. | secret | read-only, idempotent, local |
| create_test_webhook | Signs a realistic AUTHORIZED or FAILED webhook and returns the body, headers and a ready curl command. The signature is valid for 5 minutes. | secret | read-only, local |
| send_test_webhook | Sends test webhooks to your endpoint and grades each answer. Scenarios: authorized, failed, duplicate, invalid_signature, stale_timestamp or all (default). | secret | sends requests, local |
| create_invoice | Creates a Bonum Gateway invoice and returns its checkout link (followUpLink). amount in MNT; optional transactionId (generated when omitted), expiresIn (default 3600 s), callbackUrl, providers, items, language. | gateway credentials | creates an invoice |
| list_payment_providers | Lists the payment methods (QPay, cards, WeChat Pay, …) and whether each is enabled for your terminal. | gateway credentials | read-only, idempotent |
| verify_invoice_webhook | Checks a captured invoice webhook (exact raw body and X-Checksum-V2) and explains any failure. | checksum key | read-only, idempotent, local |
send_test_webhook expects a 2xx for genuine events, for both copies of a duplicate, and a 4xx for
the forged and the 10-minute-old webhook. A 2xx for either of those is reported as a security
failure: anyone could fake a payment. A 5xx where a 4xx is expected is a warning, because Bonum
would keep retrying.
Payment results carry environment. With BONUM_ENV=production, their text starts with a
production warning.
Bonum reports an invoice's result only by webhook, to the URL registered in the merchant portal,
and offers no status lookup for invoices. Ask the agent to verify a captured invoice webhook with
verify_invoice_webhook. check_connection also checks the gateway credentials.
Resources and prompts
Resources (Markdown, written for this project; each links to Bonum's official pages):
| URI | Contents |
| ---------------------------- | --------------------------------------------------------------------------------------------------------- |
| bonum://guides/integration | The V2 flow, keeping the key on the server, Apple Pay and Google Pay with waitForResult, reconciliation |
| bonum://guides/webhooks | Verification, raw body per framework, two-level idempotency, the retry schedule, local testing |
| bonum://reference/api | Endpoints, fields, statuses and errors |
| bonum://checklists/go-live | What to check before taking real payments |
In Claude Code, mention one with @bonum:bonum://guides/webhooks.
Prompts:
| Prompt | Arguments | What it does |
| -------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| integrate_bonum | framework (express, nextjs, hono, fastify, nestjs, other), wallets (apple, google, both) | Adds bonum-psp to the current project, then validates the webhook with send_test_webhook. |
| debug_webhook | symptom | Walks through raw body, secret and environment, clock skew, proxies and global JSON parsers, using verify_webhook. |
| review_bonum_integration | — | Audits an existing integration against the go-live rules. |
In Claude Code, prompts are slash commands: /mcp__bonum__integrate_bonum nextjs both.
Example requests
- "Check my Bonum connection."
- "What's the status of order ORD-1001?"
- "Wait for payment 3f0c2c8e-… to finish."
- "Test my webhook at http://localhost:3000/webhooks/bonum."
- "My webhook says signature mismatch. Here are the raw body and headers I logged: …"
- "Create a signed FAILED test webhook for order ORD-7 and give me the curl command."
- "Create a 5000 MNT invoice and give me the payment link."
- "Which payment methods are enabled on my Bonum terminal?"
Safety model
- One write, on request. The payment tools only look payments up. The only tool that creates
something at Bonum is
create_invoice. It is not marked read-only, so clients ask before running it, and its description tells the agent to confirm the amount. No tool submits, refunds or cancels anything. - Secrets only from the environment. No tool takes a key or secret as an argument, and none repeats one. As a last line of defense, every output passes through a redactor that removes the configured key and secrets (merchant key, webhook secret, gateway app secret and checksum key).
- Test webhooks stay local.
send_test_webhookonly acceptshttp/httpsURLs without credentials, and by default only these hosts:localhost,127.0.0.1,[::1],*.localhostand*.test. Anything else needsBONUM_MCP_ALLOW_REMOTE_WEBHOOK_TARGETS=true. It never follows redirects, and gives up on each request after 10 seconds, Bonum's own limit. - No signing for production. With
BONUM_ENV=production,create_test_webhookandsend_test_webhookrefuse to run.BONUM_ENVonly picks the API host, though, so the real protection is to never give this server your production webhook secret: anyone who can talk to your agent could forge valid production webhooks with it. - Honest hints. Tools that only read are marked read-only, so clients can run them without
asking.
send_test_webhookis not, so clients ask before it sends anything. - Quiet on stdout. The server logs only to stderr; stdout carries the MCP protocol.
Debugging
Start with
check_connection: it shows what the server sees, and every configuration warning.The server prints one startup line to stderr, such as
0.1.0 serving MCP on stdio; Bonum sandbox (https://testpsp.bonum.mn); merchant key set, webhook secret set.Claude Code shows server errors in/mcp. Claude Desktop writes server logs to~/Library/Logs/Claude/on macOS.Explore the server with the MCP Inspector:
npx @modelcontextprotocol/inspector -e BONUM_ENV=sandbox npx -y bonum-psp-mcpnpx -y bonum-psp-mcp --helplists the variables, and--versionprints the version.
Use as a library
The package also exports the server factory. You can embed the server, serve it over HTTP, or test it in-process:
import { createBonumMcpServer, depsFromEnv } from 'bonum-psp-mcp';
import { serveStdio } from '@modelcontextprotocol/server/stdio';
const deps = depsFromEnv(process.env); // never throws; problems become deps.warnings
serveStdio(() => createBonumMcpServer(deps));License
MIT © 2026 Jack Infinite
