Square模型上下文协议服务器(测试版)
该项目遵循 模型上下文协议 标准,允许人工智能助手与Square的connect API进行交互。
快速开始
使用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助手集成
鹅集成
配置Square MCP服务器 鹅:
远程MCP
要在Goose中安装Square远程MCP,请在安装了Goose的计算机上单击以下URL:
或者将URL复制并粘贴到浏览器的地址栏中。
# Automatic installation
npx square-mcp-server install
# Get URL for manual installation
npx square-mcp-server get-goose-url这 install 命令会自动更新Goose配置。
Claude桌面集成
有关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 Server为与Square API交互提供了一套简化的工具:
| 工具 | 描述 | 主要用途 |
|---|---|---|
get_service_info | 发现服务可用的方法 | 探索和发现 |
get_type_info | 获取详细的参数要求 | 请求准备 |
make_api_request | 执行对Square的API调用 | 执行操作 |
服务目录
Square MCP服务器提供对Square完整 API生态系统.看看 Square API文档 有关每项服务的详细信息:
| 服务 | 描述 |
|---|---|
applepay | Apple Pay集成 |
bankaccounts | 银行账户管理 |
bookingcustomattributes | 预订的自定义属性 |
bookings | 预约管理 |
cards | 支付卡管理 |
cashdrawers | 现金抽屉管理 |
catalog | 目录管理(项目、类别等) |
checkout | 结账和付款处理 |
customercustomattributes | 为客户定制属性 |
customergroups | 客户分组 |
customersegments | 客户细分 |
customers | 客户管理 |
devices | 方形设备管理 |
disputes | 付款争议处理 |
events | 事件跟踪 |
giftcardactivities | 礼品卡活动跟踪 |
giftcards | 礼品卡管理 |
inventory | 库存跟踪 |
invoices | 发票管理 |
labor | 劳动力管理 |
locationcustomattributes | 位置的自定义属性 |
locations | 位置管理 |
loyalty | 忠诚度计划管理 |
merchantcustomattributes | 商家的自定义属性 |
merchants | 商户账户管理 |
oauth | 身份验证 |
ordercustomattributes | 订单的自定义属性 |
orders | 订单管理 |
payments | 付款处理 |
payouts | 支出管理 |
refunds | 退款管理 |
sites | 网站集成 |
snippets | Square在线代码集成 |
subscriptions | 订阅管理 |
team | 员工管理 |
terminal | 广场航站楼管理 |
vendors | 供应商管理 |
webhooksubscriptions | 事件通知 |
使用模式
为了通过MCP与Square API进行最佳互动:
- 发现:使用
get_service_info探索可用的方法
get_service_info(service: "catalog")- 理解:使用
get_type_info了解参数要求
get_type_info(service: "catalog", method: "list")- 执行:使用
make_api_request执行操作
make_api_request(service: "catalog", method: "list", request: {})开发与调试
使用MCP检查器
这 MCP检查员 提供了一个用于测试的可视化界面:
# Build the project
npm run build
# Start the inspector with the Square MCP Server
npx @modelcontextprotocol/inspector node dist/index.js start开发工作流程
- 克隆存储库
- 安装依赖项:
npm install - 启动开发模式:
npm run watch - 运行服务器:
node dist/index.js start - 使用MCP检查器测试您的更改
贡献
此存储库是根据Square的OpenAPI规范自动生成的。虽然欢迎贡献,但请注意,需要将更改合并到生成此代码的生成器中。在提交pull请求之前,请打开一个问题来讨论拟议的更改。
