Weather MCP Tool

Weather MCP Tool

An India-focused MCP server that provides real-time weather conditions, forecasts, air quality data, and location search capabilities using the OpenWeatherMap API.

Category
Visit Server

README

Weather MCP Tool (India-Focused)

An MCP (Model Context Protocol) server using the OpenWeatherMap API to provide:

  • Real-time weather conditions
  • 5-day weather forecasts
  • Air quality data
  • Location search

🚀 Setup

  1. Python 3.10+ is required.
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Get an API key from OpenWeatherMap.
  4. Create a .env file in the root folder:
    OPENWEATHER_API_KEY=your_api_key_here
    

🛠 Available Tools

get_current_weather(location: str)

Returns current weather for a given location.

get_weather_forecast(location: str, days: int = 5)

Returns a weather forecast (up to 5 days) for the location.

get_air_quality(location: str)

Returns air quality metrics and AQI level.

search_location(query: str)

Returns up to 5 location matches based on the query.


🧪 Example Output (India)

Current Weather (Delhi)

{
  "location": {
    "name": "Delhi",
    "country": "IN",
    "lat": 28.6139,
    "lon": 77.2090
  },
  "temperature": {
    "current": 32.4,
    "feels_like": 35.1,
    "min": 30.0,
    "max": 36.2
  },
  "weather_condition": {
    "main": "Haze",
    "description": "smoky haze",
    "icon": "50d"
  },
  "wind": {
    "speed": 4.1,
    "deg": 135
  },
  "clouds": 20,
  "humidity": 58,
  "pressure": 1005,
  "visibility": 5000,
  "sunrise": "2025-03-16T06:20:00",
  "sunset": "2025-03-16T18:40:00",
  "timestamp": "2025-03-16T14:30:00"
}

Weather Forecast (Mumbai)

{
  "location": {
    "name": "Mumbai",
    "country": "IN",
    "lat": 19.0760,
    "lon": 72.8777
  },
  "forecast": [
    {
      "datetime": "2025-03-16T12:00:00",
      "temperature": {
        "temp": 33.2,
        "feels_like": 37.8,
        "min": 31.5,
        "max": 34.0
      },
      "weather_condition": {
        "main": "Clouds",
        "description": "scattered clouds",
        "icon": "03d"
      },
      "wind": {
        "speed": 3.9,
        "deg": 200
      },
      "clouds": 40,
      "humidity": 70,
      "pressure": 1008,
      "visibility": 10000,
      "pop": 0.1
    }
  ],
  "days": 5
}

Air Quality (Bangalore)

{
  "location": {
    "name": "Bengaluru",
    "country": "IN",
    "lat": 12.9716,
    "lon": 77.5946
  },
  "air_quality_index": 2,
  "air_quality_level": "Fair",
  "components": {
    "co": 102.4,
    "no": 0.0,
    "no2": 12.6,
    "o3": 30.5,
    "so2": 3.8,
    "pm2_5": 45.1,
    "pm10": 60.2,
    "nh3": 1.5
  },
  "timestamp": "2025-03-16T14:30:00"
}

Location Search

{
  "results": [
    {
      "name": "Kolkata",
      "state": "West Bengal",
      "country": "IN",
      "lat": 22.5726,
      "lon": 88.3639
    },
    {
      "name": "Kolkata",
      "state": "",
      "country": "IN",
      "lat": 22.5675,
      "lon": 88.3700
    }
  ]
}

🧰 Error Handling

All tools return clear error messages:

{ "error": "Location 'XYZ' not found" }

📌 Notes

  • Ensure .env file is configured correctly.
  • API keys may take time to activate.
  • OpenWeatherMap free tier: 60 API calls per minute.

🧑‍💻 Run the Server

mcp dev main.py

Once running, you can use this server with MCP-compatible clients like Claude Desktop or other automation tools.


Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured