Monetize MCP tools by charging per tool invocation. You don’t need to build custom UI—if authorization or funding is required, return the assistant message you get from Paywalls so the client can show the link.Documentation Index
Fetch the complete documentation index at: https://docs.paywalls.ai/llms.txt
Use this file to discover all available pages before exploring further.
How it works
- Your MCP server receives a tool call (with inputs).
- Compute the price for this tool run (flat fee or dynamic).
- Call
POST /v1/user/chargewith a stableuserand anIdempotency-Keytied to the tool run. - If
success: true→ perform the tool’s action and return result. - If
success: false→ return the providedmessageverbatim (it already contains the auth/top‑up link).
Quick snippet (manual charge around a tool call)
{ success: false, message }, render the message verbatim (it already contains auth/top‑up UI).
Pricing patterns
- Flat per‑call: e.g., 0.25 per PDF parse.
- Tiered by tool: cheap for simple actions; premium for heavy tools.
- Free allowance + cap: no charge for N runs/day, then charge thereafter.
- Hybrid: combine per‑tool fee with token metering if your tool also calls models.
{ tool, runId, requestId } in metadata to power analytics.
Choosing a mode
- Shared mode (fastest): hosted top‑ups; paywall messages include links automatically. Great for public tools and zero‑setup trials.
- Default mode: your own Stripe/custom rails. Credit users via
POST /user/balance/depositafter your checkout succeeds.
Implementation pattern (Node MCP server)
- Use a stable
runId(e.g., hash of tool name + timestamp + inputs) for theIdempotency-Keyso retries do not double‑charge. - If your tool also calls an LLM, set your client’s
baseURLtohttps://api.paywalls.ai/v1so token usage is metered automatically; the manual charge layers on top.
Identifying the user
- Provide a stable, pseudonymous
userper end‑user. Options:- Require sign‑in to your service and use your internal user id.
- Derive a pseudonymous id from the MCP client’s connection/session if available and persist it server‑side.
- If you can’t include
userin body, sendX‑Paywall‑Userheader.
Handling insufficient funds
- Do not build special UI. When Paywalls returns
success: falsewith amessage, return that message as the tool output. - The message contains the correct authorization or top‑up link for the user.
Advanced flows
- Prepaid/subscriptions: In Default mode, credit accounts after payment using
POST /v1/user/balance/deposit(idempotent). Use manual charges for non‑tokenized actions. - Spend caps: Keep a per‑user daily counter in your server; skip the tool or choose a cheaper variant when the cap is reached.