Skip to main content
Glama
lightspeed-x

lightspeed-x

by genvjacobc

lightspeed-x-mcp

一个用于 Lightspeed X(Lightspeed Retail POS,即前 Vend 平台)的 Model Context Protocol 服务器。它为 Claude 或任何 MCP 客户端提供对商店销售、库存、产品和客户的只读访问,并替你完成聚合计算:收入、件数、COGS、毛利润、毛利率、折扣、平均客单价和客单件数,可按你指定的任意维度分组。

构造上即只读。 每个工具都只发出 GET 请求。该服务器中不存在任何能创建、更新或删除账户中数据的代码路径,因此你可以放心地将其指向一个正在运营的零售业务。

"What sold best yesterday?"                → lightspeed_sales_report
"Revenue by store last week"               → lightspeed_sales_report, group_by: outlet
"Which SKUs need reordering?"              → lightspeed_inventory_report, status: reorder_needed
"What are our busiest hours?"              → lightspeed_sales_report, group_by: hour
"Margin by brand this month"               → lightspeed_sales_report, group_by: brand
"Pull up invoice 162220"                   → lightspeed_list_sales

为什么存在

Lightspeed X API 是 Vend 时代的遗留物,它有一些尖锐的边角,会让天真的客户端要么变慢、要么悄悄出错。这个服务器替你处理了这些问题,让模型不必操心:

现实

这个服务器做了什么

/sales 接受 date_from 和 date_to,然后静默忽略它们。无论你请求什么日期,所有结果都会返回。

通过对版本序列进行二分查找来定位日期范围,然后在本地过滤。信任这些参数的天真客户端会以十足的自信返回错误答案。

分页是基于版本的,不是基于游标的。没有 cursor 键;响应携带 version: {min, max},你需要用 ?after=<version> 翻页。

由客户端的 paginate 辅助函数透明处理。

文档规定的最大 page_size 是 200,但 API 实际可提供最多 5000。

批量扫描使用 5000(销售使用 1000,因为销售携带完整的行项目)。一次 126,000 行的库存扫描只需 26 次请求,而不是 630 次。

销售行项目只携带 product.id。没有名称、没有 SKU、没有类别。

与缓存的商品目录做连接,使每份报表都具备可读性。

商店的一天并非从 UTC 午夜开始,因此天真的拆分会把晚间销售记到错误的那一天。

日、月、星期和小时桶都在门店自身的 IANA 时区中解析。

退货以负数量和负总额的行项目入账。

它们会正确地从每个指标中净额抵消,无需任何特殊处理。

/product_categories 返回的封装结构与所有其他端点完全不同。

作为独立情况处理。

速率限制为每 5 分钟 300 x 收银机数 + 50,且 429 响应不携带可靠的 Retry-After。

对 429 和 5xx 采用带重试的指数退避。

收入计算方式如何推导

已对照 200 笔连续的实时销售进行验证。每一笔都能与销售自身的 totals.price 在两美分以内对账:

line revenue excl tax = line_items[].pricing.total        (net of discount, already x quantity)
line COGS             = line_items[].pricing.cost_total
line discount given   = line_items[].pricing.discount_total
line tax              = line_items[].tax.total

对实时数据还有三项进一步检查,全部精确匹配:

  • 一周内按日收入之和等于该周总计。

  • group_by: outlet 报表中某门店的行,等于用该门店的服务端过滤器重新运行同一报表的结果。

  • 按支付方式统计的实收金额之和等于含税收入。


Related MCP server: mcp-pdv-demo

安装

选项 1:作为 Claude Code 插件(推荐)

三条命令,无需克隆、无需构建、无需编辑路径:

/plugin marketplace add genvjacobc/lightspeed-x-mcp
/plugin install lightspeed-x@lightspeed-x-mcp
/lightspeed-x:setup

第三条命令运行一个内置的设置技能,引导你获取令牌、将其写入正确位置,并在告诉你成功之前对照你的实时账户验证连接。

该插件还附带一个 reports 技能,让 Claude 知道哪个工具回答哪类零售问题,以及如何解读拿到的数字。

凭据存放在 ${CLAUDE_PLUGIN_DATA}/credentials.env,这是一个按用户隔离的目录,插件更新后依然保留。任何内容都不会在机器或团队成员之间共享。

注意,/plugin uninstall 会删除该目录,因此卸载后重新安装意味着需要重新运行设置。令牌本身在 Lightspeed 中仍然有效,所以如果你不再需要它,请在那里撤销。

选项 2:作为独立 MCP 服务器

