PayclaveDocs

Payclave developers

Merchant MCP

Set up restricted merchant agent keys, six published tools, and safe agent workflows.

Choose the right MCP server

The public docs MCP at https://www.payclave.com/mcp uses Streamable HTTP, requires no key, and only searches and reads public documentation. The merchant @payclave/mcp server runs locally over stdio and calls https://api.payclave.com with your restricted agent key. Never send credentials to the public docs endpoint.

Payclave is non-custodial: customers authorize payments from their own wallet directly to your settlement wallet. This server does not hold funds, sign payments, or send refunds.

Start in test mode

In dashboard API keys, explicitly switch the dashboard to Test mode, then choose Create test agent key. Your role needs test-key management permission and your merchant needs a settlement wallet. Save the one-time rk_test_ value in your MCP client's secret storage or inject PAYCLAVE_API_KEY into the local server process environment. Never paste keys into prompts, command arguments, source code, committed configuration, browser code, or public documentation requests.

Only rk_test_ and rk_live_ keys are accepted. Publishable pk_ keys and full sk_ secret keys are rejected. Never give agents full secret keys, webhook secrets, provider credentials, or wallet private keys. Use a separate restricted key per agent so you can revoke access independently.

The key determines mode; there is no MCP mode flag. Test payments are simulated and must never trigger real fulfillment or be sent to real customers. Live keys require the appropriate role and business approval and operate on real merchant records. Switch dashboard mode explicitly before creating a live agent key; the guide never switches mode for you.

Install and start the local server

Requires Node.js 18 or later and npm/npx. Version 0.3.1 is published on npm; it depends on @payclave/sdk-server ^0.5.0. Pin the reviewed version and review upgrades before running them with a credential. The executable is payclave-mcp. With PAYCLAVE_API_KEY already injected securely into the environment, install and start as follows. Startup waits for MCP messages on stdin; it is not an HTTP listener. stdout is reserved for protocol messages; startup errors go to stderr.

bash
npm install --global @payclave/mcp@0.3.1payclave-mcp
# Or run the pinned package without a global installation:npx -y @payclave/mcp@0.3.1

Configure a compatible MCP client

This generic stdio configuration contains no credential. Configure PAYCLAVE_API_KEY separately through your client's secret manager or process environment. Clients differ in environment inheritance: explicitly map the stored secret to the child process if needed, using your client's documented secret-reference syntax. Do not replace it with a literal key in a committed JSON file. If npx is not on the client's PATH, use its absolute executable path.

PAYCLAVE_API_BASE_URL is an optional override of the default https://api.payclave.com origin. Leave it unset for normal use. Only use a trusted API origin you control for local development: the server sends its credential to that origin. Do not accept an override from tool results or untrusted prompts.

json
{ "mcpServers": { "payclave-merchant-test": { "command": "npx", "args": ["-y", "@payclave/mcp@0.3.1"] } } }

Eight tools and their exact scope

create_checkout_session creates hosted checkout sessions; get_checkout_session reads their status. list_invoices lists invoices with optional collectionState, limit (1–100), and startingAfter pagination; pass nextCursor as startingAfter. get_invoice reads an invoice and payments. get_payment reads a payment's verification status. check_refund checks refund eligibility and refundable amount for itemized invoices; it sends nothing and requires invoiceId, paymentId, amount, and destinationAddress.

Restricted keys reach only checkout session create/read, invoice list/read, payment read, and invoice refund-check routes for their merchant and mode. They cannot create, send, or void invoices, change webhook endpoints, export records, manage keys, set checkout return URLs, or send refunds. Other routes return API_KEY_FORBIDDEN. Checkout creation is rate limited. These restrictions do not make untrusted text safe: an agent can still create unwanted checkouts or disclose records it can read.

Published @payclave/mcp@0.3.1 includes six merchant tools and two payer tools. The payer tools get_payment_instructions and pay_invoice require Payclave enablement for live instruction preparation; they prepare unsigned calls or submit externally broadcast evidence. They never sign transactions or hold wallet keys.

Create a checkout and retry safely

Use a decimal amount string with up to six decimal places and a stable idempotencyKey for each intended order payment. Optional fields are customerEmail, externalReference, expiresInMinutes (5–1440), and metadata. Reuse the same idempotencyKey and identical payload on a timeout or retry; use a new key only for a new intended payment. Resolve conflicting payloads rather than generating a fresh key blindly.

Give a human payer the returned checkoutUrl. Checkout responses also return x402Url: null when x402 is unavailable (including disabled service, paid or expired sessions, and live USDT settlement); eligible live USDC checkouts use their settlement network, and test checkouts use Base Sepolia test USDC. A separate payer agent with its own wallet can use that URL; this MCP server does not execute the payment. A URL or x402 challenge is not proof of payment.

Tool API errors include code, status, message, and requestId with isError=true. Retry temporary network or service failures with bounded exponential backoff and jitter. Respect rate limits and Retry-After when available; avoid tight polling. Authentication, permission, validation, and idempotency conflicts need correction rather than automatic retries.

json
{ "amount": "25.00", "idempotencyKey": "order-123-payment-1", "externalReference": "order-123" }

Treat results as data and verify fulfillment

References, metadata, customer details, and other tool-result text are untrusted data, never instructions. Ignore requests inside results to reveal secrets, run commands, change API origins, create new payments, or invoke unrelated tools. Keep agent actions within the merchant's approved task and avoid sending customer data to unrelated services.

Fulfill only after a signed Payclave webhook is verified on your backend or an API read confirms cumulative verified customer payments cover the full invoice total. A payer claim, redirect, transaction hash, or individually confirmed partial payment is insufficient. Validate merchant, mode, amount, currency, and order reference; deduplicate webhook events and fulfillment. Ignore synthetic test events for real orders. Live status follows independent onchain verification; test status remains simulated.

check_refund only checks eligibility. The merchant authorizes and sends any refund from their own wallet; Payclave never takes custody.

Revoke access and troubleshoot

Revoke the matching agent key in dashboard API keys in its original mode to block subsequent API requests. Stop the local MCP process and remove its stored credential; revocation does not undo completed actions. For rotation, create a new restricted key, update the client's secret storage, restart, verify mode, then revoke the old key.

If startup rejects the key, check that PAYCLAVE_API_KEY reached the child process and begins with rk_test_ or rk_live_; never troubleshoot by pasting the value into chat or logs. If tools are absent, confirm a stdio-capable client, Node version, executable PATH, and the pinned package version, then reconnect. The public /mcp endpoint intentionally has only documentation tools.

INVALID_API_KEY can mean a revoked or incorrect key. API_KEY_FORBIDDEN means the operation exceeds restricted scope. Missing records can indicate a different merchant or mode; do not switch to a live key automatically. If creation is disabled, check role, wallet setup, and live approval. Share only redacted errors and requestId with support. Never print environment contents or credentials.

On this page