加密货币支付协议服务器

Coinley MCP Server是一个允许AI代理原生进行加密货币支付的协议服务器,无需浏览器或钱包UI,服务器端不存储私钥。

  • by coinleylabs
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 coinleylabs/coinley-mcp

使用说明

Coinley MCP服务器

一个MCP(模型上下文协议)服务器,允许AI代理在本地进行加密支付——没有浏览器,没有钱包UI,服务器端没有私钥。代理调用工具创建付款,获取存款地址,从自己的钱包发送代币,然后轮询确认。

兼容Claude Code、Claude Desktop、Cursor和任何支持MCP的框架。


安装

克劳德代码(推荐)

claude mcp add --transport stdio coinley -- npx -y github:coinleylabs/coinley-mcp

克劳德桌面版

增添 claude_desktop_config.json:

{
  "mcpServers": {
    "coinley": {
      "command": "npx",
      "args": ["-y", "github:coinleylabs/coinley-mcp"]
    }
  }
}

整个团队/项目(已签入仓库)

添加一个 .mcp.json 在您的repo根目录:

{
  "mcpServers": {
    "coinley": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "github:coinleylabs/coinley-mcp"]
    }
  }
}

先决条件

在使用任何您需要的工具之前:

项目 哪里可以买到
API基本URL 您的Coinley服务器URL,例如。 https://talented-mercy-production.up.railway.app
公钥 商户仪表板→ API密钥。格式: pk_live_... 或 pk_test_...
资金钱包 代理控制的链上钱包,持有它将发送的令牌

MCP服务器本身没有资金,也没有私钥。代理人负责签署链上交易并将其广播到存款地址 create_deposit_payment 返回一个。


工具

list_networks

列出商家接受的所有区块链网络和代币。

先叫这个 要知道哪个 network 在创建付款之前,值是有效的。

输入:

字段 类型 必填 描述
apiBaseUrl string ✅ Coinley API基础URL

退货:

{
  "networks": [
    {
      "name": "Base",
      "shortName": "base",
      "chainId": 8453,
      "tokens": ["USDT", "USDC"]
    },
    {
      "name": "Solana",
      "shortName": "solana",
      "tokens": ["USDT", "USDC"]
    }
  ]
}

使用 shortName 值为 network 领域 create_deposit_payment.


create_deposit_payment

创建付款会话并接收唯一的存款地址。代理将确切的令牌金额发送到此地址以完成付款。

输入:

字段 类型 必填 描述
apiBaseUrl string ✅ Coinley API基础URL
publicKey string ✅ 商户公钥(pk_live_... 或 pk_test_...)
amount 编号 ✅ 付款金额(美元)
network string ✅ 来自的网络简称 list_networks (例如。 base, polygon, solana)
agentId string ✅ 此代理实例的稳定标识符。仅限字母数字、下划线和连字符。最多100个字符。
agentOwner string ✅ 对该代理人负责的人或实体(例如。 "acme-corp", "user_123").最多100个字符。
currency string ❌ USDT (默认)或 USDC
metadata 对象 ❌ 付款记录附带的任意键值对
idempotencyKey string ❌ 防止重试时重复付款的唯一密钥。存储为 orderId 用于对账的支付元数据。
autonomous boolean ❌ 吃起来 true 如果这笔付款是在没有人为监督的情况下进行的。要求商家为此代理启用自主模式。违约: false.

agentId 规则:

  • 必须是仅带下划线/连字符的字母数字: ^[a-zA-Z0-9_-]+$
  • 最多100个字符
  • 每个代理实例应该是稳定的——用于每个代理的速率限制(60个请求/分钟)
  • agentId 和 agentOwner 必须同时提供或同时省略

退货:

{
  "success": true,
  "payment": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "depositAddress": "0xABC123...",
    "amount": "10.00",
    "currency": "USDT",
    "network": "base",
    "expiresAt": "2026-02-24T13:00:00.000Z"
  }
}

