Skip to main content
Glama
nandarizkika

mcp-weather-server

by nandarizkika

MCP Weather Server

A Model Context Protocol (MCP) server that provides weather information and forecasts using the OpenWeatherMap API.

Features

  • 🌀️ Get current weather conditions for any city

  • πŸ“… Get 5-day weather forecasts

  • 🌑️ Temperature, humidity, wind speed, and atmospheric pressure

  • ☁️ Weather descriptions and conditions

  • 🌍 Works with cities worldwide

Related MCP server: OpenWeatherMap MCP Server

Tools Available

get_weather

Get current weather conditions for a specified location.

Parameters:

  • location (required): City name (e.g., "London", "Jakarta", "New York")

Example: "What's the weather in Jakarta?"

get_weather_forecast

Get a 5-day weather forecast for a specified location.

Parameters:

  • location (required): City name

  • days (optional): Number of days to forecast (1-5, default: 5)

Example: "What's the 5-day forecast for London?"

Prerequisites

  • Python 3.7+

  • OpenWeatherMap API key (free tier available)

  • Claude Desktop application

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/mcp-weather-server.git
    cd mcp-weather-server
  2. Create a virtual environment:

    python -m venv .venv
    .venv\Scripts\activate  # On Windows
    # or
    source .venv/bin/activate  # On macOS/Linux
  3. Install dependencies:

    pip install -r requirements.txt
  4. Get an API key:

  5. Set up environment variables:

    • Copy .env.example to .env

    • Add your API key to the .env file:

      OPENWEATHER_API_KEY=your_api_key_here

Configuration

Claude Desktop Setup

  1. Locate your Claude Desktop config file:

    • Windows: %APPDATA%\Claude\claude_desktop_config.json

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

    • Linux: ~/.config/Claude/claude_desktop_config.json

  2. Add the weather server configuration:

    {
      "mcpServers": {
        "weather": {
          "command": "path/to/your/project/.venv/Scripts/python.exe",
          "args": ["path/to/your/project/minimal_weather_server.py"],
          "env": {
            "OPENWEATHER_API_KEY": "your_api_key_here"
          }
        }
      }
    }
  3. Restart Claude Desktop

Testing

Test the server independently:

python test_minimal.py

Or test specific functionality:

python debug_server.py

Usage Examples

Once configured with Claude Desktop, you can ask natural language questions:

  • "What's the weather in Jakarta?"

  • "Get me the current weather for London"

  • "What's the 5-day forecast for Tokyo?"

  • "How's the weather in Singapore today?"

  • "Show me the weather forecast for Bandung"

Project Structure

mcp-weather-server/
β”œβ”€β”€ minimal_weather_server.py    # Main MCP server
β”œβ”€β”€ simple_weather_server.py     # Alternative simple server
β”œβ”€β”€ weather_server.py           # Original MCP library version
β”œβ”€β”€ test_minimal.py             # Test script
β”œβ”€β”€ debug_server.py             # Debug utilities
β”œβ”€β”€ requirements.txt            # Python dependencies
β”œβ”€β”€ .env.example               # Environment template
β”œβ”€β”€ .env                      # Environment variables (not in git)
β”œβ”€β”€ .gitignore               # Git ignore rules
└── README.md               # This file

API Reference

This server uses the OpenWeatherMap API to fetch weather data.

Troubleshooting

Common Issues

  1. "API key not found" error:

    • Ensure your .env file contains OPENWEATHER_API_KEY=your_actual_key

    • Verify the API key is valid and active

  2. "Server disconnected" in Claude:

    • Check that file paths in the config are correct

    • Ensure Python executable path is accurate

    • Restart Claude Desktop after config changes

  3. "Location not found" error:

    • Try using different city name variations

    • Include country name for ambiguous cities (e.g., "London, UK")

Debug Steps

  1. Test the server independently:

    python test_minimal.py
  2. Check server logs in Claude Desktop

  3. Verify API key permissions at OpenWeatherMap

Contributing

  1. Fork the repository

  2. Create a feature branch (git checkout -b feature/amazing-feature)

  3. Commit your changes (git commit -m 'Add amazing feature')

  4. Push to the branch (git push origin feature/amazing-feature)

  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • OpenWeatherMap for providing the weather API

  • Anthropic for Claude and the MCP specification

  • MCP community for protocol documentation and examples

Support

If you encounter any issues or have questions:

  1. Check the troubleshooting section

  2. Review OpenWeatherMap API docs

  3. Open an issue on GitHub


Made with ❀️ for the MCP community

Available Tools

2 tools
get_weatherC

Get current weather for a location

ParametersJSON Schema
NameRequiredDescriptionDefault
locationYesCity name (e.g., 'London', 'New York')

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description carries full burden. It fails to disclose behavioral traits like authentication, rate limits, or whether it returns cached data. Only states basic function.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence of 6 words, highly concise and front-loaded. However, lacks any structuring like bullet points or sections.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a simple tool with one parameter and no output schema. Could be improved by mentioning what data is returned (e.g., temperature, conditions).

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with clear parameter description. The tool description adds no additional meaning beyond the schema, meeting the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states 'Get current weather for a location', specifying the verb and resource. The sibling get_weather_forecast implies distinction, but the description does not explicitly differentiate.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus the sibling tool or any alternatives. No usage context or exclusions provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_weather_forecastC

Get 5-day weather forecast for a location

ParametersJSON Schema
NameRequiredDescriptionDefault
daysNoNumber of days to forecast (1-5)
locationYesCity name (e.g., 'London', 'New York')

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided. Description lacks behavioral details such as data freshness, authentication needs, or rate limits. Only states basic operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence is concise and front-loaded with the main action. However, it is terse and could include return value hints without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no output schema, description does not explain what the forecast contains (e.g., temperature, precipitation). Schema handles input but output remains underspecified.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema already documents both parameters with descriptions (100% coverage). Description adds no extra meaning beyond the schema for the location parameter and days range.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states 'Get 5-day weather forecast for a location', specifying verb and resource. However, it does not explicitly differentiate from sibling tool 'get_weather', leaving ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like sibling 'get_weather'. Missing context for deployment scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updatesv0.1.0
    • First observedget_weather
    • First observedget_weather_forecast

TDQS

B3.3/5.0

Scored across 2 tools

Disambiguation5/5

Both tools are clearly distinct: one provides current weather, the other provides a 5-day forecast. There is no overlap or ambiguity.

Naming Consistency5/5

Both tools follow a consistent 'get_weather' prefix pattern, with a clear modifier for the forecast variant. Naming is uniform and predictable.

Tool Count4/5

With only 2 tools, the server is minimal but covers the core functionality of a weather service. It is slightly on the thin side but reasonable for a focused server.

Completeness3/5

The server covers current weather and forecast, which are the most common needs, but lacks additional features like historical data or weather alerts. It is somewhat incomplete for a full weather API.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers