Skip to main content
Glama

MCP Server Demo

by hxw-haha
server.js920 B
#!/usr/bin/env node import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; // 引入工具 import helloTool from './tools/helloTool.js'; import weatherTool from './tools/weatherTool.js'; import networkTool from './tools/networkTool.js'; const server = new McpServer({ name: "example-mcp-server", version: "1.0.0", }); // 注册工具 - 使用 Zod schema server.tool(helloTool.name, helloTool.description, helloTool.schema, helloTool.handler); server.tool(weatherTool.name, weatherTool.description, weatherTool.schema, weatherTool.handler); server.tool(networkTool.name, networkTool.description, networkTool.schema, networkTool.handler); // 启动 MCP Server(使用 stdio 通信) const transport = new StdioServerTransport(); await server.connect(transport); console.log("✅ MCP Server started successfully.");

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/hxw-haha/mcp-server-demo'

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