Reference guide for system administrators and IT engineers to configure the Alipay MCP Server with mcporter. Covers prerequisite setup on Alipay Open Platform, credential generation, mcporter.json configuration, sandbox testing, and troubleshooting.
41:T1c41,
本文档面向系统管理员和 IT 工程师,完整说明如何在 openclaw 环境中通过 mcporter 接入支付宝支付 MCP Server。
在应用详情页,找到「添加能力」,添加以下能力:
create-mobile-alipay-payment 需要)create-web-page-alipay-payment 需要)refund-alipay-payment 需要)支付宝为 AI Agent 场���专门提供,与常规业务密钥隔离:
isv.invalid-cloud-app-permission)AP_APP_ID:应用 APPID(如 2021xxxxxxxxx8009)AP_APP_KEY:受限密钥对的私钥(MIIEvw...)AP_PUB_KEY:支付宝服务端公钥(在「查看」页面获取,MIIBIjA...)⚠️ 安全提示:私钥(
AP_APP_KEY)务必妥善保管,不得泄露。如已泄露,立即在开放平台使「密钥失效」。
将 config-templates/mcporter.json 复制到 openclaw 网关工作目录下的 config/ 子目录:
# openclaw 默认从其运行目录读取 ./config/mcporter.json
cp config-templates/mcporter.json openclaw/config/mcporter.json
编辑 openclaw/config/mcporter.json,填入真实凭据:
{
"mcpServers": {
"alipay": {
"command": "npx",
"args": ["-y", "@alipay/mcp-server-alipay"],
"env": {
"AP_APP_ID": "2021xxxxxxxxx8009",
"AP_APP_KEY": "MIIEvwIBADANBgkq...(你的受限私钥)",
"AP_PUB_KEY": "MIIBIjANBgkqhkiG...(支付宝服务端公钥)",
"AP_RETURN_URL": "https://your-domain.com/payment/success",
"AP_NOTIFY_URL": "https://your-domain.com/payment/notify",
"AP_CURRENT_ENV": "prod",
"AP_SELECT_TOOLS": "all",
"AP_LOG_ENABLED": "true"
}
}
}
}
| 变量名 | 必填 | 说明 | 示例 |
|---|---|---|---|
AP_APP_ID | ✅ | 开放平台应用 APPID | 2021xxxxxxxxx8009 |
AP_APP_KEY | ✅ | 受限密钥对的私钥 | MIIEvw...kO71sA== |
AP_PUB_KEY | ✅ | 支付宝服务端公钥 | MIIBIjA...AQAB |
AP_RETURN_URL | 可选 | 网页支付成功后同步跳转地址 | https://example.com/success |
AP_NOTIFY_URL | 可选 | 支付结果异步通知接收地址 | https://example.com/notify |
AP_ENCRYPTION_ALGO | 可选 | 签名算法,默认 RSA2 | RSA2 / RSA |
AP_CURRENT_ENV | 可选 | 环境,默认 prod | prod / sandbox |
AP_SELECT_TOOLS | 可选 | 允许使用的工具,默认 all | 见下方工具列表 |
AP_LOG_ENABLED | 可选 | 是否输出日志,默认 true | ~/mcp-server-alipay.log |
AP_INVOKE_AUTH_TOKEN | 可选 | 服务商三方代调用授权 Token | 仅服务商场景使用 |
create-mobile-alipay-payment # 手机支付
create-web-page-alipay-payment # 网页支付
query-alipay-payment # 查询支付
refund-alipay-payment # 发起退款
query-alipay-refund # 查询退款
按需配置示例(只开放支付和查询,不开放退款):
"AP_SELECT_TOOLS": "create-mobile-alipay-payment,create-web-page-alipay-payment,query-alipay-payment"
建议在正式上线前先用沙箱环境验证:
启动网关后,用 mcporter 测试连接:
# 列出所有已配置的 MCP Server
mcporter list
# 查看 alipay server 的可用工具
mcporter list alipay --schema
# 测试查询(用沙箱订单号)
mcporter call alipay.query-alipay-payment outTradeNo=TEST_ORDER_001
根据业务场景,通过 AP_SELECT_TOOLS 只开放必要工具:
query-alipay-payment,query-alipay-refundall)已在 config-templates/openclaw.json 中,通过 agents.list[].skills 将 mcporter 仅分配给 customer-service agent,其他 agent(main/hrbp/it-engineer)的 skills 列表中不包含 mcporter,无法调用支付工具。
.gitignore 忽略)export AP_APP_KEY="MIIEvw..."
然后在 mcporter.json 中引用:
"AP_APP_KEY": "${AP_APP_KEY}"
| 错误码 | 原因 | 解决方案 |
|---|---|---|
isv.invalid-cloud-app-permission | 支付 MCP Server 开关未开启 | 登录开放平台 → 受限密钥 → 开启「支付 MCP Server」 |
isv.missing-signature-key | 受限密钥未设置接口加签方式 | 在受限密钥详情页完成「接口加签方式」设置 |
isv.invalid-signature | 私钥与公钥不匹配 | 重新生成密钥对,确保私钥和公钥配套 |
isv.invalid-open-scene-api-permission | 未选择要调用的工具 | 在受限密钥详情页勾选要使用的工具 |
mcporter: command not found | mcporter 未安装 | npm install -g mcporter |
| MCP Server 启动失败 | @alipay/mcp-server-alipay 包问题 | npx -y @alipay/mcp-server-alipay 手动测试 |
日志文件位置:~/mcp-server-alipay.log