sebastienb/weather-mcp
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.
A simple Model Control Protocol (MCP) server that allows LLMs to fetch weather data for US zipcodes using the Open-Meteo API.
Weather MCP Server
A simple Model Control Protocol (MCP) server that allows LLMs to fetch weather data for US zipcodes using the Open-Meteo API.
Overview
This project demonstrates how to build a Model Control Protocol (MCP) server. The MCP protocol allows Large Language Models (LLMs) like Claude to interact with external tools and services.
In this case, the server provides a weather tool that LLMs can use to fetch current weather data for a given US zipcode.
How MCP Works
-
MCP Request Format: The LLM sends a request to the MCP server with the tool it wants to use and the parameters for that tool.
-
Server Processing: The MCP server receives the request, identifies the requested tool, validates the parameters, and calls the appropriate function.
-
Tool Execution: The tool function (in this case, the weather tool) performs its task, such as fetching data from an external API.
-
Response Format: The server formats the response according to the MCP protocol and sends it back to the LLM.
-
LLM Integration: The LLM can then use this response to generate more informed and up-to-date content.
Project Structure
src/index.js
: Main entry point that sets up the Express server and handles MCP requestssrc/tools/weatherTool.js
: Implementation of the weather tool using the Open-Meteo API
API Endpoints
MCP Endpoint
- URL:
/mcp
- Method:
POST
- Body:
{ "tools": [ { "type": "weather_get", "parameters": { "zipcode": "90210" } } ] }
- Response:
{ "outputs": [ { "type": "weather_get", "status": "success", "data": { "zipcode": "90210", "location": "Beverly Hills, CA", "temperature": { "value": 72.3, "unit": "°F" }, "humidity": { "value": 65, "unit": "%" }, "precipitation": { "value": 0, "unit": "inch" }, "wind": { "speed": { "value": 5.3, "unit": "mph" }, "direction": { "value": 270, "unit": "°" } }, "condition": "Clear sky", "timestamp": "2023-11-18T12:00:00Z" } } ] }
Installation
- Clone this repository
- Install dependencies:
npm install
- Start the server:
npm start
Usage with LLMs
To use this MCP server with an LLM like Claude, you would need to:
- Deploy this server somewhere it can be accessed
- Configure the LLM to use this server as an MCP endpoint
- The LLM can then make calls to the weather_get tool to get current weather information
License
MIT