@yawlabs/lemonsqueezy-mcp 0.2.1 → 0.4.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.
Files changed (3) hide show
  1. package/README.md +51 -0
  2. package/dist/index.js +555 -191
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -162,6 +162,57 @@ Add to `claude_desktop_config.json`:
162
162
  - **Zero runtime dependencies** — Single bundled file for instant `npx` startup
163
163
  - **License API** — Activate, validate, and deactivate license keys without an API key
164
164
  - **MCP annotations** — Every tool declares read-only, destructive, and idempotent hints
165
+ - **Retry with backoff** — 429 and 5xx retries (idempotent methods only) with exponential backoff and jitter
166
+ - **Guardrails** — optional store allowlist, refund cap, and destructive-call rate limit
167
+ - **Structured logging** — opt-in JSON logs to stderr for observability and audit
168
+
169
+ ## Configuration
170
+
171
+ All configuration is via environment variables. Only `LEMONSQUEEZY_API_KEY` (or `LEMONSQUEEZY_API_KEY_COMMAND`) is required; everything else is opt-in.
172
+
173
+ | Variable | Purpose |
174
+ | --- | --- |
175
+ | `LEMONSQUEEZY_API_KEY` | LemonSqueezy API token. |
176
+ | `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. |
177
+ | `LEMONSQUEEZY_ALLOWED_STORE_IDS` | Comma-separated allowlist of store IDs. When set, tools that receive a `storeId` input reject calls to any other store. Note: operations that don't take an explicit `storeId` (e.g. `ls_refund_order`) are not gated by this — pair with `LEMONSQUEEZY_MAX_REFUND_AMOUNT_CENTS`. |
178
+ | `LEMONSQUEEZY_MAX_REFUND_AMOUNT_CENTS` | Rejects `ls_refund_order` calls above this amount. |
179
+ | `LEMONSQUEEZY_DESTRUCTIVE_RATE_LIMIT` | Max destructive tool calls per 60-second rolling window. In-process limit — per MCP server instance, not global. |
180
+ | `LEMONSQUEEZY_LOG=json` | Emit one JSON log line to stderr per tool and HTTP call. Destructive calls are tagged `audit: true` and include their inputs. |
181
+
182
+ ### Logging format
183
+
184
+ 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.
185
+
186
+ ### Error decoration
187
+
188
+ HTTP errors include the upstream `X-Request-Id` when present, so support tickets to LemonSqueezy can reference the exact call.
189
+
190
+ ## Operating the server unattended
191
+
192
+ For unattended/agentic use against a live store, we recommend:
193
+
194
+ 1. Set `LEMONSQUEEZY_ALLOWED_STORE_IDS` to the specific store(s) the agent may touch.
195
+ 2. Set `LEMONSQUEEZY_MAX_REFUND_AMOUNT_CENTS` to a per-call cap well below any single-refund expectation.
196
+ 3. Set `LEMONSQUEEZY_DESTRUCTIVE_RATE_LIMIT` to a small number (e.g. 5/min) as a runaway-agent circuit breaker.
197
+ 4. Set `LEMONSQUEEZY_LOG=json` and ship stderr to your log aggregator. Alert on `status: "guardrail_block"` or elevated error rates per tool.
198
+ 5. Run `LEMONSQUEEZY_API_KEY_COMMAND` against a vault-backed secret so credentials can rotate without restarting the server process.
199
+
200
+ What the server does **not** do and you must own at the caller level:
201
+
202
+ - **Idempotency / dedupe store** — MCP servers are stateless subprocesses; cross-invocation dedupe belongs in your agent or orchestrator.
203
+ - **Webhook reconciliation** — subscribe to LemonSqueezy webhooks in a separate long-running process to reconcile state when API writes succeed but the response is lost.
204
+ - **Metrics / dashboards** — the server emits structured logs; derive metrics in your log pipeline.
205
+
206
+ See [SEMVER.md](./SEMVER.md) for the versioning policy.
207
+
208
+ ## Development
209
+
210
+ ```bash
211
+ npm install
212
+ npm run lint
213
+ npm test # full unit + handler suite
214
+ npm run test:integration # requires LEMONSQUEEZY_TEST_API_KEY + LEMONSQUEEZY_TEST_STORE_ID
215
+ ```
165
216
 
166
217
  ## License
167
218