MCP
Charge per call for MCP tools.
Pre-release · planned API
In development
This adapter is being implemented against the core v2 contract. The example below shows the intended shape and may change.
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { withTollstile } from "@tollstile/mcp";
import { toll } from "./toll";
const server = withTollstile(new McpServer({ name: "images", version: "1.0.0" }), toll);
server.tool("generate_image", toll.price("$0.04"), async (input, { payment }) => {
return generateImage(input);
});Free tools stay free: only tools registered with a price are guarded.
Metered tools
For tools whose cost is known only after they run, authorize a ceiling and settle what was used.
server.tool(
"render_video",
toll.price(upTo("$0.50")),
async (input, { payment }) => {
const video = await render(input);
await payment.fulfill({ amount: costOf(video) });
return video;
},
);