Billing template for xmcp servers. Gate tools by plan, track metered usage, and bill AI token consumption per model.
Stack: xmcp, Commet SDK (@xmcp-dev/commet)
Quick Start
pnpm add @xmcp-dev/commetWhat's Included
Provider middleware with customer identification via headers
Feature gating with boolean checks per tool
Metered usage tracking with included quotas and overage
AI token tracking per model with configurable margins
Full SDK access via
getClient()for portal, subscriptions, and plans
Key Files
src/middleware.ts— Commet provider with API key and environment configsrc/tools/free-tool.ts— Public tool, no gatingsrc/tools/export-tool.ts— Boolean feature gatesrc/tools/pro-tool.ts— Metered usage trackingsrc/tools/ai-tokens-tool.ts— AI token consumption per model
Learn More
See the full working example in the xmcp repository on GitHub.
