Skip to main content
Glama
Meloyg

MCP Weather Server

by Meloyg
index.ts1.75 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { weatherToolSchema, getWeatherTool } from "../tools/weather-tool.js"; export class WeatherMcpServer { private server: McpServer; constructor() { console.error("[WeatherMcpServer] Initializing MCP Weather Server..."); this.server = new McpServer({ name: "MCP Weather Server", version: "1.0.0", description: "A simple weather server for MCP", }); console.error("[WeatherMcpServer] MCP Server instance created"); this.setupTools(); } private setupTools(): void { console.error("[WeatherMcpServer] Setting up tools..."); this.server.tool( "get-weather", "Tool to get the current weather for a given city", weatherToolSchema, getWeatherTool ); console.error("[WeatherMcpServer] Registered tool: get-weather"); console.error("[WeatherMcpServer] Tool setup completed"); } public async start(): Promise<void> { console.error("[WeatherMcpServer] Starting server connection..."); const transport = new StdioServerTransport(); console.error("[WeatherMcpServer] Created StdioServerTransport"); await this.server.connect(transport); console.error( "[WeatherMcpServer] ========================================" ); console.error( "[WeatherMcpServer] MCP Weather Server is running and ready!" ); console.error("[WeatherMcpServer] Available tools: get-weather"); console.error( "[WeatherMcpServer] Listening for MCP connections via stdio..." ); console.error( "[WeatherMcpServer] ========================================" ); } }

Latest Blog Posts

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/Meloyg/life-assitant-mcp'

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