Skip to main content
Glama

Muni-MCP

by leafsicle
meteredAdd.ts1.06 kB
import { z } from "zod"; import { experimental_PaidMcpAgent as PaidMcpAgent } from "@stripe/agent-toolkit/cloudflare"; import { METERED_TOOL_PAYMENT_REASON } from "../helpers/constants"; export function meteredAddTool( agent: PaidMcpAgent<Env, any, any>, env?: { STRIPE_METERED_PRICE_ID: string; BASE_URL: string } ) { const priceId = env?.STRIPE_METERED_PRICE_ID || null; const baseUrl = env?.BASE_URL || null; if (!priceId || !baseUrl) { throw new Error("No env provided"); } agent.paidTool( "metered_add", "Adds two numbers together for metered usage.", { a: z.number(), b: z.number() }, async ({ a, b }: { a: number; b: number }) => ({ content: [{ type: "text", text: String(a + b) }], }), { checkout: { success_url: `${baseUrl}/payment/success`, line_items: [ { price: priceId, }, ], mode: 'subscription', }, meterEvent: "metered_add_usage", paymentReason: "METER INFO: Your first 3 additions are free, then we charge 10 cents per addition. " + METERED_TOOL_PAYMENT_REASON, } ); }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/leafsicle/muni-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server