Billing tools
Skill arnaudjnn/billing-tools
The get-paid engine for Stripe + WorkOS apps, for humans and AI agents.
npx -y skills add arnaudjnn/billing-toolsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 13 days oldThe repository was created 13 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Add drop-in auth and billing to a Stripe + WorkOS app with the @arnaudjnn/billing-tools library (Next.js, Hono, Bun, Deno, any Node host). Use this skill whenever the user wants to monetize an app, MCP server, or API, charge per token or per credit, add subscriptions or API-key auth, let AI agents self-register with auth.md and pay per request with Stripe MPP machine payments, or wire a token wallet, Stripe Checkout, auto-reload, a Customer Portal, invoices, seat limits, or per-seat token grants, and expose it all as MCP tools, a REST API, or a CLI. Covers the pluggable WorkOS-org adapter (WorkOS-only or WorkOS plus a DB mirror), declarative plans auto-provisioned in Stripe, and a zero-webhook event-polling sync. Triggers on "add billing", "monetize my agent or tools or API", "Stripe and WorkOS", "charge per token", "agent auth.md", "machine payments", or "MPP", even when the library is not named.
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
5.7 KB, as published. Nobody here has run it
Billing Tools
@arnaudjnn/billing-tools is the get-paid engine for Stripe + WorkOS apps, for humans and AI agents. It packages API-key auth (WorkOS), token/credit + subscription billing (Stripe), agent self-registration (auth.md), and machine payments (MPP) behind one storage-pluggable engine, exposed as MCP tools, a REST API, and a CLI. Use it instead of rebuilding billing plumbing in every app.
When to use this skill
Reach for it when the user wants to charge for an app / MCP server / API, add per-token or per-credit metering, sell subscriptions, add API-key auth, let agents register and pay without a human, or stand up a token wallet + Checkout + invoices on a Stripe + WorkOS stack.
Prerequisites
- Node 18+, plus env:
STRIPE_SECRET_KEY,WORKOS_API_KEY,WORKOS_CLIENT_ID(andSTRIPE_WEBHOOK_SECRETif mounting the webhook). - Install as a Git dependency, pinned by commit SHA (ships compiled
dist/, so no build step ortranspilePackagesin the consumer):"dependencies": { "@arnaudjnn/billing-tools": "github:arnaudjnn/billing-tools#<commit-sha>" }
Core wiring (one composition root)
Build one adapter + config and reuse it everywhere, so runWithAuth and the tools share a single AsyncLocalStorage instance:
import {
registerBillingTools, createDispatcher, resolveConfig,
createToolListHandler, createToolDispatchHandler,
createMcpTransport, createStripeWebhookHandler,
} from "@arnaudjnn/billing-tools";
import { WorkOSOrgAdapter } from "@arnaudjnn/billing-tools/adapters/workos-org";
export const adapter = new WorkOSOrgAdapter(); // WorkOS = source of truth
const config = resolveConfig({ currency: "usd", baseUrl: process.env.APP_URL! });
const register = (server: any) => registerBillingTools(server, { adapter, config });
const dispatcher = createDispatcher(register);
export const mcp = createMcpTransport({ register, adapter }); // app/[transport]/route.ts
export const toolList = createToolListHandler({ dispatcher }); // app/api/v0/route.ts
export const toolDispatch = createToolDispatchHandler({ dispatcher }); // app/api/v0/[tool]/route.ts
export const webhook = createStripeWebhookHandler(); // app/api/stripe/webhook/route.ts
Route files stay thin: export const GET = mcp.GET, etc. All handlers are Web-standard Request to Response, so they mount in Next.js, Hono, Bun, Deno, or Cloudflare Workers.
Adapter patterns
- Pattern A (WorkOS-only):
new WorkOSOrgAdapter().orgIdis the WorkOS org id. No extra storage. - Pattern B (WorkOS + DB mirror): pass a
mapsoorgIdstays your own id (e.g.ws_…) while the adapter resolves it to a WorkOS org per call. API keys + the Stripe pointer stay in WorkOS.
Agent auth (auth.md)
Let agents self-register (no human signup):
import { createAgentAuth } from "@arnaudjnn/billing-tools";
export const agentAuth = createAgentAuth({
adapter, config,
branding: { productName: "Acme", logoUri: "https://acme.com/logo.svg" },
identityTypes: ["anonymous", "verified_email"],
});
Mount /auth.md, /.well-known/oauth-{protected-resource,authorization-server}, /agent/identity, /agent/identity/claim, /oauth/token, /oauth/revoke, and pass resourceMetadata: agentAuth.resourceMetadataUrl to the REST/MCP factories so every 401 advertises discovery.
Machine payments (MPP)
Charge agents per request:
import { createMachinePaymentHandler } from "@arnaudjnn/billing-tools";
const pay = createMachinePaymentHandler({ methods: ["stripe"], amount: 50, currency: "usd" });
const gate = await pay.requirePayment(request);
if (gate instanceof Response) return gate; // 402 + WWW-Authenticate: Payment
The 402 challenge ships ready; live settlement is injected via a settle function once the Stripe account is machine-payments-eligible.
Subscriptions, plans, and sync
- Declare plans in code;
registerBillingTools({ plans, defaultPlan })auto-provisions Stripe products/prices vialookup_key(zero dashboard). - Reconcile Stripe + WorkOS with
createBillingSync(...)(event polling, no webhooks); run it in-process withsync.start()or as a serverless cron withcreateSyncRoute(). - Self-serve: the
get_billing_portaltool +createBillingPortalSession()return a Stripe Billing Portal URL.
Tools exposed
get_api_key, list_api_keys, revoke_api_key, get_token_balance, buy_tokens, set_auto_reload, get_billing_portal, list_invoices, list_plans.