Skip to main content
Glama

Hello MCP Server

by mfang0126
server.tsโ€ข1.59 kB
import { FastMCP } from "fastmcp"; import { z } from "zod"; // Create FastMCP server const server = new FastMCP({ name: "hello-mcp-fargate", version: "1.0.0", }); // Register sayHello tool server.addTool({ name: "sayHello", description: "Greet someone by name", parameters: z.object({ name: z.string().describe("The name of the person to greet"), }), execute: async (args) => { return `Hello, ${args.name}! ๐Ÿ‘‹`; }, }); // Get configuration from environment const PORT = parseInt(process.env.PORT || "3000"); const BEARER_TOKEN = process.env.BEARER_TOKEN || "mcp-secret-token-12345"; // Start HTTP streaming server with stateless mode for containerization server.start({ transportType: "httpStream", httpStream: { host: "0.0.0.0", // Listen on all interfaces for container access port: PORT, endpoint: "/mcp", stateless: true, // Enable stateless mode for containerized deployments authenticate: async (headers) => { // Bearer token authentication const authHeader = headers.authorization || headers.Authorization; if (!authHeader) { throw new Error("Missing Authorization header"); } const token = authHeader.replace("Bearer ", ""); if (token !== BEARER_TOKEN) { throw new Error("Invalid bearer token"); } return true; }, }, }); console.log(`๐Ÿš€ FastMCP Server running on port ${PORT}`); console.log(`๐Ÿ“ MCP endpoint: http://localhost:${PORT}/mcp`); console.log(`๐Ÿ“ SSE endpoint: http://localhost:${PORT}/sse`); console.log(`๐Ÿ“ Stateless mode: enabled`);

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/mfang0126/ts-mcp-fargate-ecs-starter'

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