weather-mcp

sebastienb/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.

A simple Model Control Protocol (MCP) server that allows LLMs to fetch weather data for US zipcodes using the Open-Meteo API.

Tools
1
Resources
0
Prompts
0

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

  1. 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.

  2. Server Processing: The MCP server receives the request, identifies the requested tool, validates the parameters, and calls the appropriate function.

  3. Tool Execution: The tool function (in this case, the weather tool) performs its task, such as fetching data from an external API.

  4. Response Format: The server formats the response according to the MCP protocol and sends it back to the LLM.

  5. 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 requests
  • src/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

  1. Clone this repository
  2. Install dependencies: npm install
  3. Start the server: npm start

Usage with LLMs

To use this MCP server with an LLM like Claude, you would need to:

  1. Deploy this server somewhere it can be accessed
  2. Configure the LLM to use this server as an MCP endpoint
  3. The LLM can then make calls to the weather_get tool to get current weather information

License

MIT