weather-mcp

SkyH34D/weather-mcp

3.2

If you are the rightful owner of weather-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

Weather MCP Server is a TypeScript-based implementation of a Model Context Protocol (MCP) server that provides daily weather forecasts for any city using Open-Meteo APIs.

Tools
1
Resources
0
Prompts
0

šŸŒ¤ļø Weather MCP Server

Weather MCP Server is a TypeScript-based implementation of a Model Context Protocol (MCP) server. It provides a streamlined interface to retrieve daily weather forecasts for any city using public APIs from Open-Meteo.

This project serves as a clear example of how MCP servers can expose custom tools that integrate with external APIs, providing structured data to MCP clients.


✨ Key Features

FeatureDescription
MCP IntegrationUses @modelcontextprotocol/sdk for seamless MCP handling.
Zod ValidationRuntime validation of tool parameters.
Stdio TransportCommunicates through standard input/output streams.
External APIsFetches real-time weather data using Open-Meteo APIs.

šŸ“‹ Requirements

  • Node.js ≄ 18 (ESM & top-level await support)
  • npm, yarn, or pnpm for dependency management

šŸš€ Quick Start

Installation

git clone https://github.com/yourusername/weather-mcp-server.git
cd weather-mcp-server

# Install dependencies
npm install # or yarn install / pnpm install

Run the Server

npm run start # or use your preferred method (e.g., ts-node main.ts)

The server listens on standard input/output for MCP messages.

Example Tool Call

Request:

{
  "tool": "fetch-weather",
  "params": { "city": "Madrid" }
}

Response:

{
  "content": [
    {
      "type": "text",
      "text": "{\n  \"daily\": {\n    \"temperature_2m_max\": [26.4],\n    \"temperature_2m_min\": [15.1]\n  }\n}"
    }
  ]
}

šŸ—‚ļø Project Structure

weather-mcp-server/
ā”œā”€ā”€ main.ts              # Entry point for the MCP server
ā”œā”€ā”€ package.json
ā”œā”€ā”€ pnpm-lock.yaml
└── node_modules/

āš™ļø How It Works

The MCP Server operates through the following process:

  1. Initialization: MCP Server is instantiated with a name and version.
  2. Tool Definition: Tools are defined with unique identifiers, descriptions, parameter schemas validated by Zod, and asynchronous handlers.
  3. API Integration: When invoked, fetch-weather calls Open-Meteo APIs to obtain geographic and weather data for a city.
  4. Communication: Utilizes StdioServerTransport for communication between the server and MCP clients.

🚧 TODO / Future Ideas

  • Integrate additional APIs for extended functionalities (e.g., timezone, air quality).
  • Expand transport capabilities (e.g., WebSockets, HTTP).
  • Implement comprehensive test suites.

šŸ“„ License

MIT License. See for more information.