Skip to content

feat: add @xmcp-dev/commet plugin for subscription-aware billing#546

Open
decker-dev wants to merge 13 commits intobasementstudio:canaryfrom
decker-dev:feature/commet-plugin
Open

feat: add @xmcp-dev/commet plugin for subscription-aware billing#546
decker-dev wants to merge 13 commits intobasementstudio:canaryfrom
decker-dev:feature/commet-plugin

Conversation

@decker-dev
Copy link
Copy Markdown

@decker-dev decker-dev commented Apr 2, 2026

Important: Please ensure your pull request is targeting the canary branch. PRs to other branches may be closed or require retargeting.

Summary

Adds @xmcp-dev/commet — a billing plugin that connects xmcp servers to Commet for subscription-aware feature gating and usage tracking.

Uses xmcp's idiomatic middleware/context pattern. The provider extracts the customer ID from a configurable request header and makes it available to standalone functions via context.

Setup

// src/middleware.ts
import { commetProvider } from "@xmcp-dev/commet";

export default commetProvider({
  apiKey: process.env.COMMET_API_KEY!,
  environment: "production",
});

Feature gating and usage tracking

import { check, track } from "@xmcp-dev/commet";

// Boolean gate — is this feature enabled on the customer's plan?
const result = await check("export");
if (!result.allowed) return result.message;

// Metered consumption — tracks 1 unit per call
const result = await track({ feature: "ai_generate", units: 1 });

// AI token tracking — automatic cost from model catalog
const result = await track({
  feature: "ai_chat",
  model: "anthropic/claude-haiku-4.5",
  inputTokens: 1200,
  outputTokens: 340,
});

Uses @commet/node SDK as a dependency — developers only need pnpm i @xmcp-dev/commet.

Type of Change

  • Adding a feature
  • Improving documentation
  • Adding or updating examples

Affected Packages

  • Documentation
  • Examples

New package: packages/plugins/commet

Screenshots/Examples

The commet-http example includes 4 tools demonstrating each flow:

Tool Method Flow
search none Free tool, no gating
export check() Boolean gate, feature on/off per plan
ai_generate track() with units Metered consumption tracking
ai_chat check() + track() with tokens AI token tracking per model

Related Issues

N/A

- CommetProvider with check() for boolean gates and track() for consumption
- Supports metered units and AI token tracking per model
- Includes commet-http example with free, boolean, metered, and AI token tools
- Adds integration docs page
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 2, 2026

@decker-dev is attempting to deploy a commit to the xmcp Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread apps/website/content/docs/integrations/commet.mdx Outdated
Comment thread apps/website/content/docs/integrations/commet.mdx Outdated
Comment thread examples/commet-http/src/lib/commet.ts Outdated
Comment thread examples/commet-http/src/tools/ai-tokens-tool.ts Outdated
Comment thread examples/commet-http/src/tools/export-tool.ts Outdated
@0xKoller
Copy link
Copy Markdown
Collaborator

0xKoller commented Apr 2, 2026

Hoping to see also the quick demo vid if you can too! @decker-dev

Copy link
Copy Markdown
Collaborator

@0xKoller 0xKoller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few tweaks!

Comment thread apps/website/content/docs/integrations/commet.mdx Outdated
Comment thread apps/website/content/docs/integrations/commet.mdx Outdated
Comment thread apps/website/content/docs/integrations/commet.mdx Outdated
Comment thread apps/website/content/docs/integrations/commet.mdx Outdated
Comment thread apps/website/content/docs/integrations/commet.mdx Outdated
Comment thread examples/commet-http/src/tools/ai-tokens-tool.ts Outdated
@0xKoller 0xKoller marked this pull request as ready for review April 9, 2026 21:43
@0xKoller 0xKoller requested a review from valebearzotti as a code owner April 9, 2026 21:43
@decker-dev
Copy link
Copy Markdown
Author

Quick demo showing the 4 tools: free (no gating), boolean gate (export), metered usage (ai_generate), and AI token tracking (ai_chat).

demo_xmcp_commet.mp4

Copy link
Copy Markdown
Collaborator

@0xKoller 0xKoller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants