Square MCP Server

官方

一个用于 Square 的模型上下文协议(MCP)服务器

文档

Square 模型上下文协议服务器(Beta)

本项目遵循 模型上下文协议 标准,允许 AI 助手与 Square 的 connect API 进行交互。

Square Model Context Protocol Server MCP server

快速开始

使用 npx 快速启动并运行 Square MCP 服务器:

# Basic startup
npx square-mcp-server start

# With environment configuration
ACCESS_TOKEN=YOUR_SQUARE_ACCESS_TOKEN SANDBOX=true npx square-mcp-server start

# local runs
npx /path/to/project/square-mcp-server

YOUR_SQUARE_ACCESS_TOKEN 替换为您实际的 Square 访问令牌。您可以按照 Square 访问令牌 指南获取访问令牌。您也可以在运行命令之前设置环境变量。

远程 MCP 服务器

Square 现在提供托管的远程 MCP 服务器,地址为:

https://mcp.squareup.com/sse

建议使用远程 MCP,因为它使用 OAuth 身份验证,允许您直接使用 Square 账户登录,而无需手动创建或管理访问令牌。

配置选项

环境变量用途示例
ACCESS_TOKEN您的 Square API 访问令牌ACCESS_TOKEN=sq0atp-...
SANDBOX使用 Square 沙盒环境SANDBOX=true
PRODUCTION使用 Square 生产环境PRODUCTION=true
DISALLOW_WRITES限制为只读操作DISALLOW_WRITES=true
SQUARE_VERSION指定 Square API 版本SQUARE_VERSION=2025-04-16

与 AI 助手集成

Goose 集成

配置 Square MCP 服务器与 Goose 配合使用:

远程 MCP

要在 Goose 中安装 Square 远程 MCP,请在安装了 Goose 的计算机上点击此 URL:

goose://extension?cmd=npx&arg=mcp-remote&arg=https%3A%2F%2Fmcp.squareup.com%2Fsse&id=square_mcp_production_remote&name=Square%20MCP%20Remote&description=Square%20Production%20MCP%20Remote

或者将 URL 复制并粘贴到浏览器的地址栏中。

# Automatic installation
npx square-mcp-server install

# Get URL for manual installation
npx square-mcp-server get-goose-url

install 命令会自动更新您的 Goose 配置。

Claude Desktop 集成

有关 Claude Desktop 集成,请参阅 模型上下文协议快速入门指南。将此配置添加到您的 claude_desktop_config.json

远程 MCP

{
  "mcpServers": {
    "mcp_square_api": {
      "command": "npx",
      "args": ["mcp-remote", "https://mcp.squareup.com/sse"]
    }
  }
}

这种方法允许您直接使用 Square 账户凭据进行身份验证,而无需管理访问令牌。

本地 MCP

{
  "mcpServers": {
    "mcp_square_api": {
      "command": "npx",
      "args": ["square-mcp-server", "start"],
      "env": {
        "ACCESS_TOKEN": "YOUR_SQUARE_ACCESS_TOKEN",
        "SANDBOX": "true"
      }
    }
  }
}

工具参考

Square MCP 服务器提供了一组精简的工具,用于与 Square API 交互:

工具描述主要用途
get_service_info发现服务可用的方法探索与发现
get_type_info获取详细的参数要求请求准备
make_api_request执行对 Square 的 API 调用执行操作

服务目录

Square MCP 服务器提供对 Square 完整 API 生态系统 的访问。请查看 Square API 文档 了解每个服务的详细信息:

服务描述
applepayApple Pay 集成
bankaccounts银行账户管理
bookingcustomattributes预约的自定义属性
bookings预约管理
cards支付卡管理
cashdrawers现金抽屉管理
catalog目录管理(商品、类别等)
checkout结账与支付处理
customercustomattributes客户的自定义属性
customergroups客户分组
customersegments客户细分
customers客户管理
devicesSquare 设备管理
disputes支付争议处理
events事件跟踪
giftcardactivities礼品卡活动跟踪
giftcards礼品卡管理
inventory库存跟踪
invoices发票管理
labor劳动力管理
locationcustomattributes位置的自定义属性
locations位置管理
loyalty忠诚度计划管理
merchantcustomattributes商家的自定义属性
merchants商家账户管理
oauth身份验证
ordercustomattributes订单的自定义属性
orders订单管理
payments支付处理
payouts付款管理
refunds退款管理
sites网站集成
snippetsSquare 在线代码集成
subscriptions订阅管理
team员工管理
terminalSquare Terminal 管理
vendors供应商管理
webhooksubscriptions事件通知

使用模式

通过 MCP 与 Square API 进行最佳交互:

  1. 发现:使用 get_service_info 探索可用的方法

    get_service_info(service: "catalog")
    
  2. 理解:使用 get_type_info 了解参数要求

    get_type_info(service: "catalog", method: "list")
    
  3. 执行:使用 make_api_request 执行操作

    make_api_request(service: "catalog", method: "list", request: {})
    

开发与调试

使用 MCP Inspector

MCP Inspector 提供了一个用于测试的可视化界面:

# Build the project
npm run build

# Start the inspector with the Square MCP Server
npx @modelcontextprotocol/inspector node dist/index.js start

开发工作流

  1. 克隆仓库
  2. 安装依赖项:npm install
  3. 启动开发模式:npm run watch
  4. 运行服务器:node dist/index.js start
  5. 使用 MCP Inspector 测试您的更改

贡献

此仓库是根据 Square 的 OpenAPI 规范自动生成的。欢迎贡献,但请注意,更改需要纳入生成此代码的生成器中。在提交拉取请求之前,请先打开一个问题来讨论拟议的更改。