WeatherAPI MCP Server: Real-Time Weather Data for Claude AI

Anthropic’s Model Context Protocol (MCP) has revolutionized how AI assistants interact with external data sources. Today, we’re excited to announce the official WeatherAPI MCP server, enabling Claude Desktop to access real-time weather data from our API that serves over 850,000 developers worldwide.

What is the WeatherAPI MCP Server?

The WeatherAPI MCP server is a bridge that allows Claude AI to fetch live weather data, forecasts, and historical information directly through conversational queries. Instead of manually making API calls or writing scripts, you can simply ask Claude questions like “What’s the weather in Tokyo?” or “Show me the 7-day forecast for New York” and get instant, accurate responses.

This integration leverages WeatherAPI’s comprehensive dataset covering 4 million+ locations across 200+ countries, providing everything from current conditions to 14-day forecasts, historical data back to 2010, marine conditions, astronomy data, and severe weather alerts.

Installation and Setup

Getting started with the WeatherAPI MCP server is straightforward. First, install the package via npm:

npm install weatherapi-mcp

Next, you’ll need to configure Claude Desktop to use the MCP server. Add the following configuration to your Claude Desktop settings:

{
  "mcpServers": {
    "weatherapi": {
      "command": "npx",
      "args": ["weatherapi-mcp"],
      "env": {
        "WEATHERAPI_KEY": "your_api_key_here"
      }
    }
  }
}

Don’t have an API key yet? Sign up for free and get 100,000 API calls per month with no credit card required.

Available Functions and Capabilities

The MCP server exposes several powerful functions that Claude can use:

  • Current Weather: Real-time weather conditions including temperature, humidity, wind speed, and more
  • Weather Forecast: Up to 14-day forecasts with hourly breakdowns
  • Historical Weather: Access weather data from any date since 2010
  • Location Search: Find weather stations and locations worldwide
  • Astronomy Data: Sunrise, sunset, moon phases, and astronomical information
  • Marine Conditions: Tides, wave height, and marine weather data

Example Usage Scenarios

Once configured, you can interact with Claude naturally:

“What’s the current weather in London, UK?”

Claude will automatically call the appropriate MCP function and return formatted weather information including temperature, conditions, humidity, wind speed, and more.

“Give me a 3-day forecast for San Francisco with hourly details”

The assistant will fetch detailed forecast data and present it in an easy-to-read format, perfect for planning activities or travel.

Technical Implementation

The MCP server is built on Node.js and implements the MCP specification for seamless integration with Claude Desktop. Under the hood, it makes HTTP requests to WeatherAPI’s REST endpoints and formats the responses for optimal AI consumption.

Here’s how the current weather function works internally:

async function getCurrentWeather(location) {
  const response = await fetch(
    `https://api.weatherapi.com/v1/current.json?key=${API_KEY}&q=${location}&aqi=yes`
  );
  const data = await response.json();
  
  return {
    location: data.location.name,
    country: data.location.country,
    temperature: data.current.temp_c,
    condition: data.current.condition.text,
    humidity: data.current.humidity,
    wind_speed: data.current.wind_kph,
    air_quality: data.current.air_quality
  };
}

The server handles error cases gracefully, validates input parameters, and ensures Claude receives clean, structured data that can be easily interpreted and presented to users.

Benefits for Developers

This MCP integration offers several advantages:

  1. Natural Language Interface: No need to remember API endpoints or parameter formats
  2. Contextual Queries: Ask complex questions combining multiple data points
  3. Automatic Formatting: Claude presents data in human-readable formats
  4. Rapid Prototyping: Test weather-related features without writing integration code
  5. Data Analysis: Combine weather data with other information sources seamlessly

Getting Started

Ready to enhance your Claude Desktop experience with real-time weather data? Here’s what you need to do:

  1. Create your free WeatherAPI account
  2. Install the MCP server: npm install weatherapi-mcp
  3. Configure Claude Desktop with your API key
  4. Start asking Claude about weather conditions anywhere in the world

For detailed setup instructions and troubleshooting, check out our comprehensive documentation and explore code examples in our GitHub repository.

The WeatherAPI MCP server represents a significant step forward in making weather data more accessible through AI assistants. Whether you’re planning a trip, analyzing climate patterns, or building weather-aware applications, this integration streamlines your workflow and puts powerful weather insights at your fingertips through natural conversation.

Scroll to Top