mcp-server-alipay
Integrate Alipay payments into your AI applications with mcp-server-alipay
, an official MCP Server. Easily enable LLMs and Agents to create, query, and refund payments, automating financial workflows.

mcp-server-alipay Solution Overview
Unlock powerful payment capabilities for your AI applications with @alipay/mcp-server-alipay
, an official MCP Server from the Alipay Open Platform. This solution acts as a secure bridge, allowing AI models and agents to seamlessly interact with Alipay's core payment services. Developers can easily integrate functionalities like creating mobile or web-based payment links, querying transaction statuses, and processing refunds directly within their AI-driven tools. By abstracting the complexities of direct API integration, it significantly simplifies adding real-world payment processing to intelligent agents, automating workflows like order creation and payment confirmation. Integrate it into your preferred MCP Client (like Cursor or Cline) via simple configuration using environment variables, enabling your AI to manage Alipay transactions efficiently and securely.
mcp-server-alipay Key Capabilities
Mobile Payment Creation
This core function, exposed as the create-mobile-alipay-payment
MCP Tool, empowers AI models to initiate Alipay transactions specifically designed for mobile environments. When invoked by an MCP Client (like an AI Agent), the mcp-server-alipay
interacts with the Alipay Open Platform API using the configured merchant credentials (AP_APP_ID
, AP_APP_KEY
, etc.). It takes essential order details – a unique merchant order ID (outTradeNo
), the payment amount (totalAmount
), and an order title (orderTitle
) – as input parameters. Upon successful processing by Alipay, the server returns a Markdown-formatted payment link (url
). This link is optimized for mobile browsers or native apps; clicking it typically redirects the user directly to the Alipay app or presents an in-browser Alipay payment interface, streamlining the payment process on mobile devices. This capability allows developers to build AI-driven applications (e.g., chatbots, automated service platforms) that can seamlessly request payments from users within a mobile context, automating sales or service fulfillment workflows. For instance, an AI travel assistant could generate a mobile payment link for booking a flight after confirming details with the user.
Web Page Payment Creation
The create-web-page-alipay-payment
MCP Tool provides the capability for AI models to generate Alipay payment requests suitable for desktop or web browser environments. Similar to mobile payment creation, this function requires the MCP Client to provide a unique merchant order ID (outTradeNo
), payment amount (totalAmount
), and order title (orderTitle
). The mcp-server-alipay
then communicates with the Alipay Open Platform to create the transaction. The key difference lies in the output: it returns a Markdown-formatted link (url
) that, when opened in a desktop browser, displays a QR code. Users can then scan this QR code using their Alipay mobile app to complete the payment. This feature is crucial for AI applications operating primarily on desktop platforms or websites, enabling scenarios like AI-powered e-commerce stores where users browse on a PC and pay via QR code scan. For example, an AI design tool could generate a web payment link for a premium feature subscription, presenting a QR code on the user's computer screen. This standardizes payment initiation for AI across different user interfaces via the MCP framework.
Payment Status Query
Exposed as the query-alipay-payment
MCP Tool, this function enables AI models to programmatically check the status of a previously created Alipay transaction. The MCP Client needs to provide the original merchant order ID (outTradeNo
) used during payment creation. The mcp-server-alipay
uses this ID to query the Alipay Open Platform API for the transaction's current state. The server then returns key information, including the payment status (tradeStatus
, e.g., "TRADE_SUCCESS", "WAIT_BUYER_PAY"), the transaction amount (totalAmount
), and the unique Alipay transaction number (tradeNo
). This capability is vital for building robust, automated workflows within AI applications. It allows the AI to confirm payment completion before proceeding with service delivery, order fulfillment, or providing access to paid content. For instance, an AI agent managing online course enrollments could use this tool to verify a student's payment status after they claim to have paid, automatically granting access only upon successful confirmation, eliminating manual checks and potential delays.
Payment Refund Initiation
The refund-alipay-payment
MCP Tool allows AI models to initiate refunds for completed Alipay transactions. To perform a refund, the MCP Client must supply the original merchant order ID (outTradeNo
), the amount to be refunded (refundAmount
), and a unique refund request ID (outRequestNo
) to prevent duplicate refund attempts. An optional refund reason (refundReason
) can also be included. The mcp-server-alipay
securely communicates this request to the Alipay Open Platform using the merchant's credentials. Upon processing, the server returns the Alipay transaction number (tradeNo
) and the refund result (refundResult
), indicating whether the refund request was successfully submitted. This empowers AI agents to handle customer service scenarios involving refunds automatically. For example, an AI-powered customer support bot could process a refund request for a returned item after verifying the return conditions, triggering the refund via this tool without human intervention, improving efficiency and customer satisfaction.
Refund Status Query
Complementing the refund initiation tool, the query-alipay-refund
MCP Tool enables AI models to check the status of a previously requested refund. The MCP Client needs to provide both the unique refund request ID (outRequestNo
) and the original merchant order ID (outTradeNo
) associated with the transaction being refunded. The mcp-server-alipay
uses these identifiers to query the Alipay Open Platform for the specific refund's progress. The server returns details such as the Alipay transaction number (tradeNo
), the refunded amount (refundAmount
), and the current refund status (refundStatus
, e.g., "REFUND_SUCCESS"). This allows AI applications to track the refund process and provide accurate updates to users or internal systems. For instance, an e-commerce AI assistant could use this tool to monitor a refund initiated earlier and notify the customer once the refund has been successfully processed by Alipay, providing transparency and closing the loop on the customer service interaction.