收到此响应后:

  1. 保存 id --你需要它 get_payment_status
  2. 准确发送 amount 的 currency 上 network 到 depositAddress 从你的钱包
  3. 之后不要发送到此地址 expiresAt --付款将被标记为过期

get_agent_policy

检查商家为您的代理设置的支出限制和权限。在付款前打电话了解您的限额。

输入:

字段 类型 必填 描述
apiBaseUrl string ✅ Coinley API基础URL
publicKey string ✅ 商户公钥
agentId string ✅ 您的代理标识符

退货:

{
  "success": true,
  "policy": {
    "agentId": "my-agent-v1",
    "maxAmountPerTx": 500,
    "dailyBudget": 2000,
    "monthlyBudget": 10000,
    "allowedNetworks": ["base", "polygon"],
    "allowedTokens": ["USDT", "USDC"],
    "autonomous": true,
    "isActive": true
  }
}

如果没有设置策略, policy 将是 null --这意味着没有约束。

如果只是默认(*)策略存在,但没有特定于代理的策略,默认策略将返回 "isDefault": true.


get_payment_status

检查付款状态。发送令牌后轮询此项,直到 status 是 completed 或 failed.

输入:

字段 类型 必填 描述
apiBaseUrl string ✅ Coinley API基础URL
paymentId string ✅ 从返回的UUID create_deposit_payment

退货:

{
  "success": true,
  "payment": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "status": "completed",
    "confirmations": 5,
    "requiredConfirmations": 5,
    "depositTxHash": "0xabc...",
    "sweepTxHash": "0xdef...",
    "isExpired": false
  }
}

状态值:

状态 含义
pending 等待链上交易出现
confirming 检测到交易,累积确认
completed 完全确认并发送给商家——付款完成
failed 交易失败或被拒绝
expired expiresAt 在收到令牌之前通过

投票指南: 在两次投票之间等待5-15秒。在以下情况下停止轮询 status 是 completed, failed,或 expired,或当 isExpired 是 true.


read_merchant_config

获取商家的页面并从其元标签中提取Coinley API URL和公钥。 当用户直接向您提供商家URL而不是凭据时,请先调用此功能。

字段 类型 必填 描述
pageUrl string ✅ 商家页面的URL

退货: { apiBaseUrl, publicKey }

publicKey 将是 null 如果商家没有选择参与代理发现(即。 enableAgentDiscovery 没有设置在他们的 CoinleyProvider). apiBaseUrl 安装Coinley时始终存在。


create_sandbox_payment

在沙盒模式下创建测试付款。不需要真正的资金。返回a paymentId 可以使用以下方式模拟完成或失败 simulate_payment.

输入:

字段 类型 必填 描述
apiBaseUrl string ✅ Coinley API基础URL
publicKey string ✅ 商户公钥
amount 编号 ✅ 付款金额(美元)
currency string ❌ USDT (默认)或 USDC
network string ❌ 网络简称(例如。 base, polygon)
metadata 对象 ❌ 任意键值对

退货:

{
  "success": true,
  "payment": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "testPaymentId": "test_abc12345",
    "amount": "10.000000",
    "currency": "USDT",
    "status": "pending",
    "isTest": true,
    "expiresAt": "2026-03-13T13:30:00.000Z"
  }
}

simulate_payment

模拟沙盒支付完成或失败。仅适用于通过以下方式创建的付款 create_sandbox_payment.

输入:

字段 类型 必填 描述
apiBaseUrl string ✅ Coinley API基础URL
publicKey string ✅ 商户公钥
paymentId string ✅ 从返回的UUID create_sandbox_payment
action string ✅ complete 或 fail

退货:

{
  "success": true,
  "payment": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "status": "completed",
    "transactionHash": "0xfake...",
    "isTest": true
  }
}

完整使用演练

这是代理人付款的完整流程:

步骤1--发现可用网络

