使用说明
Go Stripe MCP服务器
Go中实现的MCP服务器,包裹Stripe API以模拟人工智能代理的支付场景。
先决条件
- 转到1.22+
- 条纹密钥(测试模式)
安装
-
初始化依赖关系:
go mod tidy -
构建服务器:
go build -o stripe-mcp
用法
环境变量
export STRIPE_SECRET_KEY=sk_test_...
运行服务器
./stripe-mcp
工具
| 工具 | 说明 |
|---|---|
create_payment |
创建Stripe PaymentIntent(仅限卡)。返回PI ID和客户端密码。 |
mock_confirm_payment |
使用测试PaymentMethod ID确认PaymentIntent以模拟结果。 |
get_payment |
检索PaymentIntent的当前状态和详细信息。 |
cancel_payment |
取消付款意向。 |
create_refund |
对成功的PaymentIntent发出全额或部分退款。 |
测试付款方法ID mock_confirm_payment
备注:这些是Stripe PaymentMethod测试ID(
pm_card_*),而不是传统源令牌(tok_*).
test_token value |
模拟结果 |
|---|---|
pm_card_visa |
成功 |
pm_card_chargeDeclined |
普遍下降 |
pm_card_visa_chargeDeclinedInsufficientFunds |
资金不足 |
pm_card_cvcCheckFail |
CVC检查失败 |
示例流程
-
创建付款:
create_payment(amount="20.00", currency="usd", description="Test order") → PaymentIntent ID: pi_xxx -
模拟确认:
mock_confirm_payment(payment_intent_id="pi_xxx", test_token="pm_card_visa") → Payment Confirmed Successfully. Status: succeeded -
检查状态:
get_payment(payment_intent_id="pi_xxx") → Status: succeeded -
退款:
create_refund(payment_intent_id="pi_xxx", amount="10.00") → Refund Created. Status: succeeded