git clone https://github.com/genvjacobc/lightspeed-x-mcp.git
cd lightspeed-x-mcp
npm install
npm run build

需要 Node 18 或更高版本。

获取 API 令牌

在 Lightspeed X 后台:Setup → Personal Tokens → Add Personal Token。在关闭对话框之前复制它;它只显示一次。

在规划部署之前,有两个限制值得了解:

  • 只有管理员用户才能创建个人令牌,而且 Lightspeed 将该功能限制在 Plus 套餐。 如果 Setup 下没有出现 Personal Tokens,则需要有管理员权限的人为你创建令牌。

  • Lightspeed 不提供只读令牌。 令牌携带创建它的用户的全部权限。这个服务器只发出 GET 请求,但令牌本身是通用凭据,所以要像对待密码一样对待它;如果泄露,请在同一界面撤销。

验证是否可用

npm run doctor

这会验证你的凭据、调用实时 API,并明确指出任何失败的确切原因。错误的商店域名和错误的令牌都会从 Lightspeed 返回 HTTP 401,因此诊断工具会同时报告两种可能性,而不是猜测。

配置

将 .env.example 复制为 .env 并填写你的商店信息:

LIGHTSPEED_DOMAIN=mystore
LIGHTSPEED_TOKEN=your_personal_token

LIGHTSPEED_DOMAIN 接受裸前缀(mystore)、主机名(mystore.retail.lightspeed.app)或完整 URL。三者都解析到同一位置。

多商店。 任意 LIGHTSPEED_<NAME>_DOMAIN + LIGHTSPEED_<NAME>_TOKEN 组合定义一个名为 <name>(小写)的账户。工具随后接受一个可选的 account 参数:

LIGHTSPEED_NORTH_DOMAIN=northstore
LIGHTSPEED_NORTH_TOKEN=token_for_north
LIGHTSPEED_SOUTH_DOMAIN=southstore
LIGHTSPEED_SOUTH_TOKEN=token_for_south
LIGHTSPEED_DEFAULT_ACCOUNT=north

环境中已有的值始终优先于 .env 文件,因此直接注入凭据的主机具有更高优先级。

注册到 Claude Code(仅限独立路径)

如果你安装了插件,请跳过此步骤;插件会自行注册服务器。

claude mcp add lightspeed-x -s user -- node /absolute/path/to/lightspeed-x-mcp/dist/index.js

或者手动将其添加到你的配置中:

{
  "mcpServers": {
    "lightspeed-x": {
      "command": "node",
      "args": ["/absolute/path/to/lightspeed-x-mcp/dist/index.js"],
      "env": {
        "LIGHTSPEED_DOMAIN": "mystore",
        "LIGHTSPEED_TOKEN": "your_personal_token"
      }
    }
  }
}

对于 Claude Desktop,同样的配置块放在 claude_desktop_config.json 中。

使用 MCP Inspector 在本地验证:

npm run inspect

工具

lightspeed_sales_report

主菜。聚合一个日期范围并对其分组。

参数

说明

date_from、date_to

YYYY-MM-DD,含首尾,按报表时区读取

group_by

product(默认)、sku、category、brand、supplier、tag、outlet、register、salesperson、customer、day、month、weekday、hour、payment_type、none

metrics

revenue、revenue_incl_tax、units、sale_count、cogs、gross_profit、margin_pct、discount、tax、basket_value、basket_size、customer_count

sort_by、sort_direction、limit

排名控制

outlet_id

在服务端应用,因此真正快速

states

默认为 closed,这正是报表的含义

timezone

用于日边界的 IANA 时区覆盖

| Outlet          |   Revenue | Units | Sales | Basket value | Gross profit | Margin |
| --------------- | --------: | ----: | ----: | -----------: | -----------: | -----: |
| South Lincoln   | $3,401.60 |   193 |    91 |       $37.38 |    $2,342.35 |  68.9% |
| York            | $3,222.86 | 159.2 |    73 |       $44.15 |    $2,238.77 |  69.5% |

lightspeed_list_sales

单笔交易,最新在前,可选展开行项目。用于深入查看一张小票、审计某个总额或查看退货。支持按 outlet_id、customer_id 和 min_total 过滤。

lightspeed_inventory_report

现有库存与商品和门店名称连接,并给出货架上的零售价值和成本价值。

status 是关键参数:

状态

含义

low_stock

仍可销售,但已达到或低于再订货点。即正在变少的商品。

reorder_needed

达到或低于再订货点,包括零和负数。即完整的采购清单。

out_of_stock

恰好为零。

negative

低于零,意味着库存盘点错误。

