mcpField
M
mcp-safrapay

mcp-safrapay

Local
github.com/codesparFinance275Updated 4w ago

About mcp-safrapay

mcp-safrapay is an MCP server for Safrapay, the acquirer run by Banco Safra, covering credit cards, Pix, boleto, split rules and chargebacks. It targets mid-to-large Brazilian merchants. The project is at 0.1.0-alpha.1, and its authentication flow and endpoints still need validation against a sandbox.

Key features

  1. 01Credit card pre-authorization, capture, cancel and refund
  2. 02Pix and boleto charge creation
  3. 03Split rule configuration and settlement reports
  4. 043-D Secure authentication, card tokenization and installment simulation
  5. 05Chargeback details, recurring billing and payment links

Use cases

  1. 01Accepting credit card and Pix payments from a merchant back office
  2. 02Configuring splits and retrieving settlement reports for reconciliation
  3. 03Reviewing chargeback details and managing recurring subscriptions

MCP support

The server exposes 22 tools that wrap Safrapay gateway, portal and reconciliation operations for MCP clients.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"codespar-mcp-safrapay": {
"command": "npx",
"args": [
"-y",
"@codespar/mcp-safrapay"
],
"env": {
"SAFRAPAY_CLIENT_ID": "<SAFRAPAY_CLIENT_ID>",
"SAFRAPAY_CLIENT_SECRET": "<SAFRAPAY_CLIENT_SECRET>",
"SAFRAPAY_MERCHANT_ID": "<SAFRAPAY_MERCHANT_ID>",
"SAFRAPAY_ENV": "<SAFRAPAY_ENV>"
}
}
}
}
Run commandnpx -y @codespar/mcp-safrapay
Environment variables to set
SAFRAPAY_CLIENT_IDSafrapay merchant CNPJ (sent as merchantCredential header on auth)
SAFRAPAY_CLIENT_SECRETSecretSafrapay MerchantToken used to compute the BCRYPT Authorization header on auth
SAFRAPAY_MERCHANT_IDSafrapay merchant id (used in request bodies where applicable)
SAFRAPAY_ENVEnvironment: 'sandbox' or 'production'. Defaults to sandbox.

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npm@codespar/mcp-safrapay0.2.0-alpha.3

Tools

22

Saved tool list · updated 2w ago

ParameterTypeRequiredDescription
cardobjectYesCard data. Prefer card_token from tokenize_card over raw PAN.
card.brandstringNo
card.numberstringNoPAN; never log
card.card_tokenstringNoToken from tokenize_card
card.holder_namestringNo
card.security_codestringNo
card.expiration_yearstringNo
card.expiration_monthstringNo
amountnumberYesAmount in cents
preauthbooleanNotrue = pre-authorization only; false = auth + capture
currencystringNoISO-4217 currency code (default BRL)
customerobjectYesCustomer identity
customer.namestringYes
customer.emailstringNo
customer.phonestringNo
customer.customer_idstringNo
customer.document_typeenumYesCPF | CNPJ
customer.document_numberstringYes
order_idstringYesMerchant-side order identifier
installmentsnumberNoNumber of installments (1 = à vista)
soft_descriptorstringNoStatement descriptor

Details

From the project README

@codespar/mcp-safrapay

MCP server for Safrapay — Banco Safra's acquirer. B2B-banking crossover focused on mid-to-large BR merchants and private-banking clientele.

Safrapay's API surface is operated on Aditum's payment platform (documented at safrapay-docs.aditum.com.br). The gateway, portal, reconciliation, and webhook products are split across separate base hosts.

Status: 0.1.0-alpha.1. The endpoint paths here were derived from the Aditum-hosted Safrapay developer docs (publicly reachable). Auth flow (BCRYPT + CNPJ on gateway, JWT Bearer thereafter) is best-effort: the BCRYPT hash input format is not fully specified in public docs and very likely requires a sandbox account to finalize. Treat all tools as scaffolding until validated against a live sandbox merchant.

Tools (22)

