Thanks to visit codestin.com
Credit goes to github.com

Skip to content

zkjon/mcp-weather

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

MCP Weather Server 🌀️

A Model Context Protocol (MCP) server that provides real-time weather information using the Open-Meteo API.

πŸ“‹ Description

This project implements an MCP server that allows AI models to obtain current weather information for any location worldwide. The server uses Open-Meteo's free APIs for geocoding and weather data.

πŸ” Documentation

Check out the documentation for more details on how to work with this server.

✨ Features

  • 🌍 Global coverage: Get weather information from any location worldwide
  • πŸ”„ Real-time data: Up-to-date weather information
  • πŸ“Š Complete data: Temperature, humidity, precipitation, wind, cloud cover
  • πŸš€ Fast and efficient: Quick responses with structured JSON data
  • πŸ”§ Easy integration: Compatible with any MCP client

πŸ› οΈ Installation

Prerequisites

  • Bun (recommended) or Node.js 20+

Installation Steps

  1. Clone the repository

    git clone https://github.com/zkjon/mcp-weather.git
    cd mcp-weather
  2. Install dependencies

    bun install
    # or
    npm install
  3. Run the server

    bunx -y tsx src/main.ts
    # or
    npx -y tsx src/main.ts

πŸš€ Usage

MCP Configuration

To use this server with an MCP client, add the following configuration to your mcp.json file:

{
    "mcpServers": {
        "Weather": {
            "command": "bunx",
            "args": [
                "-y",
                "tsx",
                "C:\\full\\path\\to\\project\\src\\main.ts"
            ]
        }
    }
}

Available Tools

get-weather

Gets weather information for a specific location.

Parameters:

  • location (string): Location name (city, country, etc.)

Usage Example:

// Request
{
    "tool": "get-weather",
    "arguments": {
        "location": "Madrid"
    }
}

// Response
{
    "content": [
        {
            "type": "text",
            "text": "{
                \"latitude\": 40.4375,
                \"longitude\": -3.6875,
                \"current\": {
                    \"temperature_2m\": 18.7,
                    \"relative_humidity_2m\": 54,
                    \"precipitation\": 0,
                    \"rain\": 0,
                    \"cloud_cover\": 4,
                    \"wind_speed_10m\": 6.1
                }
            }"
        }
    ]
}

Workflow

  1. Request reception: Server receives a request with a location
  2. Geocoding: Location coordinates are obtained using Open-Meteo API
  3. Weather query: Weather data is queried using the coordinates
  4. Structured response: Data is returned in structured JSON format

Code Structure

  • Imports: MCP SDK and necessary libraries
  • Server configuration: MCP server definition with name and version
  • Tool definition: Implementation of the get-weather tool
  • Connection: Transport configuration and server connection

🌐 APIs Used

πŸ“ License

This project is licensed under the MIT License. See the LICENSE file for more details.

🀝 Contributing

Contributions are welcome! Please read our contribution guide for more information.

πŸ”’ Security

If you find any security vulnerability, please check our security file to know how to report it.

πŸ“ž Support

If you have questions or need help:

  • πŸ› Report bugs: Issues
  • πŸ’‘ Request features: Issues
  • πŸ“§ Contact: zkjon

πŸ™ Acknowledgments


Made with ❀️ by zkjon

About

MCP server to get the weather from a location

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks