MCP Monetize - Drop-in Billing & Capability Token Engine

io.github.RitualDev-LabPublished by GitHub account RitualDev-Labv0.1.3Updated Nov 19, 2026

Drop-in billing, paywalls, and capability token middleware for MCP servers.

The publisher's own server: Engine Travel Platform

VerifiedSTDIODesktop onlyDeveloper ToolsBusiness & Commerce

Overview

AI-generated overview

A drop-in billing and paywall middleware library that lets MCP server authors charge users per tool call or by subscription.

What you can do
  • Wrap MCP tool handlers so each call is metered against free credits and paid balances
  • Enforce quotas and return a paywall message with a Dodo Payments or Stripe checkout link when credits run out
  • Store credit balances in memory, SQLite, Redis/Upstash or a JSON file
  • Process Dodo and Stripe payment webhooks to top up user credits automatically
  • Configure free-tier call counts, price labels, payment provider and custom user-ID extraction
When to use it
For developers publishing their own MCP servers who want to charge for tool usage, offer a free trial quota, or add subscription or pay-per-call billing without building a billing backend.
Requirements
Runs as a local npm package (Node.js) imported into your own MCP server code. Needs a Dodo Payments or Stripe checkout/payment link, and for webhook settlement the webhook secrets DODO_WEBHOOK_SECRET or DODO_PAYMENTS_WEBHOOK_KEY and STRIPE_WEBHOOK_SECRET. The Redis adapter needs UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.
Before you install
It handles real payments: users are sent to external checkout links and credits are granted from webhook events, so webhook signature verification and secret handling matter. Webhook secrets such as DODO_WEBHOOK_SECRET and STRIPE_WEBHOOK_SECRET are sensitive. The default in-memory store loses balances on restart, and the JSON file store keeps credit data on disk. It is a library for server authors, not a ready-made hosted billing service.

Installation

In SourceWeft

  1. Open MCP Monetize - Drop-in Billing & Capability Token Engine in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

💳 mcp-monetize

Drop-in billing, credit tracking, and paywall middleware for Model Context Protocol (MCP) servers.
Monetize your AI agent tools in 3 lines of code with Dodo Payments & Stripe.

[npm version] [License: MIT] [MCP Compatible]


⚡ The Problem

Developers are publishing thousands of Model Context Protocol (MCP) servers for Claude Desktop, Cursor, and Windsurf. But until now:

  • There was no standard way to charge users per tool invocation or per month.
  • Tool creators bear the heavy server, LLM API, and scraping costs while users consume unlimited queries for free.

mcp-monetize solves this by giving MCP server creators an effortless 3-line drop-in middleware that manages quotas, verifies credits, and returns interactive payment links directly inside the agent chat when quotas run out.

mcp-monetize vs. mcp-builder-kit

PackageRoleWhen to Use
mcp-monetize (this repo)Commercial Billing Clearinghouse & Paywall SDKMonetizing MCP tool invocations with Universal Pre-Paid MCP Credits, usage quotas, Dodo Payments / Stripe checkout links, and webhook-driven credit settlement.
@ritualdev-lab/mcp-builder-kit (RitualDev-Lab/mcp-builder-kit)Free Open-Source (Apache-2.0) MCP Scaffolding CLIBootstrapping TypeScript/Python MCP servers (stdio / streamable-http), wrapping tools with --with-agentshield redaction, converting OpenAPI/GraphQL/Protobuf specs, and running protocol conformance tests.

🚀 Quickstart (3 Lines of Code)

1. Install

bash
npm install @ritualdev-lab/mcp-monetize# orpnpm add @ritualdev-lab/mcp-monetize

2. Wrap your MCP tool handler

typescript
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";import { withMcpMonetization } from "@ritualdev-lab/mcp-monetize";import { z } from "zod";
const server = new McpServer({ name: "market-oracle", version: "1.0.0" });
server.tool(  "query_stock_valuation",  { ticker: z.string() },  withMcpMonetization(    async ({ ticker }) => {      const data = await fetchValuation(ticker);      return { content: [{ type: "text", text: `Valuation for ${ticker}: $142.50` }] };    },    {      // Your Dodo Payments or Stripe payment link      checkoutUrl: "https://checkout.dodopayments.com/buy/pdt_0NpjONGugY5QkrFDUaPva",      priceLabel: "$5 for 1,000 queries",      freeTierCalls: 5 // 5 free queries for every new user    }  ));

🖼️ How the Agent Sees the Paywall

When a user in Claude Desktop, Cursor, or Windsurf exhausts their free calls, the agent automatically receives structured markdown prompting the user to top up:

markdown
🔒 Usage Limit Reached for `query_stock_valuation`
Your complimentary tool credits have been exhausted. To continue executing queries with uninterrupted speed:
### 💳 Unlock Instant Access ($5 for 1,000 queries)👉 [Click Here to Activate / Top-Up Credits via Secure Checkout](https://checkout.dodopayments.com/buy/pdt_xyz)
---*User Ref: `dev_client_01` • Payments securely powered by Dodo Payments & Stripe.*

Once the user completes payment via UPI, Credit Card, or Apple Pay, their webhook or API key activates paid credits and execution resumes seamlessly!


⚙️ Configuration Options

OptionTypeDefaultDescription
checkoutUrlstring | (userId: string) => stringRequiredDodo Payments product link or Stripe Payment link. Can be dynamic function.
freeTierCallsnumber5Number of free calls given to each new user before paywall triggers.
priceLabelstring"$0.05 / call"Pricing description displayed inside the paywall message.
provider"dodo" | "stripe" | "custom""dodo"Payment provider tag.
storeTokenStoreMemoryTokenStoreStorage engine (MemoryTokenStore or JsonFileTokenStore).
getUserId(args, extra) => stringAutomaticCustom function to extract workspace or user ID.
customPaywallMessage(info) => stringStandard templateOptional custom paywall markdown generator.

💾 Storage Adapters

1. In-Memory (Default)

Fastest, zero-dependency. Great for local desktop tools.

typescript
import { MemoryTokenStore } from "mcp-monetize";const store = new MemoryTokenStore(5);

2. SQLite Database Persistence

Built-in node:sqlite store with zero native dependencies. Supports thread-safe transactions and atomic balances.

typescript
import { SqliteTokenStore } from "mcp-monetize/adapters/sqlite";const store = new SqliteTokenStore("./data/mcp-credits.sqlite", 10);

3. Serverless Redis / Upstash

Designed for cloud-hosted MCP servers (Render, Fly.io, Railway, AWS Lambda).

typescript
import { RedisTokenStore } from "mcp-monetize/adapters/redis";const store = new RedisTokenStore({  url: process.env.UPSTASH_REDIS_REST_URL!,  token: process.env.UPSTASH_REDIS_REST_TOKEN!,  defaultFreeCredits: 10});

4. JSON File Persistence

Zero database dependencies; persists user credits across server restarts in mcp-credits.json.

typescript
import { JsonFileTokenStore } from "mcp-monetize";const store = new JsonFileTokenStore("./data/credits.json", 10);

🤝 Webhook Fulfillment Engine (Turnkey Dodo & Stripe)

Use the built-in PaymentWebhookHandler to process checkouts and replenish user credits automatically:

typescript
import { PaymentWebhookHandler, SqliteTokenStore } from "mcp-monetize";
const store = new SqliteTokenStore("./data/tokens.sqlite");const webhooks = new PaymentWebhookHandler({  store,  dodoWebhookSecret: process.env.DODO_WEBHOOK_SECRET || process.env.DODO_PAYMENTS_WEBHOOK_KEY,  stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET});
// In your Express or Fastify server:app.post("/api/webhooks/dodo", async (req, res) => {  const result = await webhooks.handleDodoWebhook(req.body, req.headers["x-dodo-signature"]);  res.status(result.success ? 200 : 400).json(result);});

🔐 Cryptographic License Key Verification

For off-line or client-side MCP distribution (where users supply a license key in claude_desktop_config.json):

typescript
import { McpLicenseValidator } from "mcp-monetize";
const validator = new McpLicenseValidator("your_hmac_secret_key_min_32_chars");
// Issue a 30-day license key:const token = validator.generateLicenseKey("user_456", 30);
// Verify inside your tool:const check = validator.verifyLicense(token);if (check.valid) {  console.log(`Verified user ${check.userId}, expires: ${check.expiresAt}`);}

📦 Turnkey Starter Kit & Production Examples

Looking for ready-to-deploy boilerplates? Check the examples/ directory:

  1. examples/01-weather-api-server.ts — Pay-per-query API ($5 for 500 calls).
  2. examples/02-sql-agent-server.ts — Monthly recurring subscription with HMAC license verification.
  3. examples/03-web-scraper-server.ts — Usage credits with turnkey Dodo checkout webhook.

👉 Get the complete package with instant setup at ritualdev.in/mcp-starter-kit.


📜 License

MIT © RitualDev Lab



💖 Sponsor & Support

If you find this project valuable, consider supporting our open-source development:

[Sponsor on Dodo Payments] [Interactive Donation Portal] [GitHub Sponsors]


🛡️ Community & Governance

Source: README.md at commit f4d97f4

Tools

0
SourceWeft started this package once in an isolated sandbox, without credentials, to list its tools. That failed: the server did not start.

Version history

1
  1. v0.1.3LatestNov 19, 2026

Score

50% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts

Other Engine integrations