lightspeed-x-mcp
CLAUDE.md0 starsChanged 3 months agoMITView on GitHub
Guidance for Claude Code when working in this repository. lightspeed-x-mcp: an MCP server for Lightspeed X (Retail POS, the platform formerly called Vend), shipped both as a standalone MCP server and as a Claude Code plugin. Read-only by default; since 2.0 it has opt-in writes behind a human approval gate. Use the setup skill in skills/setup/SKILL.md. It has the full walkthrough: where the credential file goes, how to get a token, and how to verify. Do not improvise a setup…
- Reads credentials
The file
We split this CLAUDE.md into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Use the setup skill in skills/setup/SKILL.md.
- Very specific: line 62
Bump
versionin all four places: when releasing: package.json, .claude-plugin/plugin.json, .claude-plugin/marketplace.json, and the … - Distinctive: line 87
A bad value must not survive as a plausible one: Prefer resetting to the default over keeping half a setting.
- Very specific: line 99
All verified against a live account.
≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
Guidance for Claude Code when working in this repository.
What this is
lightspeed-x-mcp: an MCP server for Lightspeed X (Retail POS, the platform
formerly called Vend), shipped both as a standalone MCP server and as a Claude
Code plugin. Read-only by default; since 2.0 it has opt-in writes behind a
human approval gate.
If a user asks you to set this up for them
Use the setup skill in skills/setup/SKILL.md. It has the full walkthrough:
where the credential file goes, how to get a token, and how to verify. Do not
improvise a setup procedure from this file.
The one-command check is:
node dist/index.js --doctorIt validates credentials, calls the live API, and explains any failure. Never tell a user they are connected until the doctor reports every account reachable.
Non-negotiables when editing the server
- Writes go through the gate, always.
LightspeedClient.send()is the only mutating call, and onlytools/writes/apply.tsmay call it. Every other write tool is a preview: it may GET, validate andcreatePlan(), and must returnpreviewResult(). Never add a tool or parameter that sends a POST, PUT, PATCH or DELETE directly. The approval gate is the reason this is safe to point at a live business. - The gate's properties are not negotiable.
lightspeed_apply_writekeeps_meta["anthropic/requiresUserInteraction"]: trueanddestructiveHint; it is the only flagged tool and previews stayreadOnlyHint. Plans stay single use, expiring, bound to a server-written confirm phrase, and re-checked against the write-enabled accounts at apply time. No env var, parameter or config key may skip the per-call approval. - Off unless asked for. With
LIGHTSPEED_WRITE_ACCOUNTSunset, register no write tool at all. High-risk tools (sales, registers, store credit, gift cards, loyalty, and raw writes to those paths) also requireLIGHTSPEED_WRITE_HIGH_RISK=true, enforced inwriteClient(). - Every write tool must say what it cannot do. Set
verified: falseuntil the endpoint has been exercised live, give each step anundowhere one exists, back up prior state viabefore, and add a warning for anything permanent. A POST is never retried except on 429. scripts/check-writes.mjspins all of the above. Extend it when you add a write tool; it must keep passing with no credentials.- Never throw from a tool handler. MCP requires failures to come back as
results, not protocol errors. Wrap every handler in
guard()fromlib/format.ts. - Never
console.log. Stdout carries JSON-RPC frames on stdio transport. Diagnostics go toconsole.error. The only exception isdoctor.ts, which runs outside the protocol. - No retailer-specific values in code. Accounts, domains, and tokens come from the environment. This repo is public and generic.
- Rebuild and commit
dist/. Plugin installs do not run a build step, sodist/is intentionally tracked. A source change that is not rebuilt ships broken. Runnpm run buildbefore committing. Bump
versionin all four places when releasing:package.json,.claude-plugin/plugin.json,.claude-plugin/marketplace.json, and theVERSIONconstant insrc/index.ts. Plugin users only receive updates when the manifest version changes, andVERSIONis what the server announces to its client, so a missed bump makes the running server lie about which build it is. Check with:grep -rn '"version"' package.json .claude-plugin/*.json; grep -n 'const VERSION' src/index.ts
Non-negotiables for user preferences (lib/userconfig.ts)
config.yaml is the one file a non-developer edits by hand, so it is held to a
different standard from the rest of the server.
- No secrets, ever. Credentials stay in
credentials.env. Skills are toldconfig.yamlis safe to read aloud and rewrite, and that has to stay true. - The server never writes it. Config edits go through the
customizeskill's file tools, where the user sees the change. Write access is never configured fromconfig.yaml; it lives only incredentials.env. - Absence and breakage degrade, never fail. A missing file is the normal case. A malformed file falls back to defaults with a warning. An unknown key is ignored with a warning, so a config written for a newer version still works on an older install.
- A bad value must not survive as a plausible one. Prefer resetting to the default over keeping half a setting. Contradictory thresholds reset both sides, and an unrecognised timezone falls back to the account zone rather than silently pinning UTC, which would shift every day boundary.
- Config-derived scoping must be stated in the output. Any skill applying a preference has to say so. A total covering three of twenty outlets that reads like a company-wide total is the worst failure this layer can produce.
- Scope is convenience, not permission. Lightspeed has no store-limited token scope. Never describe or implement config as an access control.
API behaviour you must not rediscover the hard way
All verified against a live account. See lib/client.ts and lib/sales.ts for
the implementation and README.md for the reasoning.
/salesacceptsdate_fromanddate_toand silently ignores them. Date ranges are located by binary-searching the version sequence (lib/version-seek.ts), then filtered client side. Trusting the parameters produces confidently wrong answers.- Pagination is version based: responses carry
version: {min, max}and you page with?after=<version>. There is nocursorkey. - The real
page_sizeceiling is 5000, not the documented 200. Sales use 1000 because line items make pages heavy. outlet_idis honored on/sales. It is the only server-side filter and the main performance lever.- Line-item revenue is
pricing.total, already net of discount and already multiplied by quantity. COGS ispricing.cost_total. Returns are negative quantity line items that net out on their own. - Day boundaries resolve in each outlet's IANA timezone, not UTC.
/product_categoriesuses a different envelope from every other endpoint. It does return the complete taxonomy, so do not reconstruct the tree from products./categories, without the prefix, is the one that 404s.- On
/products, two field names are the opposite of what they look like.product_categoryis the real category assignment, a single dict{id, name, leaf_category, category_path}.categoriesis the tag collection, its ids matchingtag_idsone for one, and there is notagskey at all. Readingcategoriesas the category was the 1.3.1 bug: it broke every category filter and madesales_report group_by=categorygroup by tag names likeTHCAandTier_Premiumwhile still labelling the column Category. The tell is a colon in the value (pouchtype:nicotine). Categories are flat in practice, every oneleaf_category: truewith a one-element path, so there is no hierarchy to walk. Guarded byscripts/check-catalog.mjs. category_idandproduct_category_idon/productsare both accepted (HTTP 200) and then silently ignored, returning the unfiltered page. Same trap as the date params on/sales. Category filtering stays client side.- A wrong store domain returns 401, not 404, because Lightspeed resolves any
*.retail.lightspeed.appsubdomain. A domain typo is indistinguishable from a bad token, so error messages must name both causes.
Verifying a change
npm test runs three credential-free suites (scripts/check-writes.mjs, the
write gate, is described under the non-negotiables above):
scripts/check-config.mjscovers the preferences layer: parsing, precedence, provenance, every degradation path, and an assertion that no token can reach the config object. Run it after any change tolib/userconfig.tsortools/config.ts.scripts/check-catalog.mjspins product normalization, using trimmed real records as fixtures. It exists because the category and tag fields are named the opposite of what they hold, and getting them backwards produces a wrong number that looks right rather than an error. Run it after any change tonormalizeProduct, and extend it rather than trusting a field name whenever you add one.
Everything else is verified against a live account:
npm run buildnpm testnpm run doctorwith real credentials- Boot as a real MCP client over stdio and call the affected tools
- For anything touching money, reconcile: per-day sums must equal the range
total, a grouped outlet figure must equal the same report filtered by that
outlet_id, and tendered-by-payment-type must equal revenue including tax
Reconcile before claiming a metric is correct. Every figure this server reports was checked that way, and a regression in the aggregation would be invisible without it.
Dev setup
node_modules/ is not kept in the OneDrive-synced workspace (removed 2026-09-21). Run npm install here before building or testing. The installed plugin under ~/.claude/plugins/ is unaffected.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

