global-alipayplus-mcp
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"alipayplus-mcp": {
"args": [
"ant-intl-alipayplus-mcp"
],
"command": "uvx",
"env": {
"ALIPAY_PUBLIC_KEY": "your_alipay_public_key_here",
"CLIENT_ID": "your_client_id_here",
"GATEWAY_URL": "https://open-sea-global.alipay.com",
"MERCHANT_ID": "Your Merchant ID",
"MERCHANT_MCC": "5411",
"MERCHANT_NAME": "Your Merchant Name",
"MERCHANT_PRIVATE_KEY": "your_merchant_private_key_here",
"MERCHANT_REGION": "US",
"PAYMENT_NOTIFY_URL": "https://your-domain.com/payment/notify",
"SETTLEMENT_CURRENCY": "USD"
}
}
}
}
该服务需要配置环境变量:ALIPAY_PUBLIC_KEY、CLIENT_ID、GATEWAY_URL、MERCHANT_ID、MERCHANT_MCC、MERCHANT_NAME、MERCHANT_PRIVATE_KEY、MERCHANT_REGION、PAYMENT_NOTIFY_URL、PAYMENT_REDIRECT_URL、SETTLEMENT_CURRENCY
可用工具 (6 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
create_payment 4 个参数 需填 4 项
The tool is used by the Acquiring Service Provider (ACQP) to send a request to Alipay+ to place orders. Args: payment_request_id: TThe unique ID assigned by a merchant to identify a payment request. Maximum length: 64 characters order_amount_currency: The transaction currency that is specified in the contract. A 3-letter currency code that follows the ISO 4217 standard.Maximum length: 3 characters order_amount_value: The amount to charge as a positive integer in the smallest currency unit. (That is, 100 cents to charge $1.00, or 100 to charge JPY 100, a 0-decimal currency).Value range: 1 - unlimited order_description: Summary description of the order, which is used for user consumption records display or other further actions.Maximum length: 256 characters
必填参数:payment_request_id、order_amount_currency、order_amount_value、order_description
query_payment 1 个参数 需填 1 项
The tool is used by the Acquiring Service Provider (ACQP) to query the payment result if no payment result is received after a certain period of time. Args: payment_request_id: The unique ID that is assigned by a merchant to identify a payment request.Maximum length: 64 characters
必填参数:payment_request_id
cancel_payment 1 个参数 需填 1 项
The tool is used by the Acquiring Service Provider (ACQP) to proactively cancel a payment when no payment result is received after the payment expires, or when the ACQP closes the payment before receiving the payment result. Args: payment_request_id: The request ID of the payment to be canceled, assigned by the ACQP to identify the original payment order.Maximum length: 64 characters
必填参数:payment_request_id
create_refund 4 个参数 需填 4 项
The tool is used by the Acquiring Service Provider (ACQP) to initiate a refund of a successful payment.The refund can be full or partial. A transaction can have multiple refunds as long as the total refund amount is less than or equal to the original transaction amount. Args: payment_request_id: The request ID of the payment to be refunded, assigned by the ACQP to identify the original payment order.Maximum length: 64 characters refund_request_id: The unique ID that is assigned by the ACQP to identify a refund request. Maximum length: 64 characters. refund_amount_value: The amount to charge as a positive integer in the smallest currency unit. (That is, 100 cents to charge $1.00, or 100 to charge JPY 100, a 0-decimal currency).Value range: 1 - unlimited refund_currency: The currency code of the amount. The value of this parameter must be an alphabetic code that follows the ISO 4217 standard, for example, "EUR" for Euros.
必填参数:payment_request_id、refund_request_id、refund_amount_value、refund_currency
customs_declare 8 个参数 需填 8 项
The tool is used by the Acquiring Service Provider (ACQP) to declare a payment to customs or update an existing declaration. Args: payment_request_id: The unique ID that is assigned by the ACQP to identify a payment request for the order.Maximum length: 64 characters customs_declaration_request_id: The unique ID that is assigned by the merchant to identify a customs declaration request. This parameter is not provided for the customs. Maximum length: 64 characters declaration_amount_value: The customs declaration amount as a natural number.Value range: 1 - unlimited customs_code: The customs code (in either uppercase or lowercase). Maximum length: 128 characters merchant_customs_code: The merchant code that is registered in the customs system. Maximum length: 128 characters merchant_customs_name: The merchant name that is registered in the customs system. Maximum length: 256 characters is_split: This parameter indicates whether the payment order needs to be split for declaration. Valid values are: true: indicates that order splitting is needed. false: indicates that order splitting is not needed. reference_order_id: The unique ID that is assigned by the merchant to identify an order that needs to be declared to the customs. Maximum length: 64 characters
必填参数:payment_request_id、customs_declaration_request_id、declaration_amount_value、customs_code、merchant_customs_code、merchant_customs_name、is_split、reference_order_id
query_customs_declare 1 个参数 需填 1 项
The tool is used by the Acquiring Service Provider (ACQP) to inquire about the status of declared payments. Args: declaration_request_ids: The unique declaration request IDs that are assigned by the merchant to identify declaration requests. Up to 10 declaration request IDs are supported at a time. Maximum length: 64 characters. Maximum size: 10 elements
必填参数:declaration_request_ids
服务介绍
AlipayPlus MCP 服务器
一个与模型上下文协议(MCP)兼容的服务器,集成了蚂蚁国际的AlipayPlus支付API,使AI助手能够无缝处理支付和退款操作。
概述
AlipayPlus MCP 服务器将蚂蚁国际的AlipayPlus支付API封装成标准化的MCP工具,允许AI助手在对话过程中安全地处理与支付相关的操作。通过该服务器,您可以直接通过AI交互创建支付、查询交易状态、处理退款等。
功能
💳 支付操作
- 创建支付 (
create_payment):生成用于处理交易的支付请求 - 查询支付 (
query_payment):检索已提交支付请求的交易状态和信息 - 取消支付 (
cancel_payment):当结果未在预期时间内返回时取消支付
💰 退款操作
- 创建退款 (
create_refund):针对成功的支付发起全额或部分退款
🛃 海关操作
- 海关申报 (
customs_declare):向海关申报支付或更新现有申报 - 查询海关申报 (
query_customs_declare):查询已申报支付的状态
前提条件
在使用AlipayPlus MCP服务器之前,请确保您具备以下条件:
- Python 3.11 或更高版本
- uv(推荐的包管理器)或 pip
- 有效的AlipayPlus商户账户,包括:
- 商户客户端ID (CLIENT_ID)
- 商户RSA私钥 (MERCHANT_PRIVATE_KEY)
- Alipay RSA公钥 (ALIPAY_PUBLIC_KEY)
- 支付通知回调URL (PAYMENT_NOTIFY_URL)
快速开始
1. 安装
使用uvx直接使用(推荐)
bash
uvx ant-intl-alipayplus-mcp
使用pip安装
bash
pip install ant-intl-alipayplus-mcp
使用uv安装
bash
uv install ant-intl-alipayplus-mcp
从源代码安装
bash
git clone https://github.com/alipay/global-alipayplus-mcp.git
cd global-alipayplus-mcp
uv install
依赖项
- Python 3.11 或更高版本
- 依赖库:
- cryptography==44.0.3
- mcp[cli]>=1.9.1
- pycryptodome==3.22.0
- rsa>=4.9.1
2. MCP 客户端配置
将以下配置添加到您的MCP客户端中:
json
{
"mcpServers": {
"alipayplus-mcp": {
"command": "uvx",
"args": ["ant-intl-alipayplus-mcp"],
"env": {
"GATEWAY_URL": "https://open-sea-global.alipay.com",
"CLIENT_ID": "your_client_id_here",
"MERCHANT_PRIVATE_KEY": "your_merchant_private_key_here",
"ALIPAY_PUBLIC_KEY": "your_alipay_public_key_here",
"PAYMENT_NOTIFY_URL": "https://your-domain.com/payment/notify",
"SETTLEMENT_CURRENCY": "USD",
"MERCHANT_NAME": "Your Merchant Name",
"MERCHANT_ID": "Your Merchant ID",
"MERCHANT_MCC": "5411",
"MERCHANT_REGION": "US"
}
}
}
}
3. 环境变量
| 变量 | 是否必需 | 描述 |
|---|---|---|
GATEWAY_URL |
❌ | AlipayPlus API网关URL(默认为 https://open-sea-global.alipay.com) |
CLIENT_ID |
✅ | 用于身份验证的商户客户端ID |
MERCHANT_PRIVATE_KEY |
✅ | 用于请求签名的商户RSA私钥 |
ALIPAY_PUBLIC_KEY |
✅ | 用于响应验证的Alipay RSA公钥 |
PAYMENT_REDIRECT_URL |
❌ | 支付后的重定向URL(默认为空字符串) |
PAYMENT_NOTIFY_URL |
❌ | 支付结果通知回调URL(默认为 http://localhost:8080/notify) |
SETTLEMENT_CURRENCY |
❌ | 结算货币(默认为空字符串) |
MERCHANT_NAME |
❌ | 商户名称(默认为 "Alipayplus MCP") |
MERCHANT_ID |
❌ | 商户ID(默认为 "M0000000001") |
MERCHANT_MCC |
❌ | 商户类别代码(默认为 "5411") |
集成示例
以下是如何将AlipayPlus MCP服务器与您的AI代理集成的示例(以QwenAgent为例):
python
import os
from qwen_agent.agents import Assistant
将MCP服务器配置为工具
tools = [{
"mcpServers": {
"alipayplus-mcp": {
"command": "uvx",
"args": ["ant-intl-alipayplus-mcp"],
"env": {
"CLIENT_ID": os.getenv('CLIENT_ID'),
"MERCHANT_PRIVATE_KEY": os.getenv('MERCHANT_PRIVATE_KEY'),
"ALIPAY_PUBLIC_KEY": os.getenv('ALIPAY_PUBLIC_KEY'),
"GATEWAY_URL": "https://open-sea-global.alipay.com",
"PAYMENT_NOTIFY_URL": "https://your-domain.com/notify"
}
}
}
}]
创建具有支付功能的AI助手
bot = Assistant(
llm={'model': 'qwen-max', 'api_key': 'your-api-key'},
function_list=tools,
)
更新日志
有关详细的变更历史,请参阅CHANGELOG.md。
许可证
本项目采用MIT许可证。
致谢
- Model Context Protocol 提供的标准
- AlipayPlus Integration 提供的AlipayPlus支付平台