Skip to main content
Glama

Muni-MCP

by leafsicle
calculate.ts1.07 kB
import { z } from "zod"; import { experimental_PaidMcpAgent as PaidMcpAgent } from "@stripe/agent-toolkit/cloudflare"; export function calculateTool(agent: PaidMcpAgent<Env, any, any>) { const server = agent.server; // @ts-ignore server.tool( "calculate", "This tool performs a calculation on two numbers.", { operation: z.enum(["add", "subtract", "multiply", "divide"]), a: z.number(), b: z.number(), }, async ({ operation, a, b }: { operation: string; a: number; b: number }) => { let result: number; switch (operation) { case "add": result = a + b; break; case "subtract": result = a - b; break; case "multiply": result = a * b; break; case "divide": if (b === 0) return { content: [ { type: "text", text: "Error: Cannot divide by zero", }, ], }; result = a / b; break; default: throw new Error(`Unknown operation: ${operation}`); } return { content: [{ type: "text", text: String(result) }] }; } ); }

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