Skip to main content
Glama

MCP TypeScript Simple Template

by ChenReuven
index.ts888 B
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { z } from "zod"; const server = new McpServer({ name: "My App", version: "1.0.0" }); // make a echo server tool server.tool( "echo", { text: z.string() }, async ({ text }) => ({ content: [{ type: "text", text }] }) ); server.tool( "calculate-bmi", { weightKg: z.number(), heightM: z.number() }, async ({ weightKg, heightM }) => ({ content: [{ type: "text", text: String(weightKg / (heightM * heightM)) }] }) ); // Start receiving messages on stdin and sending messages on stdout const transport = new StdioServerTransport(); await server.connect(transport); console.log("Server started...");

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/ChenReuven/mcp-ts-simple-template'

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