Skip to main content
Glama

Basic Math MCP Server

by bahfahh
index.js1.62 kB
#!/usr/bin/env node import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { z } from "zod"; /** * Basic Math MCP Server * Provides two mathematical operations: sum and subtraction */ // Create the server instance const server = new McpServer({ name: "basic-math-server", version: "1.0.0" }, { capabilities: { tools: {} } }); // Define the sum tool server.tool("sum", "Add two numbers together", { a: z.number().describe("First number"), b: z.number().describe("Second number") }, async ({ a, b }) => { const result = a + b; return { content: [ { type: "text", text: `The sum of ${a} and ${b} is: ${result}` } ] }; }); // Define the subtraction tool server.tool("subtraction", "Subtract the second number from the first number", { a: z.number().describe("First number (minuend)"), b: z.number().describe("Second number (subtrahend)") }, async ({ a, b }) => { const result = a - b; return { content: [ { type: "text", text: `The subtraction of ${b} from ${a} is: ${result}` } ] }; }); // Start the server async function main() { const transport = new StdioServerTransport(); await server.connect(transport); console.error("Basic Math MCP Server is running on stdio"); } main().catch((error) => { console.error("Server error:", error); process.exit(1); }); //# sourceMappingURL=index.js.map

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/bahfahh/mcptest'

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