ECPay Logistics
MCP Server for ECPay logistics integration API — 3 tools for creating, querying, and cancelling logistics orders for convenience store pickup services.
- Tools
- 3
- Maintainer
- asgard-ai-platform
- License
- MIT
- Region
- taiwan
Introduction
An MCP server for ECPay logistics legacy APIs, exposing signed create/query/cancel flows over Model Context Protocol (MCP).
Features
- Three MCP tools — create, query, and cancel ECPay logistics orders
- stdio JSON-RPC 2.0 — standard MCP transport protocol
@mcp.tool()decorator — typed tool registration with structured dict output- Legacy Form + MD5 signing — wraps ECPay's
CheckMacValueflow for old logistics endpoints - Stage / production switch — controlled by
ECPAY_ENV - Live smoke test support — probe the real API and exercise the tools against valid credentials
Available Tools
| Tool | Description |
|---|---|
create_logistics_order |
Create an ECPay logistics order with signed legacy payload. Expects a payload object containing business fields such as MerchantTradeNo, MerchantTradeDate, LogisticsType, LogisticsSubType, GoodsAmount, SenderName, ReceiverName, and ServerReplyURL. |
query_logistics_order |
Query an ECPay logistics order by merchant_trade_no or allpay_logistics_id, plus a required timestamp. Returns structured status fields such as logistics_status, shipment_no, and raw parsed data. |
cancel_logistics_order |
Cancel a C2C logistics order by allpay_logistics_id, cvs_payment_no, and cvs_validation_no. Returns {ok, result, allpay_logistics_id}. |
Requirements
- Python
3.10+ - One of:
uv(recommended) orpip - ECPay logistics credentials (
ECPAY_MERCHANT_ID,ECPAY_HASH_KEY,ECPAY_HASH_IV)
Install
Option 1 — uvx (no install, runs on demand)
uvx mcp-ecpay-logistics
Option 2 — pip / uv pip
pip install mcp-ecpay-logistics
# or
uv pip install mcp-ecpay-logistics
After install, the mcp-ecpay-logistics console script is available.
Option 3 — From source
git clone https://github.com/asgard-ai-platform/mcp-ecpay-logistics.git
cd mcp-ecpay-logistics
uv sync
cp .env.example .env
uv run --env-file .env mcp-ecpay-logistics
Usage
The server speaks MCP over stdio. Add it to your client of choice:
Claude Desktop
~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"ecpay-logistics": {
"command": "uvx",
"args": ["mcp-ecpay-logistics"],
"env": {
"ECPAY_ENV": "stage",
"ECPAY_MERCHANT_ID": "your_merchant_id",
"ECPAY_HASH_KEY": "your_hash_key",
"ECPAY_HASH_IV": "your_hash_iv"
}
}
}
}
Claude Code
Add to your project's .mcp.json:
{
"mcpServers": {
"ecpay-logistics": {
"command": "python",
"args": ["mcp_server.py"],
"cwd": "${PWD}",
"env": {
"PYTHONPATH": "${PWD}",
"ECPAY_ENV": "stage",
"ECPAY_MERCHANT_ID": "your_merchant_id",
"ECPAY_HASH_KEY": "your_hash_key",
"ECPAY_HASH_IV": "your_hash_iv"
}
}
}
}
Cursor
~/.cursor/mcp.json:
{
"mcpServers": {
"ecpay-logistics": {
"command": "uvx",
"args": ["mcp-ecpay-logistics"],
"env": {
"ECPAY_ENV": "stage",
"ECPAY_MERCHANT_ID": "your_merchant_id",
"ECPAY_HASH_KEY": "your_hash_key",
"ECPAY_HASH_IV": "your_hash_iv"
}
}
}
}
Environment Variables
| Variable | Effect |
|---|---|
ECPAY_ENV |
stage or prod. Controls the legacy logistics base URL. |
ECPAY_MERCHANT_ID |
Merchant ID used in every signed logistics request. |
ECPAY_HASH_KEY |
HashKey used when generating CheckMacValue. |
ECPAY_HASH_IV |
HashIV used when generating CheckMacValue. |
MCP servers are launched by the MCP client, not by your shell — exporting a variable in ~/.zshrc or ~/.bashrc will not reach the server. Put variables in the client config's env block and restart the client after editing.
Example Tool Usage
You: Create a CVS logistics order in staging.
AI call: ecpay-logistics - create_logistics_order (MCP)(payload: {"MerchantTradeNo": "LOG202605040001", "MerchantTradeDate": "2026/05/04 12:00:00", "LogisticsType": "CVS", "LogisticsSubType": "UNIMARTC2C", "GoodsAmount": 100, "GoodsName": "Demo Item", "SenderName": "Alice", "SenderCellPhone": "0912345678", "ReceiverName": "Bob", "ReceiverCellPhone": "0987654321", "ReceiverStoreID": "131386", "ServerReplyURL": "https://example.com/ecpay/callback"})
{
"ok": true,
"endpoint": "create_logistics_order",
"rtn_code": "1",
"rtn_msg": "OK",
"allpay_logistics_id": "1234567",
"merchant_trade_no": "LOG202605040001",
"data": {
"RtnCode": "1",
"RtnMsg": "OK"
}
}
Result: The order was accepted by ECPay logistics and returned an AllPayLogisticsID.
You: Query that logistics order later.
AI call: ecpay-logistics - query_logistics_order (MCP)(merchant_trade_no: "LOG202605040001", timestamp: 1714824000)
{
"ok": true,
"endpoint": "query_logistics_order",
"logistics_status": "300",
"allpay_logistics_id": "1234567",
"merchant_trade_no": "LOG202605040001",
"shipment_no": "ABC123456789",
"data": {
"LogisticsStatus": "300"
}
}
Result: The tool returned the current parsed ECPay logistics status and key shipment identifiers.
You: Cancel a C2C order.
AI call: ecpay-logistics - cancel_logistics_order (MCP)(allpay_logistics_id: "1234567", cvs_payment_no: "CVS123", cvs_validation_no: "VAL456")
{
"ok": true,
"endpoint": "cancel_logistics_order",
"result": "1|OK",
"allpay_logistics_id": "1234567"
}
Result: ECPay confirmed the cancel request for the C2C logistics order.
Project Structure
mcp-ecpay-logistics/
├── app.py # FastMCP singleton
├── mcp_server.py # Entry point (stdio transport)
├── config/settings.py # ECPay environment and endpoint selection
├── connectors/ecpay_logistics_client.py # Legacy signing, POST, and response parsing
├── tools/logistics_tools.py # create/query/cancel tools
├── scripts/auth/test_connection.py
└── tests/
└── test_all_tools.py
Development
# Setup
uv sync
cp .env.example .env
# Connection check
uv run --env-file .env python scripts/auth/test_connection.py
# Tool E2E / smoke tests
uv run python tests/test_all_tools.py
# Run server locally
uv run --env-file .env mcp-ecpay-logistics
See tests/test_all_tools.py for live examples of tool invocations and scripts/auth/test_connection.py for a minimal reachability probe.
License
MIT License — see LICENSE for details.
Ecpay Logistics Notes Disclaimer
This project targets ECPay's legacy logistics APIs. These are merchant-authenticated form endpoints, not public anonymous APIs.
Please note: Required fields vary by
LogisticsType/LogisticsSubType. For example, CVS flows needReceiverStoreID, and several C2C flows require sender / receiver cell-phone fields. Treat the payload examples in this README as integration illustrations, not a universal schema for every ECPay logistics product.
The server follows ECPay's legacy CheckMacValue flow (sort parameters, wrap with HashKey / HashIV, URL-encode, MD5, uppercase). If your request is rejected, verify the environment, merchant keys, and exact payload fields first.