Mercado Pago ウェブフック(サーバー間の自動通知)の設定と動作確認を行います。MCP ウェブフック機能(ウェブフック保存、通知履歴取得)をラップし、すべての受信システムが実装する必要のある HMAC-SHA256 署名検証パターン(データの真正性を確認する暗号化手法)を提供します。 次のような場合に使用: - 通知受信機能を新規追加する場合 - 通知機能のトラブルシューティング(問題調査)を行う場合 - 通知処理のセキュリティを強化する場合
Configure and validate Mercado Pago webhooks. Wraps the MCP webhook tools (save_webhook, notifications_history) and provides the HMAC-SHA256 signature validation pattern that every receiver must implement. Use when adding, debugging, or hardening notification handling.
このスキルはウェブフックの通知に関するあらゆる機能を提供します。HMAC検証(メッセージ改ざん防止の署名検証)パターンはこのスキルだけに実装されており、他のスキルはすべてここに処理を委譲しています。
このスキルが開始するとき、MCPの状態を確認しないでください。受信パターンの構築と確認は静的な処理であり、MCP接続を必要としません。
以下の特定の処理を実行する直前のみ接続してください:
| 処理 | 必要なMCPツール |
|---|---|
| 言語別の署名例を取得 | search_documentation |
| 未知の、または国別の概念を解決する | search_documentation |
| コールバックURLを登録・更新する | save_webhook |
| ウェブフック配信を確認・診断する | notifications_history |
オンデマンド認証手順:
application_list を呼ばないでください。mcp__plugin_mercadopago_mcp__authenticate を呼び出してください。plugin:mercadopago:mcp を有効にする方法を説明してください。静的な構築・確認作業はオフラインのままで利用可能にしてください。次のチェックリストは、開発者がMCP対応の処理を選択したときだけ表示してください:
ウェブフックをライブで設定する前に、次が必要です:
- [ ] Mercado Pago開発者アカウント
- [ ] Developer Dashboardで作成したアプリ
- [ ] テスト認証情報:APP_USR- アクセストークン + 公開鍵(タブ {test_tab})
- [ ] ウェブフック署名シークレット(Dashboard → Webhooks → Signature secret)
接続は、選択したMCP処理の直前にリクエストされます。
開発者に次のどの処理を望むか質問してください(または $ARGUMENTS から推測):
| 処理 | 呼び出すツール | 用途 |
|---|---|---|
| MP アプリ上のウェブフックURLを設定 | save_webhook |
初回セットアップ、またはエンドポイントの更新 |
| 配信失敗を診断 | notifications_history |
受け取り漏れ、または失敗した通知を調査 |
| 受信コードのひな形を生成 | (MCP呼び出しなし — 下記パターンを表示) | コードベースに受信部を追加 |
これらを組み合わせることができます:受信コード生成 → save_webhook → 実際のテスト支払い実行 → notifications_history で配信を確認。
Mercado Pagoはすべての通知に、ダッシュボードの「Webhooks → Signature secret」で取得したシークレットで署名します。x-signature ヘッダは ts=...,v1=... で構成され、v1 は標準形文字列 "id:{data.id};request-id:{x-request-id};ts:{ts};" の HMAC-SHA256 です。
すべての受信コードは以下の要件を満たす必須です:
x-signature と x-request-id を読み取ってください。x-signature から ts と v1 をパースしてください。data.id と x-request-id と ts で標準形文字列を構築してください。HMAC-SHA256(標準形文字列, シークレット) を計算し、定時間比較で v1 と比較してください。200 で応答してください — その後、イベント処理は非同期で実行してください。Mercado Pagoは非200の応答に対し、最大約24時間の指数バックオフで再試行します。data.id + topic)は複数回届く可能性があります。重複除外キーとして使用してください。id:<data.id>;request-id:<x-request-id>;ts:<ts>;
import crypto from "node:crypto";
const SECRET = process.env.MP_WEBHOOK_SECRET;
export function mpWebhook(req, res) {
const signature = req.header("x-signature") ?? "";
const requestId = req.header("x-request-id") ?? "";
const parts = Object.fromEntries(
signature.split(",").map((p) => p.split("=").map((s) => s.trim()))
);
const ts = parts.ts;
const v1 = parts.v1;
const dataId = req.body?.data?.id;
if (!ts || !v1 || !dataId || !requestId) return res.status(400).end();
const canonical = `id:${dataId};request-id:${requestId};ts:${ts};`;
const expected = crypto.createHmac("sha256", SECRET).update(canonical).digest("hex");
const ok = expected.length === v1.length &&
crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(v1));
if (!ok) return res.status(401).end();
res.status(200).end();
// 200応答後に非同期処理
queueMicrotask(() => handleEvent(req.body));
}
その他の言語については、ステップ0をすぐに適用してから、MCP search_documentation に次のように問い合わせてください:
"webhook signature validation {言語}" (例:python、java、php、ruby、go、dotnet)通知ボディには type(トピック)と data.id が含まれています。よくあるトピック:
| トピック | 発生条件 | 取得するリソース |
|---|---|---|
payment |
支払いステータス変更(Payments API) | GET /v1/payments/{id} |
orders |
ポイント / QRコードイベント(Orders API) | GET /v1/orders/{id} |
merchant_order |
マーチャント注文更新 — レガシー(Checkout Pro / QR対面型の旧API) | GET /merchant_orders/{id} |
topic_claims_integration_wh |
チャージバック | GET /v1/chargebacks/{id} |
point_integration_wh |
ポイント端末イベント — レガシー(旧Point Integration API) | ポイント旧API — 国別にMCPで問い合わせ |
subscription_preapproval |
サブスクリプションステータス変更 | GET /preapproval/{id} |
subscription_authorized_payment |
定期課金試行 | GET /authorized_payments/{id} |
表にないトピックの場合は、推測せずにステップ0をすぐに適用してから、MCPに最新リストを問い合わせてください。
save_webhook)オンデマンド接続:
save_webhookの直前にステップ0を適用してください。事前にapplication_listを呼ばないでください。
mcp__plugin_mercadopago_mcp__save_webhook(
callback="https://<production-url>/mp/webhook",
callback_url="https://<your-domain>/mp/webhook",
topics=["payment", "merchant_order", ...]
)
応答でURLとトピックが正しく登録されたことを確認してください。
MCPに simulate_webhook はもう存在しません。受信コードをテストするには:
200 を返し、イベントをべき等に処理したことを確認してくださいnotifications_history で配信を確認する直前にステップ0を適用してください:
mcp__plugin_mercadopago_mcp__notifications_history()
オンデマンド接続:
notifications_historyの直前にステップ0を適用してください。事前にapplication_listを呼ばないでください。
mcp__plugin_mercadopago_mcp__notifications_history()
配信指標と失敗の内訳(タイムアウト、非200応答、署名不一致など)を返します。本番環境で通知が受け取れない場合、これを使用してください。
200 で応答してください。長い同期処理は再試行を招き、受信ボックスに氾濫して本当の問題を隠します。data.id + type を使用してください。?id=&topic= スタイルのGET通知)は非推奨です。新しい統合は、ここで説明した最新の署名付きウェブフックだけを使用します。mp-integrate を使用してください。mp-review を使用してください。This skill is for everything notifications. It is the only place where the HMAC validation pattern lives — every other skill defers here.
Do not inspect MCP state when this skill starts. Scaffolding and reviewing the receiver pattern are static operations and require no MCP connection.
Connect only immediately before one of these selected operations:
| Operation | Required MCP tool |
|---|---|
| Fetch a language-specific signature example | search_documentation |
| Resolve an unknown or country-specific topic | search_documentation |
| Register or rotate the callback URL | save_webhook |
| Confirm or diagnose webhook delivery | notifications_history |
On-demand authentication procedure:
application_list as a connection probe.mcp__plugin_mercadopago_mcp__authenticate.plugin:mercadopago:mcp. Keep any static scaffold/review work available offline.Show this prerequisites checklist only when the developer selects an MCP-backed action:
Before configuring webhooks live, you'll need:
- [ ] A Mercado Pago developer account
- [ ] An app created in the Developer Dashboard
- [ ] Test credentials: APP_USR- access token + public key (tab {test_tab})
- [ ] The webhook signature secret (Dashboard → Webhooks → Signature secret)
Connection will be requested immediately before the selected MCP operation.
Ask the developer (or infer from $ARGUMENTS) which of these they want:
| Action | Tool to call | When |
|---|---|---|
| Configure the webhook URL on the MP application | save_webhook |
First time setup or rotating the endpoint |
| Diagnose delivery failures | notifications_history |
Investigating missed/failed notifications |
| Scaffold the receiver code | (no MCP call — render the pattern below) | Adding the receiver to the codebase |
You may chain them: scaffold the receiver → save_webhook → trigger a real test payment → use notifications_history to confirm delivery.
Mercado Pago signs every notification with the secret returned in the dashboard at Webhooks → Signature secret. The x-signature header is composed of ts=...,v1=... where v1 is the HMAC-SHA256 of the canonical string "id:{data.id};request-id:{x-request-id};ts:{ts};".
Every receiver MUST:
x-signature and x-request-id from the request headers.ts and v1 out of x-signature.data.id (from the JSON body) and x-request-id and ts.HMAC-SHA256(canonical, secret) and compare in constant time with v1.200 immediately if the signature is valid — process the event asynchronously afterwards. Mercado Pago retries on non-200 responses with exponential backoff for up to ~24 hours.data.id + topic as the dedup key.id:<data.id>;request-id:<x-request-id>;ts:<ts>;
import crypto from "node:crypto";
const SECRET = process.env.MP_WEBHOOK_SECRET;
export function mpWebhook(req, res) {
const signature = req.header("x-signature") ?? "";
const requestId = req.header("x-request-id") ?? "";
const parts = Object.fromEntries(
signature.split(",").map((p) => p.split("=").map((s) => s.trim()))
);
const ts = parts.ts;
const v1 = parts.v1;
const dataId = req.body?.data?.id;
if (!ts || !v1 || !dataId || !requestId) return res.status(400).end();
const canonical = `id:${dataId};request-id:${requestId};ts:${ts};`;
const expected = crypto.createHmac("sha256", SECRET).update(canonical).digest("hex");
const ok = expected.length === v1.length &&
crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(v1));
if (!ok) return res.status(401).end();
res.status(200).end();
// process asynchronously after responding 200
queueMicrotask(() => handleEvent(req.body));
}
For other languages, apply Step 0 immediately before querying MCP search_documentation with:
"webhook signature validation {language}" (e.g., python, java, php, ruby, go, dotnet).The notification body contains type (the topic) and data.id. Common topics:
| Topic | When | Resource to fetch |
|---|---|---|
payment |
Payment status change (Payments API) | GET /v1/payments/{id} |
orders |
Point / QR Code event (Orders API) | GET /v1/orders/{id} |
merchant_order |
Merchant order updated — legacy (Checkout Pro / QR attended via legacy API) | GET /merchant_orders/{id} |
topic_claims_integration_wh |
Chargebacks | GET /v1/chargebacks/{id} |
point_integration_wh |
Point device events — legacy (old Point Integration API) | Point legacy API — query MCP for the country |
subscription_preapproval |
Subscription status change | GET /preapproval/{id} |
subscription_authorized_payment |
Recurring charge attempt | GET /authorized_payments/{id} |
If a topic is not in this table, apply Step 0 immediately before querying MCP for the latest list rather than guessing.
save_webhook)Connect on demand: apply Step 0 immediately before
save_webhook. Do not callapplication_listfirst.
mcp__plugin_mercadopago_mcp__save_webhook(
callback="https://<production-url>/mp/webhook",
callback_url="https://<your-domain>/mp/webhook",
topics=["payment", "merchant_order", ...]
)
Confirm the response shows the URL and topics correctly registered.
simulate_webhook no longer exists in the MCP. To test your receiver:
200 and processed the event idempotentlyApply Step 0 immediately before using notifications_history to confirm delivery:
mcp__plugin_mercadopago_mcp__notifications_history()
Connect on demand: apply Step 0 immediately before
notifications_history. Do not callapplication_listfirst.
mcp__plugin_mercadopago_mcp__notifications_history()
Returns delivery metrics and a breakdown of failures (timeouts, non-200 responses, signature mismatches). Use this when notifications are missing in production.
200 before processing. A long synchronous handler causes retries that flood the receiver and can mask the real failure.data.id + type as the dedup key.?id=&topic= GET-style notification) is deprecated. New integrations use only the modern signed webhook described here.mp-integrate.mp-review.原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。