Square

官方

一個用於 Square 的模型上下文協定(MCP)伺服器

你可以用 Square MCP 做什麼?

  • 探索 Square API 方法 — 請您的助理使用 get_service_info 探索任何 Square 服務(如目錄或付款)的可用操作。
  • 了解請求參數 — 讓您的助理在發出呼叫前,透過 get_type_info 查詢特定 API 方法的詳細參數需求。
  • 執行 Square API 呼叫 — 指示您的助理執行如列出庫存或建立訂單等操作,透過 make_api_request 完成。
  • 連線至託管的 Square MCP — 設定您的 AI 助理,使用位於 https://mcp.squareup.com/mcp 的遠端伺服器,透過 OAuth 驗證您的 Square 帳戶。

託管 MCP 伺服器

npx add-mcp 'https://mcp.squareup.com/sse' --transport sse

可安裝到 Claude Code、Codex、Cursor 等客戶端

文件

Square 模型上下文協定伺服器(Beta)

本專案遵循 模型上下文協定 標準,讓 AI 助手能夠與 Square 的 connect API 互動。

大多數使用者應使用託管伺服器。 Square 在 https://mcp.squareup.com/mcp 執行遠端 MCP 伺服器,並提供 OAuth 登入;請參閱 Square MCP 文件 以了解如何與您的 AI 助手進行設定。本儲存庫是本地端、自行託管的伺服器:如果您想執行自己的副本,這是一個起點。程式碼變更會透過「貢獻」一節所述的產生器進行。

Square Model Context Protocol Server MCP server

快速開始

使用 npx 即可啟動並執行本地伺服器。這會在您自己的機器上使用您自己的存取權杖執行伺服器;如需託管伺服器,請參閱上方說明。

# 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/mcp

建議使用遠端伺服器:它使用 OAuth,因此您可以使用 Square 帳戶登入,而無需建立和管理存取權杖。Claude、ChatGPT、Goose 及其他助手的設定指南位於 Square MCP 文件。較舊的 https://mcp.squareup.com/sse 端點仍會為現有的 SSE 設定提供服務。

設定選項

環境變數用途範例
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 整合

若要使用 Goose 設定 Square MCP 伺服器:

遠端 MCP

若要在 Goose 中安裝 Square 遠端 MCP,請在安裝了 Goose 的電腦上點擊此 URL:

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

或者將 URL 複製並貼上到瀏覽器的網址列。

以下指令設定的是本地伺服器(npx square-mcp-server start),而非託管伺服器:

# 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/mcp"]
    }
  }
}

此方法可讓您直接使用 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 Online Code 整合
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 規格自動產生的。雖然歡迎貢獻,但請注意,變更需要納入產生此程式碼的產生器中。請在提交 pull request 之前開啟 issue 討論建議的變更。