Tool: list_networks
Input: { "apiBaseUrl": "https://talented-mercy-production.up.railway.app" }

选择一个代理拥有足够令牌余额的网络。更喜欢具有快速终结性和低费用的网络(例如。 base, polygon, solana).


步骤2——创建付款

Tool: create_deposit_payment
Input: {
  "apiBaseUrl": "https://talented-mercy-production.up.railway.app",
  "publicKey": "pk_live_abc123",
  "amount": 25.00,
  "network": "base",
  "currency": "USDT",
  "agentId": "my-agent-v1",
  "agentOwner": "acme-corp"
}

保存返回的 id 和 depositAddress.


步骤3——在链上发送代币

使用您的钱包/签名库,准确发送 25.00 USDT 基于 depositAddress.

此步骤在MCP服务器之外——代理必须使用自己的钱包工具对交易进行签名和广播。


第4步——投票确认

Tool: get_payment_status
Input: {
  "apiBaseUrl": "https://talented-mercy-production.up.railway.app",
  "paymentId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

每10秒重复一次,直到 status === "completed".


第5步——完成

sweepTxHash 是您的链上证明,证明商家收到了资金。


速率限制

限制 值
按商家 按账户配置
根据 agentId 60个请求/分钟

如果你收到 429 响应,后退60秒后重试。


错误处理

所有工具都返回结构化错误对象,并提供可操作的建议:

{
  "error": true,
  "tool": "create_deposit_payment",
  "httpStatus": 401,
  "message": "Invalid API credentials",
  "suggestion": "Check that your publicKey is correct and starts with pk_live_ or pk_test_"
}

这 suggestion 当MCP服务器识别出常见错误模式时,该字段会被包括在内:

错误模式 建议
失踪 agentId 或 agentOwner 必须同时提供agentId和agentOwner
无效 paymentId format paymentId必须是create_deposit_palayment返回的UUID
401 /未经授权 检查您的公钥是否正确,是否以pk_live_或pk_test_开头
404 /未找到 未找到付款。验证paymentId是否正确
429 /速率限制 已超出速率限制。等待60秒后重试
网络/连接错误 无法访问Coinley API。检查apiBaseUrl是否正确
违反代理约束 违反代理约束。在重试之前,请使用get_agent_policy检查您的限制。

沙盒/测试模式

使用沙盒工具测试完整的支付流程,而无需花费真正的加密货币。

第一步——创建沙盒支付

Tool: create_sandbox_payment
Input: {
  "apiBaseUrl": "https://talented-mercy-production.up.railway.app",
  "publicKey": "pk_test_abc123",
  "amount": 10.00,
  "currency": "USDT"
}

步骤2——模拟完成或失败

Tool: simulate_payment
Input: {
  "apiBaseUrl": "https://talented-mercy-production.up.railway.app",
  "publicKey": "pk_test_abc123",
  "paymentId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "action": "complete"
}

使用 "action": "fail" 以模拟失败的付款。

步骤3——验证状态

Tool: get_payment_status
Input: {
  "apiBaseUrl": "https://talented-mercy-production.up.railway.app",
  "paymentId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

付款将显示 status: "completed" (或 "failed")与 isTest: true.


示例提示

使用商家URL(推荐-不需要凭据)

Pay $10 on https://store.example.com. My agent ID is my-agent and owner is acme-corp.

克劳德会打电话的 read_merchant_config → list_networks → create_deposit_payment → get_payment_status.

具有明确的凭据(用于开发人员/测试)

You have access to the Coinley MCP server. Use it to pay $10 USDT on Base
to merchant public key pk_live_abc123 at https://talented-mercy-production.up.railway.app.
My agent ID is "scheduler-v2" and owner is "acme-corp".
After creating the payment, send the tokens and confirm completion.

仓库

  • github:https://github.com/coinleylabs/coinley-mcp
  • 问题:https://github.com/coinleylabs/coinley-mcp/issues