midtrans-mcp
midtrans-mcp
An MCP server for Midtrans, Indonesia's payment gateway. Let your AI coding client or assistant check transactions, create Snap checkouts and payment links, cancel, and refund — without leaving your editor.
Unofficial community project. Not affiliated with Midtrans / GoTo Financial. Midtrans has no official MCP server; this fills the gap.
Tools
Tool | What it does | Changes state |
| Full status of a transaction by | No |
| Create a Snap transaction, returns token + | Yes |
| Create a Payment Link and return its URL | Yes |
| Cancel a cancellable transaction | Yes |
| Refund a settled transaction (full or partial) | Yes — moves money |
Related MCP server: vnpay-mcp
Quick start
You need a Midtrans Server Key (dashboard → Settings → Access Keys). Start with a Sandbox key while testing.
Claude Code
claude mcp add midtrans \
-e MIDTRANS_SERVER_KEY=SB-Mid-server-xxxxxxxx \
-- npx -y midtrans-mcpCursor / other MCP clients (mcp.json)
{
"mcpServers": {
"midtrans": {
"command": "npx",
"args": ["-y", "midtrans-mcp"],
"env": {
"MIDTRANS_SERVER_KEY": "SB-Mid-server-xxxxxxxx"
}
}
}
}Run from source
git clone https://github.com/ryoangriawan96/midtrans-mcp.git
cd midtrans-mcp
npm install
npm run build
MIDTRANS_SERVER_KEY=SB-Mid-server-xxxxxxxx node dist/index.jsConfiguration
Variable | Required | Default | Meaning |
| Yes | — | Your Midtrans Server Key. Sandbox keys start with |
| No |
| Set to |
| No |
| Set to |
Example prompts
“Check the status of order
ORDER-123.”“Create a Snap transaction for order
ORDER-124, Rp150.000, GoPay and BCA VA only.”“Make a payment link titled ‘Kelas Online — November’ for Rp299.000, valid 3 days.”
“Refund order
ORDER-100in full, reason: customer cancelled.”
Security
The Server Key is read only from the environment and is sent only to Midtrans over HTTPS. It is never logged, and error messages never contain the key or request headers.
Read-only mode: set
MIDTRANS_READ_ONLY=trueand only the status-check tool exists — the AI physically cannot create, cancel, or refund anything.Refund and cancel are separate, explicit tools. Nothing calls them implicitly, and your MCP client will ask for approval before running them if you keep tool approvals on (recommended for production keys).
All inputs are validated before any request is made:
order_idis limited to Midtrans's character set and length, IDR amounts must be positive integers under a sane ceiling, and free-text fields are length-capped.Every API call has a 30-second timeout, redirects are refused, and responses are size-capped before being handed to the model.
Use a Sandbox key while developing. Treat a production Server Key like a password: anyone holding it can refund your customers.
Development
npm install
npm run build # type-check + compile to dist/
npm test # smoke test: starts the server, lists tools, checks auth headerLicense
MIT © Ryo Angriawan
Available Tools
5 toolscancel_transactionCancel transactionA
Cancel a Midtrans transaction by order_id. Only works for transactions that can still be cancelled (e.g. pending payments). This changes real state in the merchant account — use deliberately.
Inputs: order_id (required).
create_payment_linkCreate payment linkA
Create a reusable Midtrans Payment Link and return its URL. The customer opens the URL to pay. Amount is in IDR (integer).
Inputs: title (required), amount (required), description, expiry_unit, +3 more.
create_snap_transactionCreate Snap transactionB
Create a Midtrans Snap transaction and get back a token and redirect_url for the Snap payment page. gross_amount is in IDR (integer).
Inputs: order_id (required), gross_amount (required), item_details, customer_details, +1 more.
get_transaction_statusGet transaction statusA
Check the current status of a Midtrans transaction by its order_id. Returns the full status object from Midtrans (transaction_status, fraud_status, payment_type, gross_amount, status_code, and more). Read-only.
Inputs: order_id (required).
refund_transactionRefund transactionA
Refund a settled Midtrans transaction by order_id. Omit amount for a full refund. This moves real money back to the customer — use deliberately.
Inputs: order_id (required), amount, reason, refund_key.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Four tools map cleanly to distinct lifecycle actions (get status, cancel, refund) keyed by order_id, leaving little ambiguity. The one risk is between create_snap_transaction and create_payment_link, which both create a payable resource and return a URL/token, though the descriptions distinguish a one-time Snap token from a reusable link.
Names are all snake_case verb_first patterns (get_, create_, cancel_, refund_) with the resource qualifier, so the pattern is predictable. Minor deviation: get_transaction_status is verb_noun_noun while the creates embed the provider name (snap/payment) rather than the resource, but this remains readable.
Five tools is tightly scoped and each one maps to a real payment operation with no filler. It is slightly thin for a payment-gateway surface but proportionate to a focused Midtrans integration.
Core create/status/cancel/refund flows are covered, but there are notable gaps: no expire_transaction for pending payments, no capture/approve for card pre-authorization, and no transaction listing or payment-link lookup. Agents can work around some of this (cancel instead of expire), but the surface is not full lifecycle coverage.
Maintenance
Related MCP Connectors
MCP server for Modern Treasury — payment orders, transactions, counterparties and ledgers.
Billing proxy for MCP servers. Adds Stripe and x402 crypto payments without writing billing code.
MCP server for MaxMind minFraud — score transactions for fraud risk from your AI assistant.
MCP server for Lemon Squeezy — stores, products, orders, subscriptions, license keys.
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP server for Xendit payment APIs. Invoices, disbursements, balance checks, and bank transfers across Southeast Asia.673 npm4MIT
- AlicenseBqualityDmaintenanceMCP server for VNPay payment gateway (Vietnam). Supports payment URL generation, transaction queries, refunds, tokenized payments, and IPN verification with HMAC-SHA512 signing.810 npmMIT
- AlicenseBqualityDmaintenanceMCP server for Xendit payment gateway (Indonesia/Philippines) that provides tools to create invoices, disbursements, virtual accounts, QR codes, e-wallet charges, and check balances.1018 npmMIT
- AlicenseAqualityCmaintenanceMCP server for PayMongo payment gateway (Philippines). Supports payment intents, sources, payments, refunds, and checkout sessions via Basic Auth.2422 npm2MIT