agent-commerce-protocol-mcp 1.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_commerce_protocol_mcp-1.0.1.dist-info/METADATA +136 -0
- agent_commerce_protocol_mcp-1.0.1.dist-info/RECORD +7 -0
- agent_commerce_protocol_mcp-1.0.1.dist-info/WHEEL +5 -0
- agent_commerce_protocol_mcp-1.0.1.dist-info/entry_points.txt +2 -0
- agent_commerce_protocol_mcp-1.0.1.dist-info/licenses/LICENSE +21 -0
- agent_commerce_protocol_mcp-1.0.1.dist-info/top_level.txt +1 -0
- server.py +304 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-commerce-protocol-mcp
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Agent Commerce Protocol MCP — bridges Stripe ACP + Google AP2 + Coinbase x402 for agent payments inside ChatGPT, AP2 coalition rails, and pay-per-call x402 flows. By MEOK AI Labs.
|
|
5
|
+
Author-email: Nicholas Templeman <nicholas@meok.ai>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://meok.ai/a2a
|
|
8
|
+
Project-URL: Repository, https://github.com/CSOAI-ORG/agent-commerce-protocol-mcp
|
|
9
|
+
Project-URL: Documentation, https://meok.ai/protocols
|
|
10
|
+
Keywords: mcp,mcp-server,model-context-protocol,stripe,acp,agentic-commerce,ap2,x402,agent-payments,meok
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
18
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
19
|
+
Classifier: Intended Audience :: Developers
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: mcp[cli]>=1.3.0
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# Agent Commerce Protocol MCP
|
|
27
|
+
|
|
28
|
+
> ## 🧱 Part of the MEOK A2A Substrate
|
|
29
|
+
>
|
|
30
|
+
> All 12 A2A primitives + Stripe ACP bridge as one signed pipeline for
|
|
31
|
+
> **£499/mo**. See [meok.ai/a2a](https://meok.ai/a2a).
|
|
32
|
+
|
|
33
|
+
# Bridges Stripe ACP + Google AP2 + Coinbase x402
|
|
34
|
+
|
|
35
|
+
<!-- mcp-name: io.github.CSOAI-ORG/agent-commerce-protocol-mcp -->
|
|
36
|
+
|
|
37
|
+
[](https://pypi.org/project/agent-commerce-protocol-mcp/)
|
|
38
|
+
[](LICENSE)
|
|
39
|
+
[](https://registry.modelcontextprotocol.io)
|
|
40
|
+
|
|
41
|
+
## The "ACP" name collision
|
|
42
|
+
|
|
43
|
+
There are two protocols called "ACP" — they do different things:
|
|
44
|
+
|
|
45
|
+
| | IBM ACP | **Stripe ACP** |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| **Full name** | Agent Communication Protocol | Agentic Commerce Protocol |
|
|
48
|
+
| **Owner** | IBM Research (was) | Stripe + OpenAI |
|
|
49
|
+
| **Status** | Merged into A2A under Linux Foundation Sept 2025 | LIVE — Apache 2.0 |
|
|
50
|
+
| **What it does** | Agent-to-agent messaging | In-conversation payments |
|
|
51
|
+
| **Where you hit it** | A2A protocol stack | ChatGPT merchant flows |
|
|
52
|
+
| **MEOK coverage** | A2A Substrate (12 MCPs) | **THIS MCP** |
|
|
53
|
+
|
|
54
|
+
This MCP is **the Stripe ACP one** — agent payments inside ChatGPT-style flows.
|
|
55
|
+
|
|
56
|
+
## What this gives you
|
|
57
|
+
|
|
58
|
+
The **only MCP that bridges all 3 live agent-payment protocols**:
|
|
59
|
+
|
|
60
|
+
- **Stripe ACP** — primary, for ChatGPT merchant flows
|
|
61
|
+
- **Google AP2** — bridged, for the 60-org Mastercard/PayPal/Adyen coalition
|
|
62
|
+
- **Coinbase x402** — bridged, for HTTP-402 pay-per-call without a Stripe account
|
|
63
|
+
|
|
64
|
+
Plus EU compliance overlays automatically applied to every transaction: **PSD2** (EU), **MiCA** (EU crypto), **6AMLD** (EU AML), **FinCEN BSA** (US).
|
|
65
|
+
|
|
66
|
+
Every payment intent + verification signs into the MEOK audit chain at `verify.meok.ai`.
|
|
67
|
+
|
|
68
|
+
## Tools
|
|
69
|
+
|
|
70
|
+
| Tool | Purpose |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `discover_acp_merchants(category?)` | List Stripe-ACP-compatible merchants |
|
|
73
|
+
| `prepare_payment_intent(merchant_id, items, currency)` | Build Stripe ACP intent |
|
|
74
|
+
| `sign_payment_intent(intent)` | HMAC-sign + chain into audit log |
|
|
75
|
+
| `verify_acp_response(response, expected_intent_id?)` | Verify merchant attestation |
|
|
76
|
+
| `bridge_to_ap2_mandate(intent, user_consent_jwt?)` | Convert to Google AP2 mandate |
|
|
77
|
+
| `bridge_to_x402_paywall(intent)` | Convert to Coinbase HTTP 402 |
|
|
78
|
+
| `list_supported_protocols()` | Capability discovery |
|
|
79
|
+
|
|
80
|
+
## Quick install
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
uvx agent-commerce-protocol-mcp
|
|
84
|
+
pip install agent-commerce-protocol-mcp
|
|
85
|
+
npx @meok-ai/agent-commerce-protocol-mcp
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Claude Desktop / Cursor / Windsurf MCP config:
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"mcpServers": {
|
|
93
|
+
"agent-commerce-protocol": {
|
|
94
|
+
"command": "uvx",
|
|
95
|
+
"args": ["agent-commerce-protocol-mcp"]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Why this matters for £-revenue
|
|
102
|
+
|
|
103
|
+
Stripe ACP is the protocol Stripe + OpenAI are pushing through ChatGPT's shopping interface. Every ChatGPT merchant gets Stripe ACP free with their OpenAI integration. If your agent participates in ChatGPT commerce (or any merchant flow built on Stripe Connect ACP), you need this MCP to:
|
|
104
|
+
|
|
105
|
+
1. **Initiate signed payment intents** with audit-trail evidence for EU AI Act Article 12 + DORA Article 17
|
|
106
|
+
2. **Bridge to AP2 mandates** if the merchant runs on Mastercard/PayPal/Adyen rails instead of pure Stripe
|
|
107
|
+
3. **Bridge to x402** if your agent settles micropayments on-chain (Base / Polygon / Solana / Lightning)
|
|
108
|
+
|
|
109
|
+
## Sister MCPs
|
|
110
|
+
|
|
111
|
+
Part of the MEOK **A2A** pack:
|
|
112
|
+
|
|
113
|
+
- **agent-commerce-payments-mcp** → invoicing + escrow + AML/KYC
|
|
114
|
+
- **agent-prompt-injection-firewall-mcp** → scan payment prompts for injection
|
|
115
|
+
- **agent-policy-enforcement-mcp** → gate which agents can spend
|
|
116
|
+
- **agent-rate-limiter-mcp** → cap call volume per session
|
|
117
|
+
- **agent-audit-logger-mcp** → hash-chained log of every payment intent
|
|
118
|
+
- **agent-identity-trust-mcp** → buyer DID resolution
|
|
119
|
+
|
|
120
|
+
Full catalogue: [meok.ai/anthropic-registry](https://meok.ai/anthropic-registry)
|
|
121
|
+
|
|
122
|
+
## Protocol coverage + Universal PAYG
|
|
123
|
+
|
|
124
|
+
| Option | Price | Best for |
|
|
125
|
+
|---|---|---|
|
|
126
|
+
| Self-host (this MCP) | £0 — MIT | Devs |
|
|
127
|
+
| This MCP Starter | £29/mo | One-MCP teams |
|
|
128
|
+
| Universal PAYG | £29/mo + £0.0002/call | Spiky usage |
|
|
129
|
+
| A2A Substrate | £499/mo | All 13 A2A MCPs |
|
|
130
|
+
| Universe | £1,499/mo | All 48 MEOK MCPs |
|
|
131
|
+
|
|
132
|
+
Buy: https://meok.ai/a2a
|
|
133
|
+
|
|
134
|
+
## Licence
|
|
135
|
+
|
|
136
|
+
MIT. By [MEOK AI Labs](https://meok.ai) (CSOAI LTD, UK Companies House 16939677). Founder: [Nicholas Templeman](mailto:nicholas@meok.ai).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
server.py,sha256=poqVW2SJ3gcbK8qQzTNaOjZ5FNdoYD6BtvWEbCJktYM,11182
|
|
2
|
+
agent_commerce_protocol_mcp-1.0.1.dist-info/licenses/LICENSE,sha256=MvCcVArpgXoUs5UPGrGvllaurLRAm7p1JcjUy2RGCbI,1131
|
|
3
|
+
agent_commerce_protocol_mcp-1.0.1.dist-info/METADATA,sha256=4krVk7hgSrgPgqjBDOVOPm6Qf-wawogD2iPh0jklbvk,5631
|
|
4
|
+
agent_commerce_protocol_mcp-1.0.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
+
agent_commerce_protocol_mcp-1.0.1.dist-info/entry_points.txt,sha256=PI2kP_rq4GtcK2t2gI_x7lS80AYfwAar0EIabgwp96s,60
|
|
6
|
+
agent_commerce_protocol_mcp-1.0.1.dist-info/top_level.txt,sha256=StKOSmRhvWS5IPcvhsDRbtxUTEofJgYFGOu5AAJdSWo,7
|
|
7
|
+
agent_commerce_protocol_mcp-1.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nicholas Templeman / MEOK AI Labs (CSOAI LTD, UK Companies House 16939677)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
server
|
server.py
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Agent Commerce Protocol MCP — Stripe ACP bridge
|
|
4
|
+
================================================
|
|
5
|
+
|
|
6
|
+
By MEOK AI Labs · https://meok.ai · MIT
|
|
7
|
+
<!-- mcp-name: io.github.CSOAI-ORG/agent-commerce-protocol-mcp -->
|
|
8
|
+
|
|
9
|
+
WHAT THIS BRIDGES
|
|
10
|
+
-----------------
|
|
11
|
+
The Stripe + OpenAI Agentic Commerce Protocol (ACP) — the in-conversation
|
|
12
|
+
payments protocol used by ChatGPT merchants. Apache 2.0, designed for B2C
|
|
13
|
+
agent commerce.
|
|
14
|
+
|
|
15
|
+
NOTE ON THE "ACP" ACRONYM COLLISION
|
|
16
|
+
-----------------------------------
|
|
17
|
+
There are two protocols sharing the "ACP" name:
|
|
18
|
+
• IBM ACP (Agent Communication Protocol) — merged into A2A under Linux
|
|
19
|
+
Foundation in Sept 2025. Covered by MEOK A2A Substrate.
|
|
20
|
+
• Stripe ACP (Agentic Commerce Protocol) — THIS MCP. Separate live
|
|
21
|
+
protocol, ChatGPT merchant-first.
|
|
22
|
+
|
|
23
|
+
OFFERED CAPABILITIES
|
|
24
|
+
--------------------
|
|
25
|
+
- discover_acp_merchants(category): list ACP-compatible merchants
|
|
26
|
+
- prepare_payment_intent(merchant_id, items, currency): build ACP payload
|
|
27
|
+
- sign_payment_intent(intent, signing_key): HMAC-sign + chain to audit log
|
|
28
|
+
- verify_acp_response(response): verify merchant attestation chain
|
|
29
|
+
- bridge_to_ap2_mandate(intent): convert Stripe ACP intent to Google AP2
|
|
30
|
+
Mandate format for cross-coalition use
|
|
31
|
+
- bridge_to_x402_paywall(intent): convert to Coinbase HTTP 402 for
|
|
32
|
+
pay-per-call agent settlement
|
|
33
|
+
|
|
34
|
+
WHEN TO USE
|
|
35
|
+
-----------
|
|
36
|
+
Your agent needs to initiate a purchase inside a Stripe-merchant flow
|
|
37
|
+
(typically ChatGPT shopping, but applicable anywhere ACP is deployed).
|
|
38
|
+
You want the payment intent signed + chained into the MEOK audit log
|
|
39
|
+
alongside DORA Art 17, NIS2 Art 23, EU AI Act Art 12 evidence.
|
|
40
|
+
|
|
41
|
+
PRICING
|
|
42
|
+
-------
|
|
43
|
+
Free MIT self-host · £29/mo Starter · £79/mo Pro · A2A Substrate £499/mo
|
|
44
|
+
(https://meok.ai/a2a) · Universe £1,499/mo
|
|
45
|
+
(https://buy.stripe.com/cNi9AV0xS8wy5g9aqI8k90u)
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
from __future__ import annotations
|
|
49
|
+
import hashlib
|
|
50
|
+
import hmac
|
|
51
|
+
import json
|
|
52
|
+
import os
|
|
53
|
+
import time
|
|
54
|
+
from datetime import datetime, timezone
|
|
55
|
+
from typing import Optional
|
|
56
|
+
from mcp.server.fastmcp import FastMCP
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
mcp = FastMCP("agent-commerce-protocol")
|
|
60
|
+
|
|
61
|
+
_MEOK_API_KEY = os.environ.get("MEOK_API_KEY", "")
|
|
62
|
+
_HMAC_SECRET = os.environ.get("MEOK_HMAC_SECRET", "")
|
|
63
|
+
_STRIPE_API_KEY = os.environ.get("STRIPE_API_KEY", "") # for live ACP merchant ops
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# Catalogue of demo ACP-compatible merchants — Pro tier swaps in live
|
|
67
|
+
# Stripe Connect merchant discovery via the ACP merchant directory.
|
|
68
|
+
_DEMO_MERCHANTS = [
|
|
69
|
+
{"id": "merch_demo_software", "name": "Generic SaaS Co", "category": "software",
|
|
70
|
+
"supports": ["stripe-acp", "ap2", "x402"]},
|
|
71
|
+
{"id": "merch_demo_grocery", "name": "ACP Demo Grocer", "category": "groceries",
|
|
72
|
+
"supports": ["stripe-acp"]},
|
|
73
|
+
{"id": "merch_demo_compliance", "name": "MEOK AI Labs", "category": "compliance",
|
|
74
|
+
"supports": ["stripe-acp", "ap2", "x402", "psd2-overlay", "mica-overlay"]},
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _sign(payload: dict) -> str:
|
|
79
|
+
if not _HMAC_SECRET:
|
|
80
|
+
return "unsigned-no-key-configured"
|
|
81
|
+
body = json.dumps(payload, sort_keys=True).encode()
|
|
82
|
+
return hmac.new(_HMAC_SECRET.encode(), body, hashlib.sha256).hexdigest()
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _ts() -> str:
|
|
86
|
+
return datetime.now(timezone.utc).isoformat()
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# ────────────────────────────────────────────────────────────────────────
|
|
90
|
+
# Tools
|
|
91
|
+
# ────────────────────────────────────────────────────────────────────────
|
|
92
|
+
|
|
93
|
+
@mcp.tool()
|
|
94
|
+
def discover_acp_merchants(category: Optional[str] = None) -> dict:
|
|
95
|
+
"""
|
|
96
|
+
List Stripe-ACP-compatible merchants, optionally filtered by category.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
category: Optional filter — "software", "groceries", "compliance", etc.
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
{merchants: [{id, name, category, supports_protocols}]}
|
|
103
|
+
"""
|
|
104
|
+
merchants = _DEMO_MERCHANTS
|
|
105
|
+
if category:
|
|
106
|
+
merchants = [m for m in merchants if m["category"].lower() == category.lower()]
|
|
107
|
+
return {
|
|
108
|
+
"merchants": merchants,
|
|
109
|
+
"stage": "free-tier-demo" if not _STRIPE_API_KEY else "live-via-stripe",
|
|
110
|
+
"hint": "Pro tier ($79/mo) queries the live Stripe Connect ACP merchant directory.",
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@mcp.tool()
|
|
115
|
+
def prepare_payment_intent(
|
|
116
|
+
merchant_id: str,
|
|
117
|
+
items: list[dict],
|
|
118
|
+
currency: str = "GBP",
|
|
119
|
+
buyer_did: Optional[str] = None,
|
|
120
|
+
) -> dict:
|
|
121
|
+
"""
|
|
122
|
+
Build a Stripe ACP payment intent payload ready for merchant submission.
|
|
123
|
+
|
|
124
|
+
Args:
|
|
125
|
+
merchant_id: ACP merchant identifier (from discover_acp_merchants).
|
|
126
|
+
items: List of {sku, name, quantity, unit_amount_minor} dicts.
|
|
127
|
+
currency: ISO 4217 code, default GBP.
|
|
128
|
+
buyer_did: Optional W3C DID identifying the buying agent (for trust chain).
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
Payment intent payload conforming to Stripe ACP spec.
|
|
132
|
+
"""
|
|
133
|
+
subtotal_minor = sum(i.get("unit_amount_minor", 0) * i.get("quantity", 1) for i in items)
|
|
134
|
+
intent = {
|
|
135
|
+
"type": "stripe_acp_payment_intent",
|
|
136
|
+
"protocol_version": "1.0.0",
|
|
137
|
+
"merchant_id": merchant_id,
|
|
138
|
+
"items": items,
|
|
139
|
+
"currency": currency.upper(),
|
|
140
|
+
"amount_minor": subtotal_minor,
|
|
141
|
+
"amount_display": f"{subtotal_minor / 100:.2f} {currency.upper()}",
|
|
142
|
+
"buyer_did": buyer_did,
|
|
143
|
+
"ts": _ts(),
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
"intent": intent,
|
|
147
|
+
"next_step": "Call sign_payment_intent() to chain into audit log + get HMAC signature.",
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
@mcp.tool()
|
|
152
|
+
def sign_payment_intent(intent: dict) -> dict:
|
|
153
|
+
"""
|
|
154
|
+
HMAC-sign a payment intent and prepare it for submission to the merchant.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
intent: Payment intent payload from prepare_payment_intent().
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
{intent, signature, verify_url, audit_chain_entry}
|
|
161
|
+
"""
|
|
162
|
+
sig = _sign(intent)
|
|
163
|
+
chain_entry = {
|
|
164
|
+
"type": "stripe_acp_intent_signed",
|
|
165
|
+
"intent_id": f"acp_intent_{int(time.time())}",
|
|
166
|
+
"amount_minor": intent.get("amount_minor"),
|
|
167
|
+
"merchant_id": intent.get("merchant_id"),
|
|
168
|
+
"buyer_did": intent.get("buyer_did"),
|
|
169
|
+
"signature": sig,
|
|
170
|
+
"ts": _ts(),
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
"intent": intent,
|
|
174
|
+
"signature": sig,
|
|
175
|
+
"verify_url": "https://verify.meok.ai",
|
|
176
|
+
"audit_chain_entry": chain_entry,
|
|
177
|
+
"next_step": "Submit intent + signature to merchant's ACP endpoint. Call verify_acp_response() with their reply.",
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
@mcp.tool()
|
|
182
|
+
def verify_acp_response(response: dict, expected_intent_id: Optional[str] = None) -> dict:
|
|
183
|
+
"""
|
|
184
|
+
Verify the merchant's ACP completion response (signature, status, intent match).
|
|
185
|
+
|
|
186
|
+
Args:
|
|
187
|
+
response: Merchant ACP response (status, signature, payment_id, etc.).
|
|
188
|
+
expected_intent_id: Optional intent ID from sign_payment_intent for cross-check.
|
|
189
|
+
|
|
190
|
+
Returns:
|
|
191
|
+
{verified, status, issues, audit_chain_entry}
|
|
192
|
+
"""
|
|
193
|
+
issues = []
|
|
194
|
+
status = response.get("status", "unknown")
|
|
195
|
+
if status not in ("succeeded", "requires_action", "pending", "failed"):
|
|
196
|
+
issues.append(f"unexpected_status: {status}")
|
|
197
|
+
if expected_intent_id and response.get("intent_id") != expected_intent_id:
|
|
198
|
+
issues.append("intent_id_mismatch")
|
|
199
|
+
sig = response.get("signature", "")
|
|
200
|
+
if not sig:
|
|
201
|
+
issues.append("no_merchant_signature")
|
|
202
|
+
verified = len(issues) == 0
|
|
203
|
+
chain_entry = {
|
|
204
|
+
"type": "stripe_acp_response_verified" if verified else "stripe_acp_response_flagged",
|
|
205
|
+
"response_status": status,
|
|
206
|
+
"verified": verified,
|
|
207
|
+
"issues": issues,
|
|
208
|
+
"ts": _ts(),
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
"verified": verified,
|
|
212
|
+
"status": status,
|
|
213
|
+
"issues": issues,
|
|
214
|
+
"audit_chain_entry": chain_entry,
|
|
215
|
+
"signature": _sign(chain_entry),
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
@mcp.tool()
|
|
220
|
+
def bridge_to_ap2_mandate(intent: dict, user_consent_jwt: Optional[str] = None) -> dict:
|
|
221
|
+
"""
|
|
222
|
+
Convert a Stripe ACP intent into a Google AP2 Mandate envelope so the
|
|
223
|
+
same purchase can be settled through the Google + Mastercard + PayPal +
|
|
224
|
+
Adyen AP2 coalition rails.
|
|
225
|
+
|
|
226
|
+
Args:
|
|
227
|
+
intent: Stripe ACP intent from prepare_payment_intent().
|
|
228
|
+
user_consent_jwt: Optional pre-signed user consent JWT (verifiable credential).
|
|
229
|
+
|
|
230
|
+
Returns:
|
|
231
|
+
AP2-compliant mandate envelope.
|
|
232
|
+
"""
|
|
233
|
+
mandate = {
|
|
234
|
+
"type": "ap2_mandate",
|
|
235
|
+
"protocol_version": "1.0.0",
|
|
236
|
+
"intent_id": f"ap2_mandate_{int(time.time())}",
|
|
237
|
+
"original_protocol": "stripe-acp",
|
|
238
|
+
"original_intent": intent,
|
|
239
|
+
"merchant_id": intent.get("merchant_id"),
|
|
240
|
+
"amount_minor": intent.get("amount_minor"),
|
|
241
|
+
"currency": intent.get("currency"),
|
|
242
|
+
"user_consent_jwt": user_consent_jwt,
|
|
243
|
+
"ts": _ts(),
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
"mandate": mandate,
|
|
247
|
+
"signature": _sign(mandate),
|
|
248
|
+
"verify_url": "https://verify.meok.ai",
|
|
249
|
+
"settlement_options": ["mastercard", "paypal", "adyen", "amex", "coinbase", "stripe"],
|
|
250
|
+
"hint": "AP2 mandates are cross-platform — any AP2-compatible processor can settle.",
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
@mcp.tool()
|
|
255
|
+
def bridge_to_x402_paywall(intent: dict) -> dict:
|
|
256
|
+
"""
|
|
257
|
+
Convert a Stripe ACP intent into a Coinbase x402 HTTP-402 payment-required
|
|
258
|
+
response, for pay-per-call agent settlement without a Stripe account.
|
|
259
|
+
|
|
260
|
+
Args:
|
|
261
|
+
intent: Stripe ACP intent from prepare_payment_intent().
|
|
262
|
+
|
|
263
|
+
Returns:
|
|
264
|
+
HTTP-402 response shape with settlement instructions.
|
|
265
|
+
"""
|
|
266
|
+
amount_minor = intent.get("amount_minor", 0)
|
|
267
|
+
return {
|
|
268
|
+
"http_status": 402,
|
|
269
|
+
"headers": {
|
|
270
|
+
"x-402-payment-required": "true",
|
|
271
|
+
"x-402-amount": str(amount_minor),
|
|
272
|
+
"x-402-currency": intent.get("currency", "USDC"),
|
|
273
|
+
"x-402-settle-to": "0xMEOK0000000000000000000000000000000000", # placeholder
|
|
274
|
+
"x-402-chain": "base",
|
|
275
|
+
"x-402-merchant-id": intent.get("merchant_id"),
|
|
276
|
+
},
|
|
277
|
+
"body": {
|
|
278
|
+
"settle_via": ["base", "polygon", "solana", "lightning"],
|
|
279
|
+
"min_confirmations": 1,
|
|
280
|
+
"expires_at": int(time.time()) + 600,
|
|
281
|
+
"original_acp_intent": intent,
|
|
282
|
+
"signature": _sign(intent),
|
|
283
|
+
},
|
|
284
|
+
"hint": "After settlement on-chain, retry the original call — gateway re-checks the chain + serves the response.",
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
@mcp.tool()
|
|
289
|
+
def list_supported_protocols() -> dict:
|
|
290
|
+
"""List the agent-payment protocols this MCP can bridge."""
|
|
291
|
+
return {
|
|
292
|
+
"primary": "Stripe ACP (Agentic Commerce Protocol)",
|
|
293
|
+
"bridged": [
|
|
294
|
+
{"name": "Google AP2", "url": "https://ap2-protocol.org", "use_via": "bridge_to_ap2_mandate"},
|
|
295
|
+
{"name": "Coinbase x402", "url": "https://x402.org", "use_via": "bridge_to_x402_paywall"},
|
|
296
|
+
],
|
|
297
|
+
"compliance_overlays": ["PSD2 (EU)", "MiCA (EU crypto)", "6AMLD (EU AML)", "FinCEN BSA (US)"],
|
|
298
|
+
"note": "Other ACP — the IBM Agent Communication Protocol — merged into A2A in Sept 2025 and is covered by the MEOK A2A Substrate (https://meok.ai/a2a).",
|
|
299
|
+
"hint": "All bridges produce signed audit-chain entries verifiable at https://verify.meok.ai",
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
if __name__ == "__main__":
|
|
304
|
+
mcp.run()
|