agentleFS
genvjacobcgenvjacobc/lightspeed-x-mcp/CLAUDE.md

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
  1. Very specific:

    Use the setup skill in skills/setup/SKILL.md.

    line 14
  2. Very specific:

    Bump version in all four places: when releasing: package.json, .claude-plugin/plugin.json, .claude-plugin/marketplace.json, and the …

    line 62
  3. Distinctive:

    A bad value must not survive as a plausible one: Prefer resetting to the default over keeping half a setting.

    line 87
  4. Very specific:

    All verified against a live account.

    line 99

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

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 --doctor

It 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 only tools/writes/apply.ts may call it. Every other write tool is a preview: it may GET, validate and createPlan(), and must return previewResult(). 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_write keeps _meta["anthropic/requiresUserInteraction"]: true and destructiveHint; it is the only flagged tool and previews stay readOnlyHint. 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_ACCOUNTS unset, register no write tool at all. High-risk tools (sales, registers, store credit, gift cards, loyalty, and raw writes to those paths) also require LIGHTSPEED_WRITE_HIGH_RISK=true, enforced in writeClient().
  • Every write tool must say what it cannot do. Set verified: false until the endpoint has been exercised live, give each step an undo where one exists, back up prior state via before, and add a warning for anything permanent. A POST is never retried except on 429.
  • scripts/check-writes.mjs pins 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() from lib/format.ts.
  • Never console.log. Stdout carries JSON-RPC frames on stdio transport. Diagnostics go to console.error. The only exception is doctor.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, so dist/ is intentionally tracked. A source change that is not rebuilt ships broken. Run npm run build before committing.
  • Bump version in all four places when releasing: package.json, .claude-plugin/plugin.json, .claude-plugin/marketplace.json, and the VERSION constant in src/index.ts. Plugin users only receive updates when the manifest version changes, and VERSION is 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 told config.yaml is safe to read aloud and rewrite, and that has to stay true.
  • The server never writes it. Config edits go through the customize skill's file tools, where the user sees the change. Write access is never configured from config.yaml; it lives only in credentials.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.

  • /sales accepts date_from and date_to and 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 no cursor key.
  • The real page_size ceiling is 5000, not the documented 200. Sales use 1000 because line items make pages heavy.
  • outlet_id is 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 is pricing.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_categories uses 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_category is the real category assignment, a single dict {id, name, leaf_category, category_path}. categories is the tag collection, its ids matching tag_ids one for one, and there is no tags key at all. Reading categories as the category was the 1.3.1 bug: it broke every category filter and made sales_report group_by=category group by tag names like THCA and Tier_Premium while still labelling the column Category. The tell is a colon in the value (pouchtype:nicotine). Categories are flat in practice, every one leaf_category: true with a one-element path, so there is no hierarchy to walk. Guarded by scripts/check-catalog.mjs.
  • category_id and product_category_id on /products are 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.app subdomain. 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.mjs covers 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 to lib/userconfig.ts or tools/config.ts.
  • scripts/check-catalog.mjs pins 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 to normalizeProduct, and extend it rather than trusting a field name whenever you add one.

Everything else is verified against a live account:

  1. npm run build
  2. npm test
  3. npm run doctor with real credentials
  4. Boot as a real MCP client over stdio and call the affected tools
  5. 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.