in_stock / all

大于零 / 全部。

group_by 可汇总到 product、outlet、category、brand 或 supplier,这就是回答"每个类别中有多少库存价值"的方式。

lightspeed_search_products

对名称、变体名称、SKU 和 handle 进行自由文本搜索,支持品牌 / 供应商 / 类别 / 标签过滤。匹配在本地针对缓存的目录进行,因为 API 自身的搜索端点排序效果不佳,因此结果是精确的子串匹配。

lightspeed_get_product

按 ID 或精确 SKU 获取单个商品的完整详情,包括各门店库存和计算出的毛利率。

lightspeed_search_customers / lightspeed_get_customer

按邮箱(推送到 API)或按姓名、电话、客户代码(本地匹配)查找客户。返回销售工具用作 customer_id 过滤条件的 UUID。这会返回个人数据,请妥善处理。

lightspeed_list_outlets / lightspeed_list_registers / lightspeed_list_accounts

将商店名称解析为报表过滤器所需的门店 UUID,列出包括电商收银机在内的 POS 通道,并查看服务器可以访问哪些账户。lightspeed_list_accounts 永远不会返回令牌。

lightspeed_list_reference_data

一个工具涵盖 brands、suppliers、product_categories、tags、customer_groups、payment_types、promotions、taxes 和 users。在按品牌或类别筛选报表之前,使用它来获取品牌或类别的确切拼写。

lightspeed_api_get

适用于任何没有专用工具的端点的逃生舱:/consignments、/price_books、/serial_numbers 等。仅会发出 GET 请求。


性能与限制

报表的形态受限于销售记录无法在服务端按日期过滤这一事实。

查询

典型冷启动时间

单日、所有门店(约 900 条销售)

首次调用 15 至 20 秒,之后约 2 秒

一周(约 5,900 条销售)

约 20 秒

全量库存扫描(约 126,000 行)

首次调用约 25 秒,之后即时

产品 / 门店 / 参考号查找

首次调用后 1 秒以内

冷调用的大部分时间花在大约 30 次单行探测上,用于定位日期范围。这些探测会按账户记住,因此会话中的第二份报表通常无需任何探测。目录、门店、收银机、用户和库存扫描会缓存 15 分钟。

为了保持快速运行:当您只关心单个门店时,请传入 outlet_id,并优先选择较窄的日期范围。LIGHTSPEED_MAX_SALES(默认 200,000)限制单次调用的上限,工具在截断时会明确告知,而不会静默返回不完整的答案。

一个坦诚的注意事项。 由于日期范围是通过版本查找的,因此在范围之前创建但在范围之后编辑的销售记录可能会被遗漏。LIGHTSPEED_SEEK_MARGIN_DAYS(默认 1)设定搜索在范围之前的目标距离,提高该值会扩大安全网,代价是扫描更多记录。这是不改按日期过滤的 API 所固有的特性,而非此处采用的捷径。


配置参考

变量

默认值

用途

LIGHTSPEED_DOMAIN

必填

店铺前缀、主机或 URL

LIGHTSPEED_TOKEN

必填

个人令牌

LIGHTSPEED_<NAME>_DOMAIN / _TOKEN

可选

额外的命名账户

LIGHTSPEED_DEFAULT_ACCOUNT

第一个账户

当工具省略 account 时使用的账户

LIGHTSPEED_API_VERSION

2026-01

API 版本路径段

LIGHTSPEED_MAX_SALES

200000

每次销售调用的安全上限

LIGHTSPEED_SEEK_MARGIN_DAYS

1

查找版本锚点时的边际天数

LIGHTSPEED_ENV_FILE

可选

凭据文件的显式路径。插件将其设置为 ${CLAUDE_PLUGIN_DATA}/credentials.env


开发

npm run dev      # run from source with tsx
npm run build    # compile to dist/
npm run inspect  # MCP Inspector against the built server
npm run doctor   # credentials + live connectivity check
npm run validate-plugin  # validate the plugin manifests
src/
  index.ts            entry point, env loading, tool registration
  config.ts           account discovery from the environment
  lib/
    client.ts         HTTP client, retry, version pagination
    version-seek.ts   date to version binary search
    sales.ts          sale fetching and metric aggregation
    catalog.ts        cached product, outlet, register, inventory lookups
    time.ts           timezone-aware day boundaries
    format.ts         Markdown table rendering, tool results
  tools/              one file per tool group

工具返回 Markdown 表格而非原始 JSON:模型阅读对齐的表格比深层 JSON 块更可靠,且所需 token 更少。底层数字也可通过 structuredContent 供程序化调用者使用。

