@yawlabs/lemonsqueezy-mcp 0.14.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,410 +1,429 @@
1
- # @yawlabs/lemonsqueezy-mcp
2
-
3
- MCP server for the [LemonSqueezy](https://lemonsqueezy.com) API. Manage your store, products, customers, subscriptions, discounts, license keys, and more from any MCP-compatible AI assistant.
4
-
5
- [![Add to Yaw MCP](https://yaw.sh/yaw-mcp-button.svg)](https://yaw.sh/mcp/install?name=LemonSqueezy&command=npx&args=-y%2C%40yawlabs%2Flemonsqueezy-mcp&description=LemonSqueezy%20store%20management%20-%20products%2C%20orders%2C%20subscriptions%2C%20license%20keys&source=https%3A%2F%2Fgithub.com%2FYawLabs%2Flemonsqueezy-mcp)
6
-
7
- One click adds this to your local Yaw MCP config so it's available in every Yaw Terminal session. Or install manually below.
8
-
9
- ## Quick start
10
-
11
- ```bash
12
- npx -y @yawlabs/lemonsqueezy-mcp@latest
13
- ```
14
-
15
- Or one-click install via Smithery:
16
-
17
- ```bash
18
- npx -y @smithery/cli install @yawlabs/lemonsqueezy-mcp --client claude
19
- ```
20
-
21
- Smithery prompts for your env vars (API key, optional guardrails) and writes the config into your client for you.
22
-
23
- ## What it looks like
24
-
25
- Once configured, you can ask your AI assistant store-management questions in plain English and it routes them through the MCP tools:
26
-
27
- ```
28
- You: How much did we make from the "Pro Annual" plan last month?
29
- Claude: [calls ls_list_subscriptions, ls_get_variant, ls_list_subscription_invoices]
30
- Pro Annual brought in $14,280 across 84 active subscriptions in April.
31
- Three of those were upgrades from monthly; none churned.
32
-
33
- You: Refund order #LS-1234 in full.
34
- Claude: [calls ls_get_order to fetch the total, then ls_refund_order with amount = total]
35
- Refunded $99.00 against order LS-1234. The customer's card will see the
36
- credit in 5-10 business days.
37
-
38
- You: Disable license key abc-123 for the customer who reported abuse.
39
- Claude: [calls ls_list_license_keys to find the ID, then ls_update_license_key with disabled: true]
40
- License key disabled. Their existing activations will fail validation
41
- on the next check.
42
- ```
43
-
44
- Guardrails (refund cap, rate limit, store allowlist) catch the obvious mistakes before they reach LemonSqueezy. See [Configuration](#configuration) for the env vars that turn them on.
45
-
46
- ## Setup
47
-
48
- Set your LemonSqueezy API key as an environment variable:
49
-
50
- ```bash
51
- export LEMONSQUEEZY_API_KEY="your-api-key"
52
- ```
53
-
54
- Get your API key from your [LemonSqueezy dashboard](https://app.lemonsqueezy.com/settings/api).
55
-
56
- ### Docker
57
-
58
- A multi-stage `Dockerfile` is included at the repo root. The runtime image is a single bundled file on `node:20-alpine` running as the non-root `node` user, with no port exposed (stdio transport).
59
-
60
- ```bash
61
- docker build -t yawlabs/lemonsqueezy-mcp .
62
- docker run --rm -i -e LEMONSQUEEZY_API_KEY="your-api-key" yawlabs/lemonsqueezy-mcp
63
- ```
64
-
65
- A matching `Containerfile` is provided for Podman users. It is generated from `Dockerfile` via `npm run gen:containerfile`; CI calls `npm run check:containerfile` so a divergent edit fails review rather than drifting silently.
66
-
67
- ### Claude Code
68
-
69
- Add to your MCP config:
70
-
71
- ```json
72
- {
73
- "mcpServers": {
74
- "lemonsqueezy": {
75
- "command": "npx",
76
- "args": ["-y", "@yawlabs/lemonsqueezy-mcp@latest"],
77
- "env": {
78
- "LEMONSQUEEZY_API_KEY": "your-api-key"
79
- }
80
- }
81
- }
82
- }
83
- ```
84
-
85
- ### Claude Desktop
86
-
87
- Add to `claude_desktop_config.json`:
88
-
89
- ```json
90
- {
91
- "mcpServers": {
92
- "lemonsqueezy": {
93
- "command": "npx",
94
- "args": ["-y", "@yawlabs/lemonsqueezy-mcp@latest"],
95
- "env": {
96
- "LEMONSQUEEZY_API_KEY": "your-api-key"
97
- }
98
- }
99
- }
100
- }
101
- ```
102
-
103
- ## Tools (64)
104
-
105
- ### Users
106
- - `ls_get_user` — Get the authenticated user
107
-
108
- ### Stores
109
- - `ls_get_store` — Get a store by ID
110
- - `ls_list_stores` — List all stores
111
-
112
- ### Customers
113
- - `ls_get_customer` — Get a customer by ID
114
- - `ls_list_customers` — List customers (filter by store, email)
115
- - `ls_create_customer` — Create a customer
116
- - `ls_update_customer` — Update a customer
117
- - `ls_archive_customer` — Archive a customer
118
-
119
- ### Products
120
- - `ls_get_product` — Get a product by ID
121
- - `ls_list_products` — List products (filter by store)
122
-
123
- ### Variants
124
- - `ls_get_variant` — Get a variant by ID
125
- - `ls_list_variants` — List variants (filter by product)
126
-
127
- ### Prices
128
- - `ls_get_price` — Get a price by ID
129
- - `ls_list_prices` — List prices (filter by variant)
130
-
131
- Both annotate every record with `effective_unit_price`, the cents actually charged per unit. Read that rather than `unit_price`, which is vestigial on tiered (`volume` / `graduated`) pricing, or a variant's `price`. The subscription-item reads apply the same annotation to prices embedded via `include=price`.
132
-
133
- ### Files
134
- - `ls_get_file` — Get a file by ID
135
- - `ls_list_files` — List files (filter by variant)
136
-
137
- ### Orders
138
- - `ls_get_order` — Get an order by ID
139
- - `ls_list_orders` — List orders (filter by store, email)
140
- - `ls_generate_order_invoice` — Generate a PDF invoice
141
- - `ls_refund_order` — Issue a refund
142
-
143
- ### Order Items
144
- - `ls_get_order_item` — Get an order item by ID
145
- - `ls_list_order_items` — List order items (filter by order, product, variant)
146
-
147
- ### Subscriptions
148
- - `ls_get_subscription` — Get a subscription by ID
149
- - `ls_list_subscriptions` — List subscriptions (filter by store, status, product, etc.)
150
- - `ls_update_subscription` — Update (plan switch, pause, billing anchor, trial)
151
- - `ls_cancel_subscription` — Cancel a subscription
152
-
153
- ### Subscription Invoices
154
- - `ls_get_subscription_invoice` — Get a subscription invoice by ID
155
- - `ls_list_subscription_invoices` — List subscription invoices (filter by store, subscription, status)
156
- - `ls_generate_subscription_invoice` — Generate a PDF invoice
157
- - `ls_refund_subscription_invoice` — Issue a refund
158
-
159
- ### Subscription Items
160
- - `ls_get_subscription_item` — Get a subscription item by ID
161
- - `ls_list_subscription_items` — List subscription items (filter by subscription, price)
162
- - `ls_update_subscription_item` — Update quantity
163
- - `ls_get_subscription_item_usage` — Get current billing period usage
164
-
165
- ### Usage Records
166
- - `ls_get_usage_record` — Get a usage record by ID
167
- - `ls_list_usage_records` — List usage records (filter by subscription item)
168
- - `ls_create_usage_record` — Report metered usage (increment or set)
169
-
170
- ### Discounts
171
- - `ls_get_discount` — Get a discount by ID
172
- - `ls_list_discounts` — List discounts (filter by store)
173
- - `ls_create_discount` — Create a discount code
174
- - `ls_delete_discount` — Delete a discount
175
-
176
- ### Discount Redemptions
177
- - `ls_get_discount_redemption` — Get a discount redemption by ID
178
- - `ls_list_discount_redemptions` — List redemptions (filter by discount, order)
179
-
180
- ### License Keys
181
- - `ls_get_license_key` — Get a license key by ID
182
- - `ls_list_license_keys` — List license keys (filter by store, order, product)
183
- - `ls_update_license_key` — Update activation limit, expiry, or disabled status
184
-
185
- ### License Key Instances
186
- - `ls_get_license_key_instance` — Get a license key activation by ID
187
- - `ls_list_license_key_instances` — List activations (filter by license key)
188
-
189
- ### Checkouts
190
- - `ls_get_checkout` — Get a checkout by ID
191
- - `ls_list_checkouts` — List checkouts (filter by store, variant)
192
- - `ls_create_checkout` — Create a checkout URL (custom pricing, prefill, discounts)
193
-
194
- ### Webhooks
195
- - `ls_get_webhook` — Get a webhook by ID
196
- - `ls_list_webhooks` — List webhooks (filter by store)
197
- - `ls_create_webhook` — Create a webhook
198
- - `ls_update_webhook` — Update a webhook
199
- - `ls_delete_webhook` — Delete a webhook
200
-
201
- ### License API
202
- - `ls_activate_license` — Activate a license key (no API key required)
203
- - `ls_validate_license` — Validate a license key (no API key required)
204
- - `ls_deactivate_license` — Deactivate a license key instance (no API key required)
205
-
206
- ### Webhook sink (optional)
207
- Bridge to a separate [@yawlabs/lemonsqueezy-webhook-sink](https://github.com/YawLabs/lemonsqueezy-webhook-sink) process so the agent can reconcile against webhooks that actually fired. Tools are always registered; if `LEMONSQUEEZY_SINK_URL` / `LEMONSQUEEZY_SINK_ADMIN_TOKEN` are unset, calls return a clear "not configured" error.
208
-
209
- - `ls_sink_events_list` — List webhook events the sink has received (filter by `since` / `type` / `limit`)
210
- - `ls_sink_event_mark_processed` — Mark a sink event as processed by your consumer (idempotent)
211
- - `ls_sink_stats` — Get total events, unprocessed count, and last-received timestamp
212
-
213
- ## Features
214
-
215
- - **Full API coverage** — All 17 LemonSqueezy API resources with 61 tools, plus 3 bridge tools to an optional [@yawlabs/lemonsqueezy-webhook-sink](https://github.com/YawLabs/lemonsqueezy-webhook-sink) for webhook reconciliation
216
- - **JSON:API support** — Filtering, pagination, and relationship inclusion on all list/get operations
217
- - **Zero runtime dependencies** — Single bundled file for instant `npx` startup
218
- - **License API** — Activate, validate, and deactivate license keys without an API key
219
- - **MCP annotations** — Every tool declares read-only, destructive, and idempotent hints
220
- - **Retry with backoff** — 429 and 5xx retries (idempotent methods only) with exponential backoff, jitter, and a 90s overall-deadline ceiling
221
- - **Guardrails** — opt-in store allowlist, refund cap, destructive-call rate limit, authority-class disable (`LEMONSQUEEZY_DISABLE_CLASSES`), and per-authority-class rate limits (`LEMONSQUEEZY_RATE_LIMIT_PER_CLASS`)
222
- - **Audit log MCP Resource** — `lemonsqueezy://audit-log` exposes the last 1000 destructive-call entries as `application/x-ndjson` for clients without stderr access
223
- - **Structured logging** — opt-in JSON logs to stderr with selectable levels (`error`, `audit`, `all`)
224
-
225
- ## Configuration
226
-
227
- All configuration is via environment variables. Only `LEMONSQUEEZY_API_KEY` (or `LEMONSQUEEZY_API_KEY_COMMAND`) is required; everything else is opt-in.
228
-
229
- | Variable | Purpose |
230
- | --- | --- |
231
- | `LEMONSQUEEZY_API_KEY` | LemonSqueezy API token. |
232
- | `LEMONSQUEEZY_API_KEY_COMMAND` | Command whose stdout produces the API key. Overrides `LEMONSQUEEZY_API_KEY`. Output is cached for 1 hour. Use this to pull short-lived credentials from a vault (`op read`, `gcloud secrets versions access`, etc.) without writing them to env vars. The cache is keyed by the command string, so changing it mid-process refreshes on the next request; it is also invalidated automatically on a 401/403 from the API, so a key rotated upstream takes effect on the next call without waiting for the TTL. |
233
- | `LEMONSQUEEZY_TEST_API_KEY` | Optional test-mode key. When set and non-empty, it takes precedence over `LEMONSQUEEZY_API_KEY` (but not over `LEMONSQUEEZY_API_KEY_COMMAND`). On first activation per process, the server prints a one-line JSON `test_mode` notice to stderr so you can confirm test mode is engaged. Use this to point the server at a sandbox/test store without unsetting your production key. |
234
- | `LEMONSQUEEZY_ALLOWED_STORE_IDS` | Comma-separated allowlist of store IDs. When set: (1) any tool whose input includes a `storeId` rejects calls to a non-allowed store; (2) tools that *accept* a `storeId` filter (e.g. `ls_list_orders`, `ls_list_subscriptions`) require it — calls without one are blocked so a missing filter cannot return data from every store the API key can see. Tools with no `storeId` field at all are **not** gated by this allowlist, in two distinct shapes: (a) ID-targeted tools (`ls_refund_order`, `ls_cancel_subscription`, `ls_archive_customer`, `ls_delete_webhook`, `ls_delete_discount`, `ls_update_license_key`) route by their own resource ID, so the caller must already know the ID; (b) `ls_list_stores` and `ls_list_affiliates` take no scoping ID at all and **return rows from every store the API key can see** — `ls_list_stores` will enumerate stores outside the allowlist. Both say so in their own tool descriptions. Other list-by-parent tools (`ls_list_prices`, `ls_list_files`, `ls_list_variants`, `ls_list_order_items`, `ls_list_discount_redemptions`, `ls_list_license_key_instances`, `ls_list_subscription_items`, `ls_list_usage_records`) require a parent-ID filter when the allowlist is set — a partial mitigation, since that parent can itself belong to a non-allowed store. LemonSqueezy API keys are issued at the account level and authorize access to every store in that account, so this allowlist is the only in-process store boundary the server can enforce. Pair it with `LEMONSQUEEZY_MAX_REFUND_AMOUNT_CENTS` / `LEMONSQUEEZY_DESTRUCTIVE_RATE_LIMIT` / `LEMONSQUEEZY_RATE_LIMIT_PER_CLASS` for defense in depth, and — if your account hosts multiple stores you don't want exposed to the same agent — keep those stores under a separate LemonSqueezy account whose API key isn't reachable from this server. |
235
- | `LEMONSQUEEZY_MAX_REFUND_AMOUNT_CENTS` | Non-negative integer. Rejects `ls_refund_order` and `ls_refund_subscription_invoice` calls above this amount. Unset or empty means no cap; **`0` is a valid value and blocks every refund** (the schemas require `amount >= 1`), so use it as a kill switch. The check runs *before* the rate limiters, so a rejected over-cap refund does not consume your destructive or `money`-class budget. |
236
- | `LEMONSQUEEZY_DESTRUCTIVE_RATE_LIMIT` | Non-negative integer. Max destructive tool calls per 60-second rolling window. Unset or empty means no limit; **`0` blocks every destructive call.** In-process limit — per MCP server instance, not global; each `npx` cold start resets the window. Counts include every refund, cancellation, archive, and delete tool, plus the input-dependent destructive paths: `ls_update_license_key` calls that set `disabled: true` *or* change `activationLimit`, `ls_update_subscription` calls that pause or switch plan, and `ls_update_customer` calls with `status: "archived"`. |
237
- | `LEMONSQUEEZY_DISABLE_CLASSES` | Comma-separated list of [authority classes](#authority-classes) to refuse outright. Any tool whose class is listed returns a `guardrail_block` before the API call is attempted. Example: `LEMONSQUEEZY_DISABLE_CLASSES=money,recurring,pii` lets an agent run reads but blocks refunds, subscription changes, and customer-record access. Unknown class names throw at server startup. |
238
- | `LEMONSQUEEZY_RATE_LIMIT_PER_CLASS` | Per-class rolling rate limits, comma-separated. Each entry is `class:N`, `class:N/m`, or `class:N/h` (bare numbers default to per-minute). Example: `money:2/h,recurring:5/h,key:10/m`. Composes with `LEMONSQUEEZY_DESTRUCTIVE_RATE_LIMIT` — both must pass. A limit of `0` blocks every call in that class; classes you don't list are unlimited. Malformed entries throw at server startup. In-process per server instance. |
239
- | `LEMONSQUEEZY_LOG` | Structured-log verbosity to stderr. Set to `all` (or legacy `json`) to log every tool and HTTP call, `audit` to log only destructive-call audit entries plus errors (recommended for production), `error` to log only failures. Unset: no logs. Destructive calls are tagged `audit: true` and include their inputs. Failure entries carry a `status` that identifies the cause: `guardrail_block` (operator policy refused the call), `validation_error` (the client sent a malformed request, e.g. an update with no fields to change), `exception` (something faulted), plus `timeout` / `network_error` and raw HTTP status codes. |
240
- | `LEMONSQUEEZY_SINK_URL` | Base URL of an optional [@yawlabs/lemonsqueezy-webhook-sink](https://github.com/YawLabs/lemonsqueezy-webhook-sink) instance (e.g. `https://webhooks.example.com`). Trailing slashes are stripped. Enables the `ls_sink_*` reconciliation tools below. Unset: the tools are still registered but return a "not configured" error when called. |
241
- | `LEMONSQUEEZY_SINK_ADMIN_TOKEN` | Bearer token for the sink's admin endpoints. Must match the sink's `WEBHOOK_SINK_ADMIN_TOKEN`. Required when `LEMONSQUEEZY_SINK_URL` is set; if the sink itself was started without an admin token, its admin endpoints return 404 and `ls_sink_*` calls surface that diagnostically. |
242
-
243
- ### Logging format
244
-
245
- Each line: `{ts, event, tool?, method?, path?, status, latency_ms, request_id?, error?, audit?, inputs?}`. Stdout is reserved for the MCP protocol — never log there.
246
-
247
- ### Error decoration
248
-
249
- HTTP errors include the upstream `X-Request-Id` when present, so support tickets to LemonSqueezy can reference the exact call.
250
-
251
- ## Authority classes
252
-
253
- **The strongest access control LemonSqueezy itself exposes is the API key boundary.** A LemonSqueezy API key authorizes its full account — every store, every tool — and the only way to deny a class of authority through LemonSqueezy is to not give the API key to the agent in the first place. LemonSqueezy's team-membership UI scopes which humans can do which actions in the dashboard, but the public API key inherits the full authority of the account it was issued under; there's no "this key can read but not refund" toggle. So the authoritative boundary, as far as the upstream API is concerned, is *which API key the agent has*.
254
-
255
- That means the env vars below are the primary in-process control surface for anything LemonSqueezy can't gate by itself — per-class rate ceilings (`RATE_LIMIT_PER_CLASS`), deploy-time class disables (`DISABLE_CLASSES`), refund caps (`MAX_REFUND_AMOUNT_CENTS`), and the audit log. They are belt-and-braces in the sense that an operator who can change the server's env can remove them; they are load-bearing in the sense that LemonSqueezy has no equivalent. If you need an agent that genuinely cannot reach a store or a class of action, the durable answer is a separate LemonSqueezy account whose key is never handed to that agent.
256
-
257
- Every tool is tagged with an **authority class** — a label for the kind of business authority a caller needs to invoke it. The class is separate from the binary destructive/read-only annotation: a customer-record read and a product list are both reads, but only one returns PII; a checkout creation and a refund are both writes, but only one moves money.
258
-
259
- | Class | What it covers | Example tools |
260
- | --- | --- | --- |
261
- | `read` | Safe reads (list/get) that don't return customer PII as the primary payload. | `ls_list_orders`, `ls_get_product`, `ls_validate_license` |
262
- | `pii` | Reads or writes whose primary payload is a customer record. | `ls_list_customers`, `ls_create_customer`, `ls_archive_customer` |
263
- | `mutate` | Safe mutations: checkouts, discounts, invoice generation, usage records. | `ls_create_checkout`, `ls_create_discount`, `ls_generate_order_invoice` |
264
- | `money` | Money movement. Irreversible at the payment layer. | `ls_refund_order`, `ls_refund_subscription_invoice` |
265
- | `recurring` | Subscription state changes that affect recurring revenue. | `ls_update_subscription`, `ls_cancel_subscription`, `ls_update_subscription_item` |
266
- | `key` | License-key admin (activate, deactivate, disable, change activation limit). | `ls_update_license_key`, `ls_activate_license`, `ls_deactivate_license` |
267
- | `webhook` | Webhook configuration — affects the trust surface other systems rely on. | `ls_create_webhook`, `ls_update_webhook`, `ls_delete_webhook` |
268
-
269
- Note: `ls_get_order` returns customer fields incidentally, but its primary payload is the order — it stays in `read`, not `pii`. The class is reserved for tools whose *primary purpose* is the customer record. If you need to deny all access to customer-shaped data, set `LEMONSQUEEZY_DISABLE_CLASSES=pii` and — if the agent must never under any circumstances touch that data — also issue its API key from a separate LemonSqueezy account that doesn't host customer records you care about.
270
-
271
- The two opt-in env vars that consume this taxonomy:
272
-
273
- - `LEMONSQUEEZY_RATE_LIMIT_PER_CLASS` — caps the call rate per class. LemonSqueezy permissions cannot express "max 2 refunds per hour"; this is the only place that policy can live. **This is the load-bearing one for runaway-agent prevention.**
274
- - `LEMONSQUEEZY_DISABLE_CLASSES` — blocks a class outright. Useful when fast deploy-time toggles matter — flipping `DISABLE_CLASSES=pii,mutate,money,recurring,key,webhook` to lock an analytics deployment into pure reads is a one-line config change. An operator who can change the server's env can also remove this gate, so for an authoritative deny use a separate LemonSqueezy account whose API key the agent never sees.
275
-
276
- Both are opt-in; with neither set, behavior is unchanged from prior versions.
277
-
278
- ## Resources
279
-
280
- The server exposes one MCP Resource for clients that prefer structural retrieval over parsing stderr:
281
-
282
- | URI | MIME type | Contents |
283
- | --- | --- | --- |
284
- | `lemonsqueezy://audit-log` | `application/x-ndjson` | The most recent destructive tool calls and outcomes (rate-limit blocks, refund-cap blocks, exceptions, successes). Bounded ring buffer of the last 1000 entries, most-recent-first, resets on server restart. Redaction runs on the input payload before it reaches the buffer: any object key whose name matches a credential / PII pattern (`secret`, `password`, `token`, `api_key`, `bearer`, `authorization`, `signing_secret`, `private_key`, `pin`, `ssn`, `social_security_number`, `credit_card`, `card_number`, `cvv`, `cvc` — case-insensitive, whole-word) AND any string value matching the JWT bearer-token shape (`eyJ…`-prefixed, three base64url segments) is replaced with `[REDACTED]`. Ordinary identifiers (`licenseKey`, `instanceId`, `storeId`, `orderId`, `webhookId`) and UUID-shaped values are preserved. |
285
-
286
- ## Operating the server unattended
287
-
288
- For unattended/agentic use against a live store, we recommend:
289
-
290
- 1. Issue an API key under a LemonSqueezy account that hosts only the store(s) the agent is allowed to touch — LemonSqueezy doesn't expose per-store API-key scoping, so account separation is the durable store boundary. Set `LEMONSQUEEZY_ALLOWED_STORE_IDS` to the same set as a belt-and-braces in-process gate on the tools that take a `storeId`.
291
- 2. Set `LEMONSQUEEZY_MAX_REFUND_AMOUNT_CENTS` to a per-call cap well below any single-refund expectation.
292
- 3. Set `LEMONSQUEEZY_DESTRUCTIVE_RATE_LIMIT` to a small number (e.g. 5/min) as a runaway-agent circuit breaker. For finer control, add `LEMONSQUEEZY_RATE_LIMIT_PER_CLASS=money:2/h,recurring:5/h,key:10/m` so each [authority class](#authority-classes) has its own ceiling.
293
- 4. If a class shouldn't be reachable at all (e.g. an analytics agent that needs only `read`), set `LEMONSQUEEZY_DISABLE_CLASSES` to the classes you want refused. The server rejects them before the API call is built. For an irrevocable deny, also issue the agent's API key from a separate LemonSqueezy account.
294
- 5. Set `LEMONSQUEEZY_LOG=audit` and ship stderr to your log aggregator. The `audit` level keeps every destructive-call entry plus errors but drops successful reads so log volume stays bounded over weeks of operation. Alert on `status: "guardrail_block"` or elevated error rates per tool. Use `LEMONSQUEEZY_LOG=all` while debugging.
295
- 6. Run `LEMONSQUEEZY_API_KEY_COMMAND` against a vault-backed secret so credentials can rotate without restarting the server process. The API client invalidates its in-process key cache automatically on a 401/403, so a rotated upstream key picks up on the next request rather than waiting on the 1h TTL.
296
-
297
- What the server does **not** do and you must own at the caller level:
298
-
299
- - **Idempotency / dedupe store** — MCP servers are stateless subprocesses; cross-invocation dedupe belongs in your agent or orchestrator.
300
- - **Webhook reconciliation** — subscribe to LemonSqueezy webhooks in a separate long-running process to reconcile state when API writes succeed but the response is lost. See [@yawlabs/lemonsqueezy-webhook-sink](https://github.com/YawLabs/lemonsqueezy-webhook-sink) for a ready-made sink.
301
- - **Metrics / dashboards** — the server emits structured logs; derive metrics in your log pipeline.
302
-
303
- See [SEMVER.md](./SEMVER.md) for the versioning policy.
304
-
305
- ## Development
306
-
307
- ```bash
308
- npm install
309
- npm run lint
310
- npm test # full unit + handler suite
311
- npm run test:integration # requires LEMONSQUEEZY_TEST_API_KEY + LEMONSQUEEZY_TEST_STORE_ID
312
- ```
313
-
314
- `Containerfile` is generated from `Dockerfile`. After editing `Dockerfile`:
315
-
316
- ```bash
317
- npm run gen:containerfile # regenerate Containerfile
318
- npm run check:containerfile # CI runs this; non-zero exit means the two have drifted
319
- ```
320
-
321
- ## Running on oam.js (optional)
322
-
323
- [oam.js](https://oamjs.org) runs this server unmodified, and the launcher only ever uses the **latest oam release, currently 0.15.2**. Verified against oam 0.9.0: full MCP handshake, all 64 tools, the `lemonsqueezy://audit-log` resource, working `fetch`, and guardrail rejections with error text identical to Node. On oam 0.15.2 the MCP handshake and all 64 tools have been re-verified through the launcher, with and without the sandbox below.
324
-
325
- **oam 0.15.2 is the minimum.** The launcher picks the newest oam it can find at or above it, never serves on an older one, and falls back to Node when there is none (`LEMONSQUEEZY_MCP_RUNTIME=oam` turns that into a hard error). A floor matters here: releases before 0.9.0 ran `child_process.execFile` arguments through a shell, which was reachable whenever `LEMONSQUEEZY_API_KEY_COMMAND` is configured -- that feature shells out to fetch the key, and its arguments were re-split by a shell.
326
-
327
- The published `lemonsqueezy-mcp` command (`bin/lemonsqueezy-mcp.mjs`, which is what `npx` runs) chooses its runtime from these variables:
328
-
329
- | Variable | Default | Purpose |
330
- |----------|---------|---------|
331
- | `LEMONSQUEEZY_MCP_RUNTIME` | `auto` | `auto`: serve on the oam the launcher is already running under if that is 0.15.2 or newer (unless `LEMONSQUEEZY_MCP_SANDBOX=1`); otherwise run on the newest oam binary it can find at 0.15.2 or newer (see `OAM_BIN`); otherwise on Node. An oam host older than 0.15.2 never serves the server itself -- it hands off to the newest usable oam, or to Node on `PATH`, or exits with an error when there is neither. On stderr, an `OAM_BIN` that was passed over is always named. The other oam binaries passed over, and any `oam.cmd` / `oam.bat` shim, are named only when no usable oam is found -- an older copy skipped for a newer one is not mentioned. A chosen oam that fails to launch, and a handoff to Node from an oam host older than 0.15.2, are always reported; when such a host hands off to a newer oam instead, nothing is printed. `oam`: the same, but exit with an error instead of falling back. `node`: always Node -- in-process under `npx`, and handed off to Node on `PATH` when a client launches the command with `oam run`. Case-insensitive, and any other value behaves like `auto`. |
332
- | `OAM_BIN` | unset | Path to an oam binary to use in preference to discovery, when it is 0.15.2 or newer. If it does not exist, is older, or will not run, the launcher says so on stderr and carries on with discovery. Discovery looks in the installed location (`%LOCALAPPDATA%\oam\bin` then `~/.oam/bin` on Windows, `~/.oam/bin` elsewhere) and on `PATH`, asks every oam it finds for its version, and uses the newest; on a tie the installed copy wins. On Windows only `oam.exe` counts: an `oam.cmd` / `oam.bat` shim is never run, and is named on stderr only when no usable oam is found. Ignored under `LEMONSQUEEZY_MCP_RUNTIME=node`, and when already running on oam 0.15.2+ without the sandbox. |
333
- | `LEMONSQUEEZY_MCP_SANDBOX` | unset | `1` runs the server under `--permission`; see below. |
334
-
335
- ### Sandboxing (opt-in)
336
-
337
- Set `LEMONSQUEEZY_MCP_SANDBOX=1` to run under oam's `--permission` model: network restricted to `api.lemonsqueezy.com` (plus the host of `LEMONSQUEEZY_SINK_URL` when set), filesystem denied outright, and child-process denied unless `LEMONSQUEEZY_API_KEY_COMMAND` is configured.
338
-
339
- `--permission` is a process-level flag, so the launcher always starts a fresh oam for it -- even when a client already launches the command under oam 0.15.2+. That is a preference, not a guarantee: if no usable oam can be started, `LEMONSQUEEZY_MCP_RUNTIME=auto` still serves the server **without** `--permission`, and `LEMONSQUEEZY_MCP_RUNTIME=oam` exits with an error instead.
340
-
341
- It is opt-in rather than default because a wrong grant does not fail loudly. oam denies a non-granted environment variable by making it **absent** from `process.env` rather than throwing, so an under-granted `LEMONSQUEEZY_API_KEY` reads as "unauthenticated" rather than "denied". The env allow-list in the launcher is derived from what the shipped bundle actually reads -- if you add a new `process.env` lookup, extend that list with it.
342
-
343
- ```jsonc
344
- {
345
- "mcpServers": {
346
- "lemonsqueezy": {
347
- "command": "oam",
348
- "args": ["run", "/path/to/lemonsqueezy-mcp/dist/index.js"],
349
- "env": { "LEMONSQUEEZY_API_KEY": "..." }
350
- }
351
- }
352
- }
353
- ```
354
-
355
- Note the `--` separator if you pass arguments to the server rather than to oam: `oam run dist/index.js -- version`.
356
-
357
- **The published command prefers oam; it does not require it.** oam is not distributed on npm, so `npx @yawlabs/lemonsqueezy-mcp` has to keep working without it, and it does: discovery is file-existence checks only, never a subprocess, and the fallback runs the server inside the Node process npm already started. With oam installed, though, the command boots Node, runs `--version` on every oam binary it found to pick the newest, and only then boots oam, so it is always slower than pointing your client at oam directly with the config above. `LEMONSQUEEZY_MCP_RUNTIME=node` skips oam entirely. An MCP client cold-starts this server once per session, so startup is the cost that actually gets paid -- and it has not been measured for this repo on a current oam. Measure on your own hardware before concluding anything.
358
-
359
- Two places oam *does* win for this repo, both opt-in and neither touching the npm package:
360
-
361
- - **`npm run check:oam`** — type-checks via `oam check` (tsgo, TypeScript 7 native). Measured 2878ms against 4406ms for `tsc --noEmit`, same clean result. `npx tsc --noEmit` remains the portable default and is what the pre-commit checklist calls for.
362
- - **`npm run build:binary:oam`** — builds the standalone binary via `oam compile` instead of the Node SEA path. Measured 57.14 MB. Writes to the same `bin/<platform>-<arch>/` path as `npm run build:binary`, so the release staging script consumes either unchanged — run one or the other, not both. If you redistribute that binary it embeds oam's runtime, so ship oam's `LICENSE`, `NOTICE` and `THIRD_PARTY_LICENSES.md` with it.
363
-
364
- The source stays runtime-agnostic on purpose: no `oam:` imports anywhere, and tests stay on `node:test`. That is what keeps the Node fallback real rather than nominal — an `oam:test` or `oam:`-prefixed import would make "falls back to Node" false the moment it landed. Any `oam` invocation writes a bytecode cache to `oam/` in the working directory; that path is gitignored.
365
-
366
- ## Releasing
367
-
368
- Two paths from a clean checkout of `main`. Both produce the same artifact (npm publish with provenance + GitHub release).
369
-
370
- ### 1. Tag-and-let-CI (preferred)
371
-
372
- ```bash
373
- # 1. Bump version
374
- npm version X.Y.Z --no-git-tag-version
375
-
376
- # 2. Commit
377
- git add package.json && git commit -m "vX.Y.Z"
378
-
379
- # 3. Annotated tag (lightweight tags are silently skipped by --follow-tags)
380
- git tag -a vX.Y.Z -m "vX.Y.Z"
381
-
382
- # 4. Push commit + tag
383
- git push origin main --follow-tags
384
-
385
- # 5. Confirm the Release workflow fired (not just CI on the bump commit)
386
- gh run list --limit 2
387
- ```
388
-
389
- The tag push triggers `.github/workflows/release.yml`, which runs `release.sh` in CI mode: lint, test, build, npm publish (with `--provenance`) using the org-level `NPM_TOKEN` secret, then GitHub release creation, then a smoke test against the published tarball, then a publish to the [Official MCP Registry](https://registry.modelcontextprotocol.io) via GitHub OIDC (no `MCP_*` secret needed; the namespace `io.github.YawLabs/*` is authorized purely from the OIDC `repository_owner` claim). No local `npm login` needed.
390
-
391
- ### 2. Local end-to-end
392
-
393
- ```bash
394
- ./release.sh X.Y.Z
395
- ```
396
-
397
- Does the same steps 1–7 on the workstation: lint, test, build, bump, commit, annotated tag, push, npm publish, GitHub release, verify. Idempotent — safe to re-run with the same version after a partial failure. Requires one-time setup:
398
-
399
- ```bash
400
- npm login --auth-type=web # publisher of @yawlabs/lemonsqueezy-mcp
401
- gh auth login # GitHub CLI for the release-creation step
402
- ```
403
-
404
- The local path does **not** publish to the Official MCP Registry — that step lives only in CI and depends on a GitHub Actions OIDC token. To push a locally-released version to the registry, install [`mcp-publisher`](https://github.com/modelcontextprotocol/registry/releases), run `mcp-publisher login github` (interactive OAuth), then `mcp-publisher publish` from the repo root.
405
-
406
- ## License
407
-
408
- MIT
409
-
410
- [![Follow @TokenLimitNews on X](https://img.shields.io/badge/follow-%40TokenLimitNews-000000?logo=x&logoColor=white)](https://x.com/TokenLimitNews)
1
+ # @yawlabs/lemonsqueezy-mcp
2
+
3
+ MCP server for the [LemonSqueezy](https://lemonsqueezy.com) API. Manage your store, products, customers, subscriptions, discounts, license keys, and more from any MCP-compatible AI assistant.
4
+
5
+ [![Add to Yaw MCP](https://yaw.sh/yaw-mcp-button.svg)](https://yaw.sh/mcp/install?name=LemonSqueezy&command=npx&args=-y%2C%40yawlabs%2Flemonsqueezy-mcp&description=LemonSqueezy%20store%20management%20-%20products%2C%20orders%2C%20subscriptions%2C%20license%20keys&source=https%3A%2F%2Fgithub.com%2FYawLabs%2Flemonsqueezy-mcp)
6
+
7
+ One click adds this to your local Yaw MCP config so it's available in every Yaw Terminal session. Or install manually below.
8
+
9
+ ## Quick start
10
+
11
+ ```bash
12
+ npx -y @yawlabs/lemonsqueezy-mcp@latest
13
+ ```
14
+
15
+ Requires Node.js 22 or later (`engines.node` is `>=22`).
16
+
17
+ Or one-click install via Smithery:
18
+
19
+ ```bash
20
+ npx -y @smithery/cli install @yawlabs/lemonsqueezy-mcp --client claude
21
+ ```
22
+
23
+ Smithery prompts for your env vars (API key, optional guardrails) and writes the config into your client for you.
24
+
25
+ ## What it looks like
26
+
27
+ Once configured, you can ask your AI assistant store-management questions in plain English and it routes them through the MCP tools:
28
+
29
+ ```
30
+ You: How much did we make from the "Pro Annual" plan last month?
31
+ Claude: [calls ls_list_subscriptions, ls_get_variant, ls_list_subscription_invoices]
32
+ Pro Annual brought in $14,280 across 84 active subscriptions in April.
33
+ Three of those were upgrades from monthly; none churned.
34
+
35
+ You: Refund order #LS-1234 in full.
36
+ Claude: [calls ls_get_order to fetch the total, then ls_refund_order with amount = total]
37
+ Refunded $99.00 against order LS-1234. The customer's card will see the
38
+ credit in 5-10 business days.
39
+
40
+ You: Disable license key abc-123 for the customer who reported abuse.
41
+ Claude: [calls ls_list_license_keys to find the ID, then ls_update_license_key with disabled: true]
42
+ License key disabled. Their existing activations will fail validation
43
+ on the next check.
44
+ ```
45
+
46
+ Guardrails (refund cap, rate limit, store allowlist) catch the obvious mistakes before they reach LemonSqueezy. See [Configuration](#configuration) for the env vars that turn them on.
47
+
48
+ ## Setup
49
+
50
+ Set your LemonSqueezy API key as an environment variable:
51
+
52
+ ```bash
53
+ export LEMONSQUEEZY_API_KEY="your-api-key"
54
+ ```
55
+
56
+ Get your API key from your [LemonSqueezy dashboard](https://app.lemonsqueezy.com/settings/api).
57
+
58
+ ### Docker
59
+
60
+ A multi-stage `Dockerfile` is included at the repo root. The runtime image is a single bundled file on `node:22-alpine` running as the non-root `node` user, with no port exposed (stdio transport).
61
+
62
+ ```bash
63
+ docker build -t yawlabs/lemonsqueezy-mcp .
64
+ docker run --rm -i -e LEMONSQUEEZY_API_KEY="your-api-key" yawlabs/lemonsqueezy-mcp
65
+ ```
66
+
67
+ A matching `Containerfile` is provided for Podman users. It is generated from `Dockerfile` via `npm run gen:containerfile`. `release.sh` runs `npm run check:containerfile` in step 1, so a release fails if the two have drifted. This repo has no CI, so nothing checks a pull request for drift: run it yourself after editing `Dockerfile`.
68
+
69
+ ### Claude Code
70
+
71
+ Add to your MCP config:
72
+
73
+ ```json
74
+ {
75
+ "mcpServers": {
76
+ "lemonsqueezy": {
77
+ "command": "npx",
78
+ "args": ["-y", "@yawlabs/lemonsqueezy-mcp@latest"],
79
+ "env": {
80
+ "LEMONSQUEEZY_API_KEY": "your-api-key"
81
+ }
82
+ }
83
+ }
84
+ }
85
+ ```
86
+
87
+ ### Claude Desktop
88
+
89
+ Add to `claude_desktop_config.json`:
90
+
91
+ ```json
92
+ {
93
+ "mcpServers": {
94
+ "lemonsqueezy": {
95
+ "command": "npx",
96
+ "args": ["-y", "@yawlabs/lemonsqueezy-mcp@latest"],
97
+ "env": {
98
+ "LEMONSQUEEZY_API_KEY": "your-api-key"
99
+ }
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ ## Tools (64)
106
+
107
+ ### Users
108
+ - `ls_get_user` — Get the authenticated user
109
+
110
+ ### Stores
111
+ - `ls_get_store` — Get a store by ID
112
+ - `ls_list_stores` — List all stores (not gated by `LEMONSQUEEZY_ALLOWED_STORE_IDS`: returns every store the API key can see)
113
+
114
+ ### Customers
115
+ - `ls_get_customer` — Get a customer by ID
116
+ - `ls_list_customers` — List customers (filter by store, email)
117
+ - `ls_create_customer` — Create a customer
118
+ - `ls_update_customer` — Update a customer
119
+ - `ls_archive_customer` — Archive a customer
120
+
121
+ ### Products
122
+ - `ls_get_product` — Get a product by ID
123
+ - `ls_list_products` — List products (filter by store)
124
+
125
+ ### Variants
126
+ - `ls_get_variant` — Get a variant by ID
127
+ - `ls_list_variants` — List variants (filter by product)
128
+
129
+ ### Prices
130
+ - `ls_get_price` — Get a price by ID
131
+ - `ls_list_prices` — List prices (filter by variant)
132
+
133
+ Both annotate every price record with `effective_unit_price`, the cents actually charged per unit, and `effective_unit_price_note`, which says where that number came from; `unit_price_is_not_charged` or `unit_price_is_per_package` is added where it applies. Read `effective_unit_price` rather than `unit_price`, which is vestigial on tiered (`volume` / `graduated`) pricing, or a variant's `price`. The subscription-item reads apply the same annotation to prices embedded via `include=price`.
134
+
135
+ ### Files
136
+ - `ls_get_file` — Get a file by ID
137
+ - `ls_list_files` — List files (filter by variant)
138
+
139
+ ### Orders
140
+ - `ls_get_order` — Get an order by ID
141
+ - `ls_list_orders` — List orders (filter by store, email)
142
+ - `ls_generate_order_invoice` — Generate a PDF invoice
143
+ - `ls_refund_order` — Issue a refund
144
+
145
+ ### Order Items
146
+ - `ls_get_order_item` — Get an order item by ID
147
+ - `ls_list_order_items` — List order items (filter by order, product, variant)
148
+
149
+ ### Subscriptions
150
+ - `ls_get_subscription` — Get a subscription by ID
151
+ - `ls_list_subscriptions` — List subscriptions (filter by store, status, product, etc.)
152
+ - `ls_update_subscription` — Update (plan switch, pause, billing anchor, trial)
153
+ - `ls_cancel_subscription` — Cancel a subscription
154
+
155
+ ### Subscription Invoices
156
+ - `ls_get_subscription_invoice` — Get a subscription invoice by ID
157
+ - `ls_list_subscription_invoices` — List subscription invoices (filter by store, subscription, status)
158
+ - `ls_generate_subscription_invoice` — Generate a PDF invoice
159
+ - `ls_refund_subscription_invoice` — Issue a refund
160
+
161
+ ### Subscription Items
162
+ - `ls_get_subscription_item` — Get a subscription item by ID
163
+ - `ls_list_subscription_items` — List subscription items (filter by subscription, price)
164
+ - `ls_update_subscription_item` — Update quantity
165
+ - `ls_get_subscription_item_usage` — Get current billing period usage
166
+
167
+ ### Usage Records
168
+ - `ls_get_usage_record` — Get a usage record by ID
169
+ - `ls_list_usage_records` — List usage records (filter by subscription item)
170
+ - `ls_create_usage_record` — Report metered usage (increment or set)
171
+
172
+ ### Discounts
173
+ - `ls_get_discount` — Get a discount by ID
174
+ - `ls_list_discounts` — List discounts (filter by store)
175
+ - `ls_create_discount` — Create a discount code
176
+ - `ls_delete_discount` — Delete a discount
177
+
178
+ ### Discount Redemptions
179
+ - `ls_get_discount_redemption` — Get a discount redemption by ID
180
+ - `ls_list_discount_redemptions` — List redemptions (filter by discount, order)
181
+
182
+ ### License Keys
183
+ - `ls_get_license_key` — Get a license key by ID
184
+ - `ls_list_license_keys` — List license keys (filter by store, order, product)
185
+ - `ls_update_license_key` — Update activation limit, expiry, or disabled status
186
+
187
+ ### License Key Instances
188
+ - `ls_get_license_key_instance` — Get a license key activation by ID
189
+ - `ls_list_license_key_instances` — List activations (filter by license key)
190
+
191
+ ### Checkouts
192
+ - `ls_get_checkout` — Get a checkout by ID
193
+ - `ls_list_checkouts` — List checkouts (filter by store, variant)
194
+ - `ls_create_checkout` — Create a checkout URL (custom pricing, prefill, discounts)
195
+
196
+ ### Webhooks
197
+ - `ls_get_webhook` — Get a webhook by ID
198
+ - `ls_list_webhooks` — List webhooks (filter by store)
199
+ - `ls_create_webhook` — Create a webhook
200
+ - `ls_update_webhook` — Update a webhook
201
+ - `ls_delete_webhook` — Delete a webhook
202
+
203
+ ### License API
204
+ - `ls_activate_license` — Activate a license key (no API key required)
205
+ - `ls_validate_license` — Validate a license key (no API key required)
206
+ - `ls_deactivate_license` — Deactivate a license key instance (no API key required). Destructive on every call: rate-limited and audited, with the license key masked in the audit entry
207
+
208
+ ### Affiliates
209
+ - `ls_get_affiliate` — Get an affiliate by ID (commission rate, status, earnings)
210
+ - `ls_list_affiliates` — List affiliates (filter by user email). Not gated by `LEMONSQUEEZY_ALLOWED_STORE_IDS`: returns affiliates from every store the API key can see
211
+
212
+ ### Webhook sink (optional)
213
+ Bridge to a separate [@yawlabs/lemonsqueezy-webhook-sink](https://github.com/YawLabs/lemonsqueezy-webhook-sink) process so the agent can reconcile against webhooks that actually fired. Tools are always registered; if `LEMONSQUEEZY_SINK_URL` / `LEMONSQUEEZY_SINK_ADMIN_TOKEN` are unset, calls return a clear "not configured" error.
214
+
215
+ - `ls_sink_events_list` — List webhook events the sink has received (filter by `since` / `type` / `limit`)
216
+ - `ls_sink_event_mark_processed` — Mark a sink event as processed by your consumer (idempotent)
217
+ - `ls_sink_stats` — Get total events, unprocessed count, and last-received timestamp
218
+
219
+ ## Features
220
+
221
+ - **API coverage** — 58 tools across 20 LemonSqueezy API resources, 3 License API tools, and 3 bridge tools to an optional [@yawlabs/lemonsqueezy-webhook-sink](https://github.com/YawLabs/lemonsqueezy-webhook-sink) for webhook reconciliation (64 in total)
222
+ - **JSON:API support** — Pagination on every `ls_list_*` tool, filters on every one but `ls_list_stores`, and relationship inclusion (`include`) on every `ls_get_*` / `ls_list_*` tool except `ls_get_user` and `ls_get_subscription_item_usage`
223
+ - **Zero runtime dependencies** — Single bundled file for instant `npx` startup
224
+ - **License API** — Activate, validate, and deactivate license keys without an API key
225
+ - **MCP annotations** — Every tool declares read-only, destructive, and idempotent hints
226
+ - **Retry with backoff** — for LemonSqueezy API calls (the `ls_sink_*` tools make a single attempt): a 429 is retried for every method, including POSTs such as refunds and License API calls, after waiting for the server's `Retry-After` (1s if it is missing or unparseable). This relies on a 429 meaning the request was rejected before LemonSqueezy acted on it. If `Retry-After` is over 30s, or the wait would pass the overall deadline, the 429 is returned instead. 5xx responses, timeouts and network errors are retried only for idempotent methods (GET, DELETE), with exponential backoff and jitter; a POST or PATCH that hits one is not retried. Up to 4 attempts, 30s per attempt, and no new attempt or wait is started after 90s
227
+ - **Guardrails** — opt-in store allowlist, refund cap, destructive-call rate limit, authority-class disable (`LEMONSQUEEZY_DISABLE_CLASSES`), and per-authority-class rate limits (`LEMONSQUEEZY_RATE_LIMIT_PER_CLASS`)
228
+ - **Audit log MCP Resource** — `lemonsqueezy://audit-log` exposes the last 1000 destructive-call entries as `application/x-ndjson` for clients without stderr access
229
+ - **Structured logging** — opt-in JSON logs to stderr with selectable levels (`error`, `audit`, `all`)
230
+
231
+ ## Configuration
232
+
233
+ All configuration is via environment variables. The management-API tools need one of `LEMONSQUEEZY_API_KEY_COMMAND`, `LEMONSQUEEZY_TEST_API_KEY` or `LEMONSQUEEZY_API_KEY` (checked in that order); the three License API tools and the `ls_sink_*` tools need none of them. Everything else is opt-in.
234
+
235
+ | Variable | Purpose |
236
+ | --- | --- |
237
+ | `LEMONSQUEEZY_API_KEY` | LemonSqueezy API token. |
238
+ | `LEMONSQUEEZY_API_KEY_COMMAND` | Command whose stdout (trimmed, must be non-empty) is the API key. Takes precedence over `LEMONSQUEEZY_TEST_API_KEY` and `LEMONSQUEEZY_API_KEY`. Use this to pull short-lived credentials from a vault (`op read`, `gcloud secrets versions access`, etc.) without writing them to env vars. It is run directly, **not through a shell**: the string is split on spaces and tabs, single or double quotes group an argument (with no escapes inside them), and a backslash is a literal character. Adjacent quoted and unquoted text joins into one argument, and an empty `''` is dropped. There is no `$VAR` / `~` expansion, globbing, command substitution, piping or redirection. If you need any of those, put them in a script and invoke the script through its interpreter, e.g. `sh /path/get-key.sh`, `node get-key.js`, or on Windows `powershell -NoProfile -File C:\path\get-key.ps1`. **On Windows, a `.cmd` / `.bat` file cannot be launched directly, by bare name or by full path**, and many vault CLIs install as `.cmd` shims (e.g. `gcloud`): wrap them as `cmd /c gcloud secrets versions access ...`, or call an `.exe` such as `op`. The command gets 10 seconds, and stdout and stderr are each capped at 64 KB. Output is cached for 1 hour. The cache is keyed by the command string, so changing it mid-process refreshes on the next request; it is also invalidated automatically on a 401/403 from the API, so a key rotated upstream takes effect on the next call without waiting for the TTL. |
239
+ | `LEMONSQUEEZY_TEST_API_KEY` | Optional test-mode key. When set and non-empty, it takes precedence over `LEMONSQUEEZY_API_KEY` (but not over `LEMONSQUEEZY_API_KEY_COMMAND`). On first activation per process, the server prints a one-line JSON `test_mode` notice to stderr so you can confirm test mode is engaged. Use this to point the server at a sandbox/test store without unsetting your production key. |
240
+ | `LEMONSQUEEZY_ALLOWED_STORE_IDS` | Comma-separated allowlist of store IDs. When set: (1) any tool whose input includes a `storeId` rejects calls to a non-allowed store; (2) tools that *accept* a `storeId` filter (e.g. `ls_list_orders`, `ls_list_subscriptions`) require it — calls without one are blocked so a missing filter cannot return data from every store the API key can see. Tools with no `storeId` field at all are **not** gated by this allowlist, in three distinct shapes: (a) tools addressed by a resource ID (e.g. `ls_get_order`, `ls_refund_order`, `ls_cancel_subscription`, `ls_update_subscription_item`, `ls_create_usage_record`, `ls_archive_customer`, `ls_delete_webhook`, `ls_delete_discount`, `ls_update_license_key`) route by that ID, so the caller must already know it; (b) `ls_list_stores` and `ls_list_affiliates` take no scoping ID at all and **return rows from every store the API key can see** — `ls_list_stores` will enumerate stores outside the allowlist. Both say so in their own tool descriptions. (c) The License API tools (`ls_activate_license`, `ls_validate_license`, `ls_deactivate_license`) authenticate with the license key the caller passes, not the API key, so neither this allowlist nor account separation reaches them; see [Authority classes](#authority-classes) for the controls that do. Other list-by-parent tools (`ls_list_prices`, `ls_list_files`, `ls_list_variants`, `ls_list_order_items`, `ls_list_discount_redemptions`, `ls_list_license_key_instances`, `ls_list_subscription_items`, `ls_list_usage_records`) require a parent-ID filter when the allowlist is set — a partial mitigation, since that parent can itself belong to a non-allowed store. LemonSqueezy API keys are issued at the account level and authorize access to every store in that account, so this allowlist is the only in-process store boundary the server can enforce for the tools that use the API key. Pair it with `LEMONSQUEEZY_MAX_REFUND_AMOUNT_CENTS` / `LEMONSQUEEZY_DESTRUCTIVE_RATE_LIMIT` / `LEMONSQUEEZY_RATE_LIMIT_PER_CLASS` for defense in depth, and — if your account hosts multiple stores you don't want exposed to the same agent — keep those stores under a separate LemonSqueezy account whose API key isn't reachable from this server. |
241
+ | `LEMONSQUEEZY_MAX_REFUND_AMOUNT_CENTS` | Non-negative number. Rejects `ls_refund_order` and `ls_refund_subscription_invoice` calls above this amount (refund amounts are whole cents, so a fractional cap such as `99.5` allows up to 99). Unset or empty means no cap; **`0` is a valid value and blocks every refund** (the schemas require `amount >= 1`), so use it as a kill switch. A negative or non-numeric value stops the server at startup. The check runs *before* the rate limiters, so a rejected over-cap refund does not consume your destructive or `money`-class budget. |
242
+ | `LEMONSQUEEZY_DESTRUCTIVE_RATE_LIMIT` | Non-negative number. Max destructive tool calls per 60-second rolling window (a fraction behaves as the next whole number: `2.5` allows 3 calls). Unset or empty means no limit; **`0` blocks every destructive call.** A negative or non-numeric value stops the server at startup. In-process limit — per MCP server instance, not global; each `npx` cold start resets the window. **Destructive on every call** (whatever the input): `ls_refund_order`, `ls_refund_subscription_invoice`, `ls_cancel_subscription`, `ls_update_subscription_item`, `ls_create_usage_record`, `ls_archive_customer`, `ls_delete_discount`, `ls_delete_webhook` and `ls_deactivate_license`. **Destructive depending on input:** `ls_update_license_key` when it sets `disabled: true` or passes any `activationLimit` or `expiresAt` (`null` included); `ls_update_subscription` when it pauses (`pause: "void"` or `"free"`), switches plan (`variantId`), passes `billingAnchor`, passes `trialEndsAt` (a date or `null`), or sets `invoiceImmediately: true`; `ls_update_customer` with `status: "archived"`; and `ls_update_webhook` when it passes `secret`. No other tool call is destructive. A destructive call refused first by `LEMONSQUEEZY_DISABLE_CLASSES`, the refund cap or `LEMONSQUEEZY_RATE_LIMIT_PER_CLASS` never reaches this counter, so it is not counted. Every destructive call, including a blocked one, is tagged `audit: true` in the log and recorded in `lemonsqueezy://audit-log`. MCP clients see `destructiveHint: true` on all 13 of these tools, including the four input-dependent ones, because an annotation is static; the server-side count for those four is per call. |
243
+ | `LEMONSQUEEZY_DISABLE_CLASSES` | Comma-separated list of [authority classes](#authority-classes) to refuse outright. Any tool whose class is listed returns a `guardrail_block` before the API call is attempted. Example: `LEMONSQUEEZY_DISABLE_CLASSES=money,recurring,pii` blocks refunds, subscription changes and usage reporting, and the dedicated customer tools, while leaving the `read`, `mutate`, `key` and `webhook` classes open. Disabling `pii` does not keep customer data away from the agent: read-class tools still return customer names and emails (see the note under [Authority classes](#authority-classes)). Unknown class names stop the server at startup. |
244
+ | `LEMONSQUEEZY_RATE_LIMIT_PER_CLASS` | Per-class rolling rate limits, comma-separated. Each entry is `class:N`, `class:N/m`, or `class:N/h` (bare numbers default to per-minute). Example: `money:2/h,recurring:5/h,key:10/m`. A `recurring` budget counts usage reports (`ls_create_usage_record`) alongside subscription changes, so size it for any metering agent. Composes with `LEMONSQUEEZY_DESTRUCTIVE_RATE_LIMIT` — both must pass. A limit of `0` blocks every call in that class; classes you don't list are unlimited. Malformed entries throw at server startup. In-process per server instance. |
245
+ | `LEMONSQUEEZY_LOG` | Structured-log verbosity to stderr. Set to `all` (or legacy `json`) to log every tool and HTTP call, `audit` to log only destructive-call audit entries plus errors (recommended for production), `error` to log only failures. Unset (or any other value): no logs. Destructive calls are tagged `audit: true` and include their inputs, redacted as described under [Resources](#resources) (the stderr log and the audit-log resource apply the same redaction). Failure entries carry a `status` that identifies the cause. On `tool_call` lines: `guardrail_block` (operator policy refused the call), `validation_error` (the client sent a malformed request, e.g. an update with no fields to change), `exception` (something faulted), or `error` (the tool returned an error result, such as an HTTP error from LemonSqueezy or a timed-out request). On `http_call` lines: `timeout`, `network_error`, or the HTTP status code. |
246
+ | `LEMONSQUEEZY_SINK_URL` | Base URL of an optional [@yawlabs/lemonsqueezy-webhook-sink](https://github.com/YawLabs/lemonsqueezy-webhook-sink) instance (e.g. `https://webhooks.example.com`). Trailing slashes are stripped. Enables the `ls_sink_*` reconciliation tools below. Unset: the tools are still registered but return a "not configured" error when called. |
247
+ | `LEMONSQUEEZY_SINK_ADMIN_TOKEN` | Bearer token for the sink's admin endpoints. Must match the sink's `WEBHOOK_SINK_ADMIN_TOKEN`. Required when `LEMONSQUEEZY_SINK_URL` is set; if the sink itself was started without an admin token, its admin endpoints return 404 and `ls_sink_*` calls surface that diagnostically. |
248
+
249
+ ### Logging format
250
+
251
+ Each line: `{ts, event, tool?, method?, path?, status, latency_ms, request_id?, error?, audit?, inputs?}`. Stdout is reserved for the MCP protocol — never log there.
252
+
253
+ ### Error decoration
254
+
255
+ HTTP errors include the upstream `X-Request-Id` when present, so support tickets to LemonSqueezy can reference the exact call. When an error body is JSON with no message the server recognizes, it is surfaced whole, in both the error text and the log line, after the same redaction as audited inputs (see [Resources](#resources)). A non-JSON error body is passed through as-is.
256
+
257
+ ## Authority classes
258
+
259
+ **The strongest access control LemonSqueezy itself exposes is the API key boundary.** A LemonSqueezy API key authorizes its full account — every store, and every tool except the three License API tools (see below) and the three `ls_sink_*` bridge tools, which do not use it — and the only way to deny a class of authority through LemonSqueezy is to not give the API key to the agent in the first place. LemonSqueezy's team-membership UI scopes which humans can do which actions in the dashboard, but the public API key inherits the full authority of the account it was issued under; there's no "this key can read but not refund" toggle. So the authoritative boundary, as far as the upstream API is concerned, is *which API key the agent has*.
260
+
261
+ That means the env vars below are the primary in-process control surface for anything LemonSqueezy can't gate by itself — per-class rate ceilings (`RATE_LIMIT_PER_CLASS`), deploy-time class disables (`DISABLE_CLASSES`), refund caps (`MAX_REFUND_AMOUNT_CENTS`), and the audit log. They are belt-and-braces in the sense that an operator who can change the server's env can remove them; they are load-bearing in the sense that LemonSqueezy has no equivalent. If you need an agent that genuinely cannot reach a store or a class of action, the durable answer is a separate LemonSqueezy account whose key is never handed to that agent. That answer does not cover the License API tools (see below).
262
+
263
+ Every tool is tagged with an **authority class** — a label for the kind of business authority a caller needs to invoke it. The class is separate from the binary destructive/read-only annotation: a customer-record read and a product list are both reads, but only one returns PII; a checkout creation and a refund are both writes, but only one moves money.
264
+
265
+ | Class | What it covers | Tools |
266
+ | --- | --- | --- |
267
+ | `read` | Safe reads (list/get) that don't return customer PII as the primary payload. | Every `ls_get_*` and `ls_list_*` tool except `ls_get_customer` and `ls_list_customers`, plus `ls_validate_license`, `ls_sink_events_list` and `ls_sink_stats` |
268
+ | `pii` | The dedicated customer-record tools. This class does not keep customer data out of reach; see the note below. | `ls_get_customer`, `ls_list_customers`, `ls_create_customer`, `ls_update_customer`, `ls_archive_customer` |
269
+ | `mutate` | Non-money mutations: checkouts, discounts, invoice generation, marking sink events processed. | `ls_create_checkout`, `ls_create_discount`, `ls_delete_discount`, `ls_generate_order_invoice`, `ls_generate_subscription_invoice`, `ls_sink_event_mark_processed` |
270
+ | `money` | Money movement. Irreversible at the payment layer. | `ls_refund_order`, `ls_refund_subscription_invoice` |
271
+ | `recurring` | Subscription state and metered billing: changes that affect recurring revenue. | `ls_update_subscription`, `ls_cancel_subscription`, `ls_update_subscription_item`, `ls_create_usage_record` |
272
+ | `key` | License-key admin (activate, deactivate, disable, change activation limit or expiry). | `ls_update_license_key`, `ls_activate_license`, `ls_deactivate_license` |
273
+ | `webhook` | Webhook configuration — affects the trust surface other systems rely on. | `ls_create_webhook`, `ls_update_webhook`, `ls_delete_webhook` |
274
+
275
+ That is every tool's class. `src/tools/tools.test.ts` pins the same map, and moving a tool to another class is a MAJOR change under [SEMVER.md](./SEMVER.md).
276
+
277
+ Note: `pii` gates only the five customer tools above. It does **not** keep customer data out of an agent's reach: read-class tools still return customer names and emails incidentally (orders, subscriptions and license keys carry them), `ls_list_orders` and `ls_list_subscriptions` accept a `userEmail` filter, and the order, subscription and license-key get/list tools accept `include=customer`, which side-loads the customer record. The class is reserved for tools whose *primary purpose* is the customer record, so `LEMONSQUEEZY_DISABLE_CLASSES=pii` blocks those tools, not customer data. To keep customer data away from an agent, issue its API key from a separate LemonSqueezy account that doesn't host customer records you care about.
278
+
279
+ **The License API tools are outside the API-key boundary.** `ls_activate_license`, `ls_validate_license` and `ls_deactivate_license` authenticate with the license key the caller passes, not the API key, so they work on any LemonSqueezy account's license keys, whichever API key the server holds. A separate LemonSqueezy account does not fence them off, and `LEMONSQUEEZY_ALLOWED_STORE_IDS` does not gate them. The controls that do reach them, per tool:
280
+
281
+ - **`ls_deactivate_license`** (class `key`): `LEMONSQUEEZY_DISABLE_CLASSES=key`, `LEMONSQUEEZY_RATE_LIMIT_PER_CLASS=key:N`, and `LEMONSQUEEZY_DESTRUCTIVE_RATE_LIMIT`, which treats every call as destructive. Every call is also audited, with the license key masked (see [Resources](#resources)).
282
+ - **`ls_activate_license`** (class `key`): the same two class controls. Activation is additive, so it is not destructive, and the destructive rate limit and the audit log do not see it.
283
+ - **`ls_validate_license`** (class `read`): only `LEMONSQUEEZY_DISABLE_CLASSES=read` or `LEMONSQUEEZY_RATE_LIMIT_PER_CLASS=read:N`, and both of those also hit every other read. The read-only lock-down below leaves it reachable.
284
+
285
+ Both `key` controls also cover `ls_update_license_key`, the management-API tool in the same class.
286
+
287
+ The two opt-in env vars that consume this taxonomy:
288
+
289
+ - `LEMONSQUEEZY_RATE_LIMIT_PER_CLASS` — caps the call rate per class. LemonSqueezy permissions cannot express "max 2 refunds per hour"; this is the only place that policy can live. **This is the load-bearing one for runaway-agent prevention.**
290
+ - `LEMONSQUEEZY_DISABLE_CLASSES` — blocks a class outright. Useful when fast deploy-time toggles matter — flipping `DISABLE_CLASSES=pii,mutate,money,recurring,key,webhook` to lock an analytics deployment into pure reads is a one-line config change (every `read` tool stays reachable, `ls_validate_license` included). An operator who can change the server's env can also remove this gate, so for an authoritative deny use a separate LemonSqueezy account whose API key the agent never sees; that does not bound the License API tools.
291
+
292
+ Both are opt-in; with neither set, every class is allowed and unlimited.
293
+
294
+ ## Resources
295
+
296
+ The server exposes one MCP Resource for clients that prefer structural retrieval over parsing stderr:
297
+
298
+ | URI | MIME type | Contents |
299
+ | --- | --- | --- |
300
+ | `lemonsqueezy://audit-log` | `application/x-ndjson` | The most recent destructive tool calls and outcomes (rate-limit blocks, refund-cap blocks, exceptions, successes). Bounded ring buffer of the last 1000 entries, most-recent-first, resets on server restart. Inputs are redacted before they reach the buffer, and the stderr log gets the same redacted copy. (1) Any object key whose whole name matches a credential / PII pattern (`secret`, `password`, `token`, `api_key`, `bearer`, `authorization`, `signing_secret`, `private_key`, `pin`, `ssn`, `social_security_number`, `credit_card`, `card_number`, `cvv`, `cvc` — case-insensitive, and the `_` in a compound name may also be `-` or absent) has its value replaced with `[REDACTED]`. (2) A key named `licenseKey`, `license_key` or `license-key` (any case) holds a License API credential, so its value is masked: a string of 16 or more characters becomes `[REDACTED:last4=XXXX]`, keeping its last four characters so an entry can be correlated with a key without exposing it, and any other value becomes `[REDACTED]`. (3) Any string value matching the JWT bearer-token shape (`eyJ…`-prefixed, three base64url segments) becomes `[REDACTED]` under whatever key it appears. Rules (1) and (2) go by key name, so a license key stored under some other key name is not masked. Values under any other key name are kept, including the IDs `licenseKeyId`, `license_key_id`, `licenseKeyInstanceId`, `instanceId`, `storeId`, `orderId` and `webhookId`, and UUID-shaped values. |
301
+
302
+ ## Operating the server unattended
303
+
304
+ For unattended/agentic use against a live store, we recommend:
305
+
306
+ 1. Issue an API key under a LemonSqueezy account that hosts only the store(s) the agent is allowed to touch — LemonSqueezy doesn't expose per-store API-key scoping, so account separation is the durable store boundary. Set `LEMONSQUEEZY_ALLOWED_STORE_IDS` to the same set as a belt-and-braces in-process gate on the tools that take a `storeId`. Account separation does not bound the three License API tools, which authenticate with a license key rather than the API key (see [Authority classes](#authority-classes)).
307
+ 2. Set `LEMONSQUEEZY_MAX_REFUND_AMOUNT_CENTS` to a per-call cap well below any single-refund expectation.
308
+ 3. Set `LEMONSQUEEZY_DESTRUCTIVE_RATE_LIMIT` to a small number (e.g. 5/min) as a runaway-agent circuit breaker. For finer control, add `LEMONSQUEEZY_RATE_LIMIT_PER_CLASS=money:2/h,recurring:5/h,key:10/m` so each [authority class](#authority-classes) has its own ceiling. If the agent also reports metered usage, size the `recurring` figure for that too: usage reports count against it.
309
+ 4. If a class shouldn't be reachable at all (e.g. an analytics agent that needs only `read`), set `LEMONSQUEEZY_DISABLE_CLASSES` to the classes you want refused. The server rejects them before the API call is built. For an irrevocable deny, also issue the agent's API key from a separate LemonSqueezy account (the License API tools excepted).
310
+ 5. Set `LEMONSQUEEZY_LOG=audit` and ship stderr to your log aggregator. The `audit` level keeps every destructive-call entry plus errors but drops successful reads so log volume stays bounded over weeks of operation. Alert on `status: "guardrail_block"` or elevated error rates per tool. Use `LEMONSQUEEZY_LOG=all` while debugging.
311
+ 6. Run `LEMONSQUEEZY_API_KEY_COMMAND` against a vault-backed secret so credentials can rotate without restarting the server process. The API client invalidates its in-process key cache automatically on a 401/403, so a rotated upstream key picks up on the next request rather than waiting on the 1h TTL.
312
+
313
+ What the server does **not** do and you must own at the caller level:
314
+
315
+ - **Idempotency / dedupe store** — MCP servers are stateless subprocesses; cross-invocation dedupe belongs in your agent or orchestrator.
316
+ - **Webhook reconciliation** — subscribe to LemonSqueezy webhooks in a separate long-running process to reconcile state when API writes succeed but the response is lost. See [@yawlabs/lemonsqueezy-webhook-sink](https://github.com/YawLabs/lemonsqueezy-webhook-sink) for a ready-made sink.
317
+ - **Metrics / dashboards** — the server emits structured logs; derive metrics in your log pipeline.
318
+
319
+ See [SEMVER.md](./SEMVER.md) for the versioning policy.
320
+
321
+ ## Development
322
+
323
+ ```bash
324
+ npm install
325
+ npm run lint
326
+ npm test # full unit + handler suite (builds first)
327
+ npm run test:integration # live suite; exits 1 unless LEMONSQUEEZY_TEST_API_KEY + LEMONSQUEEZY_TEST_STORE_ID are set
328
+ ```
329
+
330
+ This repo has no CI: nothing re-runs lint, types or tests on a pull request, so run them locally. `npm run test:integration` writes throwaway `ci-test-` resources to a real store.
331
+
332
+ `Containerfile` is generated from `Dockerfile`. After editing `Dockerfile`:
333
+
334
+ ```bash
335
+ npm run gen:containerfile # regenerate Containerfile
336
+ npm run check:containerfile # release.sh step 1 runs this too; non-zero exit means the two have drifted
337
+ ```
338
+
339
+ ## Running on oam.js (optional)
340
+
341
+ [oam.js](https://oamjs.org) runs this server unmodified, and the launcher only runs the server on an oam that is **0.15.2 or newer**. Verified against oam 0.9.0: full MCP handshake, all 64 tools, the `lemonsqueezy://audit-log` resource, working `fetch`, and guardrail rejections with error text identical to Node. On oam 0.15.2 the MCP handshake and all 64 tools have been re-verified through the launcher, with and without the sandbox below.
342
+
343
+ **oam 0.15.2 is the minimum.** The launcher picks the newest oam it can find at or above it, never serves on an older one, and falls back to Node when there is none (`LEMONSQUEEZY_MCP_RUNTIME=oam` turns that into a hard error). A floor matters here: releases before 0.9.0 ran `child_process.execFile` arguments through a shell, which was reachable whenever `LEMONSQUEEZY_API_KEY_COMMAND` is configured -- that feature runs the key command with `execFile`, deliberately without a shell, and on those releases its arguments were re-split by one anyway.
344
+
345
+ The published `lemonsqueezy-mcp` command (`bin/lemonsqueezy-mcp.mjs`, which is what `npx` runs) chooses its runtime from these variables:
346
+
347
+ | Variable | Default | Purpose |
348
+ |----------|---------|---------|
349
+ | `LEMONSQUEEZY_MCP_RUNTIME` | `auto` | `auto`: serve on the oam the launcher is already running under if that is 0.15.2 or newer (unless `LEMONSQUEEZY_MCP_SANDBOX=1`); otherwise run on the newest oam binary it can find at 0.15.2 or newer (see `OAM_BIN`); otherwise on Node. An oam host older than 0.15.2 never serves the server itself -- it hands off to the newest usable oam, or to Node on `PATH`, or exits with an error when there is neither. On stderr, an `OAM_BIN` that was passed over is always named. The other oam binaries passed over, and any `oam.cmd` / `oam.bat` shim, are named only when no usable oam is found -- an older copy skipped for a newer one is not mentioned. A chosen oam that fails to launch, and a handoff to Node from an oam host older than 0.15.2, are always reported; when such a host hands off to a newer oam instead, nothing is printed. `oam`: the same, but exit with an error instead of falling back. `node`: always Node -- in-process under `npx`, and handed off to Node on `PATH` when a client launches the command with `oam run`. Case-insensitive, and any other value behaves like `auto`. |
350
+ | `OAM_BIN` | unset | Path to an oam binary to use in preference to discovery, when it is 0.15.2 or newer. If it does not exist, is older, or will not run, the launcher says so on stderr and carries on with discovery. Discovery looks in the installed location (`%LOCALAPPDATA%\oam\bin` then `~/.oam/bin` on Windows, `~/.oam/bin` elsewhere) and on `PATH`, asks every oam it finds for its version, and uses the newest; on a tie the installed copy wins. On Windows only `oam.exe` counts: an `oam.cmd` / `oam.bat` shim is never run, and is named on stderr only when no usable oam is found. Ignored under `LEMONSQUEEZY_MCP_RUNTIME=node`, and when already running on oam 0.15.2+ without the sandbox. |
351
+ | `LEMONSQUEEZY_MCP_SANDBOX` | unset | `1` runs the server under `--permission`; see below. |
352
+
353
+ ### Sandboxing (opt-in)
354
+
355
+ Set `LEMONSQUEEZY_MCP_SANDBOX=1` to run under oam's `--permission` model: network restricted to `api.lemonsqueezy.com` (plus the host of `LEMONSQUEEZY_SINK_URL` when set), filesystem denied outright, and child-process denied unless `LEMONSQUEEZY_API_KEY_COMMAND` is configured.
356
+
357
+ `--permission` is a process-level flag, so the launcher always starts a fresh oam for it -- even when a client already launches the command under oam 0.15.2+. That is a preference, not a guarantee: if no usable oam can be started, `LEMONSQUEEZY_MCP_RUNTIME=auto` still serves the server **without** `--permission`, and `LEMONSQUEEZY_MCP_RUNTIME=oam` exits with an error instead.
358
+
359
+ It is opt-in rather than default because a wrong grant does not fail loudly. oam denies a non-granted environment variable by making it **absent** from `process.env` rather than throwing, so an under-granted `LEMONSQUEEZY_API_KEY` reads as "unauthenticated" rather than "denied". The env allow-list in the launcher is derived from what the shipped bundle actually reads -- if you add a new `process.env` lookup, extend that list with it.
360
+
361
+ ```jsonc
362
+ {
363
+ "mcpServers": {
364
+ "lemonsqueezy": {
365
+ "command": "oam",
366
+ "args": ["run", "/path/to/lemonsqueezy-mcp/dist/index.js"],
367
+ "env": { "LEMONSQUEEZY_API_KEY": "..." }
368
+ }
369
+ }
370
+ }
371
+ ```
372
+
373
+ Note the `--` separator if you pass arguments to the server rather than to oam: `oam run dist/index.js -- version`.
374
+
375
+ **The published command prefers oam; it does not require it.** oam is not distributed on npm, so `npx @yawlabs/lemonsqueezy-mcp` has to keep working without it, and it does: discovery is file-existence checks only, never a subprocess, and the fallback runs the server inside the Node process npm already started. With oam installed, though, the command boots Node, runs `--version` on every oam binary it found to pick the newest, and only then boots oam, so it is always slower than pointing your client at oam directly with the config above. `LEMONSQUEEZY_MCP_RUNTIME=node` skips oam entirely. An MCP client cold-starts this server once per session, so startup is the cost that actually gets paid -- and it has not been measured for this repo on a current oam. Measure on your own hardware before concluding anything.
376
+
377
+ Two places oam *does* win for this repo, both opt-in and neither touching the npm package:
378
+
379
+ - **`npm run check:oam`** — type-checks via `oam check` (tsgo, TypeScript 7 native). Measured 2878ms against 4406ms for `tsc --noEmit`, same clean result. `npx tsc --noEmit` remains the portable default and is what the pre-commit checklist calls for.
380
+ - **`npm run build:binary:oam`** — builds the standalone binary via `oam compile` instead of the Node SEA path. Measured 57.14 MB. Writes to the same `bin/<platform>-<arch>/` path as the Node SEA build (`node scripts/build-binary.mjs`), so `scripts/stage-release-asset.mjs` consumes either unchanged — run one or the other, not both. If you redistribute that binary it embeds oam's runtime, so ship oam's `LICENSE`, `NOTICE` and `THIRD_PARTY_LICENSES.md` with it.
381
+
382
+ The source stays runtime-agnostic on purpose: no `oam:` imports anywhere, and tests stay on `node:test`. That is what keeps the Node fallback real rather than nominal — an `oam:test` or `oam:`-prefixed import would make "falls back to Node" false the moment it landed. Any `oam` invocation writes a bytecode cache to `oam/` in the working directory; that path is gitignored.
383
+
384
+ ## Releasing
385
+
386
+ Releases run locally, from a clean checkout of `main`, with `release.sh`. This repo has no GitHub Actions workflows (`.github/` holds only `CODEOWNERS`), so pushing a tag by itself publishes nothing. `release.sh` keeps a CI mode for a tag-triggered release workflow, the intended end state, but nothing invokes it today.
387
+
388
+ Before cutting a release, write the `## [Unreleased]` entry in `CHANGELOG.md` by hand, and run `npm run test:integration` against a test-mode store if `src/api.ts` or a tool handler changed (it needs `LEMONSQUEEZY_TEST_API_KEY` and `LEMONSQUEEZY_TEST_STORE_ID`, and exits 1 without them). The unit suite mocks `fetch`, so it cannot see changes in the upstream API. Then:
389
+
390
+ ```bash
391
+ ./release.sh X.Y.Z
392
+ ```
393
+
394
+ Before step 1, `release.sh` checks that `gh` is installed and authenticated and that you are on `main`, and refuses a dirty working tree unless it is resuming a run whose version bump already landed. Unless `X.Y.Z` is already on npm, it also runs `npm whoami` and stops if that fails, so a dead or missing npm token ends the run before step 4 pushes the tag. `npm whoami` proves the token is live, not that it is an automation token: a web-login session passes it and then fails step 5 with `EOTP`.
395
+
396
+ It then runs eight steps on the workstation:
397
+
398
+ 1. `npm run lint`, and `npm run check:containerfile` (fails if `Containerfile` has drifted from `Dockerfile`)
399
+ 2. `npm test` (which builds first)
400
+ 3. Bump the version in `package.json` and `package-lock.json`, and sync `server.json` to it
401
+ 4. Turn `## [Unreleased]` in `CHANGELOG.md` into `## [X.Y.Z]` (when `[Unreleased]` is empty, write that section from the commit subjects since the previous tag instead, with a warning), commit, create the annotated tag `vX.Y.Z`, and push `main` with the tag
402
+ 5. `npm publish --access public`
403
+ 6. Create the GitHub release, with the notes taken from the `## [X.Y.Z]` section of `CHANGELOG.md`
404
+ 7. Wait for npm to serve the new version (up to 5 minutes, then carry on with a warning), smoke-test `npx -y @yawlabs/lemonsqueezy-mcp@X.Y.Z --version`, then publish `server.json` to the [Official MCP Registry](https://registry.modelcontextprotocol.io) with `mcp-publisher`
405
+ 8. Verify the npm version, `package.json` and the tag
406
+
407
+ Re-running after a partial failure is safe. `./release.sh X.Y.Z` detects the version bump, commit, tag, npm publish and GitHub release that already landed and skips them; lint, test, the push and the npx smoke test run again. The MCP Registry publish in step 7 is not skipped, so a re-run after it has succeeded fails there on the duplicate version.
408
+
409
+ A workstation publish carries no npm provenance attestation: `release.sh` passes `--provenance` only in CI mode.
410
+
411
+ One-time setup on each machine:
412
+
413
+ - **An npm automation token** for a publisher of `@yawlabs/lemonsqueezy-mcp`, in `~/.npmrc` (npmjs.com -> Access Tokens -> Generate -> Automation):
414
+
415
+ ```ini
416
+ @yawlabs:registry=https://registry.npmjs.org/
417
+ //registry.npmjs.org/:_authToken=npm_YOURTOKEN
418
+ ```
419
+
420
+ **Never run `npm login --auth-type=web`.** It overwrites the automation token with a 2FA-bound web session, and the next publish fails with `EOTP`.
421
+ - **`gh auth login`.** The pre-flight requires it, and step 6 creates the release with it. Step 7 logs `mcp-publisher` in with its token (`gh auth token`) unless `MCP_REGISTRY_TOKEN` is set; either way the token needs `read:org` access to YawLabs, which the registry checks for the `io.github.YawLabs/*` namespace. `mcp-publisher` is downloaded to `~/.local/bin` on first use; set `MCP_PUBLISHER` to use another copy.
422
+ - **`jq`, `curl` and `tar` on `PATH`.** Step 3 edits `server.json` with `jq`. Step 7 downloads `mcp-publisher` with `curl` and `tar` on first use, unless `MCP_PUBLISHER` points at an existing copy. It also polls npm with `curl`, and skips that wait with a warning if `curl` is missing.
423
+ - **Rights to push to `main` and create `v*` tags.** The repository rulesets require a pull request for `main` and restrict `v*` tag creation, only organization admins bypass them, and step 4 pushes both directly.
424
+
425
+ ## License
426
+
427
+ MIT
428
+
429
+ [![Follow @TokenLimitNews on X](https://img.shields.io/badge/follow-%40TokenLimitNews-000000?logo=x&logoColor=white)](https://x.com/TokenLimitNews)