ToolPurpose
authorize_paymentAuthorize a credit-card payment on Safrapay.
capture_paymentCapture a previously authorized (pre-auth) payment.
cancel_paymentCancel (void) an authorized-but-uncaptured payment.
refund_paymentRefund a captured payment.
create_pixCreate a Pix charge.
create_boletoCreate a boleto charge.
get_paymentRetrieve a charge by Safrapay chargeId.
tokenize_cardTokenize a card for PCI-safe reuse.
create_split_ruleConfigure split distribution for an existing charge.
get_statementRetrieve the digital statement (extrato).
list_transactionsList charges with optional filters.
delete_card_tokenRevoke a stored card token.
search_by_merchant_orderLook up charges by the merchant-side order identifier (the order_id supplied at creation).
query_chargebackRetrieve chargeback (contestacao) detail for a charge: reason code, acquirer deadline, dispute amount, evid...
query_installmentsSimulate an installment plan for a given amount.
authenticate_3dsKick off 3-D Secure authentication before authorize_payment.
create_recurrenceCreate a recurring-billing subscription.
get_recurrenceRetrieve a recurrence by id: schedule, next-charge date, charge history, status.
cancel_recurrenceCancel an active recurrence.
get_settlement_reportRetrieve a settlement (liquidacao) report from the reconciliation host.
create_payment_linkCreate a hosted-checkout payment link.
register_webhookBulk-register webhook subscriptions on the Safrapay webhook product.

Install

npm install @codespar/mcp-safrapay@alpha

Environment

SAFRAPAY_CLIENT_ID="..."      # Merchant CNPJ (sent as merchantCredential)
SAFRAPAY_CLIENT_SECRET="..."  # MerchantToken (used to compute BCRYPT)
SAFRAPAY_MERCHANT_ID="..."    # Safrapay merchant id (body field where required)
SAFRAPAY_ENV="sandbox"        # 'sandbox' (default) or 'production'

Base URLs

Safrapay splits its API into four products hosted on distinct domains:

ProductSandboxProduction
Gateway (payments)https://payment-dev.aditum.com.brhttps://payment.aditum.com.br
Portal (management)https://portal-dev.aditum.com.brhttps://portal-api.aditum.com.br
Reconciliationhttps://reconciliation-dev.aditum.com.brhttps://reconciliation-api.aditum.com.br
Webhookhttps://webhook-dev.aditum.com.brhttps://webhook.aditum.com.br

Authentication

Gateway uses a two-step bootstrap:

  1. POST {gateway}/v2/merchant/auth with headers Authorization: <BCRYPT(CNPJ+MerchantToken)> and merchantCredential: <CNPJ> to exchange for a JWT access token.
  2. Subsequent calls send Authorization: Bearer <jwt>.

The server caches the JWT in memory until 60 s before expiry. The BCRYPT input concatenation is an informed guess; refine once you have a sandbox account.

Run

# stdio (default)
npx @codespar/mcp-safrapay

# HTTP
MCP_HTTP=true MCP_PORT=3000 npx @codespar/mcp-safrapay

Endpoint map (used by tools)

ToolMethodPath (under gateway, unless noted)
authorize_paymentPOST/v2/charge/authorization or /v2/charge/preauthorization
capture_paymentPUT/v2/charge/capture/{chargeId}
cancel_paymentPUT/v2/charge/cancelation/{chargeId}
refund_paymentPUT/v2/charge/cancelation/{chargeId} (partial amount)
create_pixPOST/v2/charge/pix
create_boletoPOST/v2/charge/boleto
get_paymentGET/v2/charge/{chargeId}
tokenize_cardPOST/v2/card (or /v2/temporary/card)
create_split_rulePUT/v2/charge/split/{chargeId}
get_statementGET/v2/Account/Movement/Extract
list_transactionsGET/v2/charges
register_webhookPOST{webhook}/v1/webhook/bulk

Enterprise

Need governance, budget limits, and audit trails for agent payments? CodeSpar Enterprise adds policy engine, payment routing, and compliance templates on top of these MCP servers.

License

MIT

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.