如果你参与贡献,值得遵守两条约定:

  • 绝不从工具处理程序中抛出异常。 失败通过 isError 结果返回。guard() 包装器强制执行这一点。

  • 绝不使用 console.log。 标准输出承载着 JSON-RPC 帧。诊断信息请使用 console.error。


仓库结构

.claude-plugin/     plugin + marketplace manifests
.mcp.json           MCP server declaration used by the plugin path
skills/setup/       guided connection walkthrough
skills/reports/     how to answer retail questions with these tools
src/                TypeScript source
dist/               compiled output, committed so plugin installs need no build

dist/ 有意被纳入 git 跟踪,因为 Claude Code 插件安装不执行构建步骤,编译后的服务器必须随仓库一起发布。提交源代码更改前请运行 npm run build,并在发布时一并提升 package.json、.claude-plugin/plugin.json 和 .claude-plugin/marketplace.json 中的 version。

许可证

MIT。参见 LICENSE。

与 Lightspeed Commerce 无关联,亦未获得其认可。

Available Tools

1 tool
lightspeed_setup_statusLightspeed setup statusA
Read-only

Report whether this server has working Lightspeed credentials, and if not, the exact file path to create and what to put in it. Call this first when any Lightspeed tool fails with a credential error, when the user says Lightspeed is not connected, or when setting the server up for the first time. Safe to call at any time and never returns the token itself.

NameRequiredDescriptionDefault

No parameters

TDQS

A4.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already mark readOnlyHint=true and openWorldHint=true, so the description need not restate safety labels. It adds valuable context: the tool never returns the token itself, and it reports the exact file path and content to create when credentials are absent. This is a useful disclosure beyond the structured hints, warranting a 4.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the core purpose, then usage conditions, then a safety note. Every word earns its place; there is no fluff or repeated information. Ideal conciseness for a tool of this simplicity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple (no parameters, no output schema) and the description covers everything an agent needs to call it correctly: the exact condition to invoke it, what it reveals (success or failure plus remediation info), and its non-sensitive nature. Nothing is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With zero parameters, the schema is trivially covered at 100%, and the rubric sets a baseline of 4 for this case. The description adds no parameter-specific meaning, but nothing is missing—there is nothing to document. The baseline score is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a precise statement of what the tool does: report whether the server has working Lightspeed credentials and, if not, provide the exact file path and content to fix it. This is a specific verb-resource pair that leaves no doubt about the tool's role, and it stands alone clearly even without siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit, actionable usage guidance: call this first when a Lightspeed tool fails with a credential error, when the user reports Lightspeed is not connected, or during initial setup. It also notes the tool is safe to call at any time, covering both when to use and the absence of constraints.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev1.2.0
    • First observedlightspeed_setup_status

TDQS

A4.2/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of confusion or overlap between tool purposes. The tool's role as a credential/setup status check is clearly defined.

Naming Consistency5/5

A single tool name cannot exhibit inconsistency. 'lightspeed_setup_status' is descriptive, snake_case, and follows a predictable pattern for this server.

Tool Count1/5

A single setup/status tool is an extreme mismatch for a server named 'lightspeed-x'. The tool explicitly references other Lightspeed tools that do not exist, making the surface feel incomplete and unbalanced.

Completeness1/5

The server provides no actual Lightspeed operations—only a credential status check. This is severely incomplete for a Lightspeed integration domain and leaves agents with no way to perform real tasks.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    C
    quality
    B
    maintenance
    Enables Claude or any MCP client to query a Toast POS using plain English, with 55 read-only tools covering orders, sales, labor, employees, menus, inventory, customers, and cash.
    55
    2
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI assistants to query a retail and food-service point-of-sale database through predefined business tools for sales summaries, top products, margins, stagnant inventory, cash reconciliation, and optional stock adjustments, returning formatted markdown answers.
    MIT
  • A
    license
    B
    quality
    B
    maintenance
    Enables Claude and other MCP clients to read and write a Loyverse point-of-sale account, covering catalogue items, inventory levels, loyalty customers, receipts and refunds through natural language. Includes a one-call sales summary that aggregates any date range into totals and ranked breakdowns by day, item, category, payment type, employee or store.
    41
    MIT
  • A
    license
    C
    quality
    C
    maintenance
    Enables asking questions in plain language about a Lightspeed Retail store's sales, revenue, stock, products, customers, promotions, and purchase orders, with local-time date handling and readable summaries. It is read-only by construction, so it can retrieve data but never write to the account.
    35
    MIT