Weather API MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Weather API MCP Serverwhat's the weather forecast for Tokyo this weekend?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Weather API MCP Server
A Model Context Protocol (MCP) server implementation for weather information, providing current weather data and forecasts using the 和风天气 (QWeather) API.
Features
Current Weather: Get current weather data for any location
Weather Forecast: Get 3-day to 30-day weather forecasts
Hourly Forecast: Get 24-hour weather forecasts
City Lookup: Look up city information and IDs for more precise weather data
Customizable Options: Configure units, language, and additional details
Powered by QWeather: Integrates with the 和风天气 (QWeather) API for accurate weather data
Related MCP server: Hefeng QWeather MCP Server
Installation
npm install mcp-weather-apiOr use it directly with npx:
npx mcp-weather-apiAPI Reference
Weather Tools
The server provides four weather tools that can be called through MCP:
1. Get Current Weather
// Tool name: getWeather
{
location: "New York, NY", // Can be city name, coordinates like "119.98,30.24", or QWeather location ID
options: {
units: "metric", // "metric" (Celsius) or "imperial" (Fahrenheit)
language: "en", // Language code (en, zh, etc.)
}
}2. Get Weather Forecast
// Tool name: getWeatherForecast
{
location: "London, UK", // Can be city name, coordinates like "119.98,30.24", or QWeather location ID
options: {
units: "imperial", // "metric" (Celsius) or "imperial" (Fahrenheit)
days: 3, // Supports 3, 7, 10, 15, or 30 days
language: "en" // Language code (en, zh, etc.)
}
}3. Get Hourly Weather Forecast
// Tool name: getHourlyWeather
{
location: "Tokyo, Japan", // Can be city name, coordinates like "119.98,30.24", or QWeather location ID
options: {
units: "metric", // "metric" (Celsius) or "imperial" (Fahrenheit)
hours: 24, // Number of hours (default: 24, max: 24)
language: "ja" // Language code (en, zh, ja, etc.)
}
}4. City Lookup
// Tool name: lookupCity
{
location: "Beijing", // City name or coordinates like "119.98,30.24"
options: {
language: "en" // Language code (en, zh, etc.)
}
}Weather Options
Current weather tool options:
interface WeatherOptions {
units?: "metric" | "imperial"; // Temperature units (default: metric)
language?: string; // Response language code
}Forecast tool options:
interface ForecastOptions {
units?: "metric" | "imperial"; // Temperature units (default: metric)
days?: number; // Number of days (default: 3)
language?: string; // Response language code
}Hourly forecast tool options:
interface HourlyForecastOptions {
units?: "metric" | "imperial"; // Temperature units (default: metric)
hours?: number; // Number of hours (default: 24, max: 24)
language?: string; // Response language code
}City lookup tool options:
interface CityLookupOptions {
language?: string; // Response language code
}Response Format
All tools return responses in the following format:
{
content: Array<{
type: "text";
text: string;
}>;
}Sample Responses
Current Weather Response
Weather for New York:
Observation Time: 2023-11-15T12:30+08:00
Current Conditions: Partly Cloudy (Icon: 101)
Temperature: 18.5°C
Feels Like: 19.2°C
Wind Information:
- Direction: Northeast (45°)
- Scale: 3
- Speed: 15 km/h
Other Information:
- Humidity: 65%
- Precipitation: 0.0 mm
- Pressure: 1013 hPa
- Visibility: 25 km
- Cloud Cover: 30%
- Dew Point: 12.1°C
Updated: 2023-11-15T12:35+08:00
Data Sources: QWeather
License: QWeather Developers LicenseWeather Forecast Response
Weather Forecast for London:
2023-11-15:
Time Information:
- Sunrise: 07:12, Sunset: 16:30
- Moonrise: 15:40, Moonset: 03:25
- Moon Phase: Waxing Gibbous (Icon: 802)
Day Weather:
- Conditions: Rain (Icon: 305)
- Temperature Range: 12.0°F / 7.0°F
- Wind: Northwest (315°)
- Wind Scale: 3, Speed: 18 km/h
Night Weather:
- Conditions: Cloudy (Icon: 101)
- Wind: North (0°)
- Wind Scale: 2, Speed: 10 km/h
Other Information:
- Humidity: 75%
- Precipitation: 5.2 mm
- Pressure: 1008 hPa
- Visibility: 10 km
- Cloud Cover: 85%
- UV Index: 2
...additional days...
Data Sources: QWeather
License: QWeather Developers LicenseCity Lookup Response
Location Information:
1. Beijing (ID: 101010100)
Location: 39.90499, 116.40529
Region: Beijing, Beijing, China
Timezone: Asia/Shanghai (UTC +8.0)
Type: city, Rank: 10
2. Beijing Shi (ID: 101010000)
Location: 39.90998, 116.40529
Region: Beijing, Beijing, China
Timezone: Asia/Shanghai (UTC +8.0)
Type: city, Rank: 10
Note: Use the ID (e.g., "101010100") in other weather tools to get weather information for this location.
Data Sources: QWeather
License: QWeather Developers LicenseUsage with MCP
Add the Weather MCP server to your MCP configuration:
{
"mcpServers": {
"weather": {
"command": "npx",
"args": ["-y", "mcp-weather-api"]
}
}
}QWeather API
This server uses the 和风天气 (QWeather) API to fetch weather data. The API key is included in the package for demo purposes. For production use, you should obtain your own API key from QWeather.
API Endpoints Used
Current Weather -
/weather/nowReturns the current weather conditions
Response includes a
nowobject with temperature, humidity, etc.
Weather Forecast -
/weather/3d,/weather/7d,/weather/10d,/weather/15d,/weather/30dReturns weather forecast for different periods
Response includes a
dailyarray with daily forecast data
Hourly Weather Forecast -
/weather/24hReturns hourly weather forecast for the next 24 hours
Response includes an
hourlyarray with hourly forecast data
City Lookup -
/city/lookupLooks up city information by name or coordinates
Returns city IDs and other location information
API Response Structure
Current Weather (/weather/now)
{
"code": "200",
"updateTime": "2021-11-15T16:35+08:00",
"now": {
"temp": "22.5",
"humidity": "65",
"text": "Partly cloudy",
"windSpeed": "10.2",
"windDir": "East",
"feelsLike": "24.0",
"pressure": "1012",
"vis": "10",
"cloud": "30",
"dew": "15.5"
}
}Weather Forecast (/weather/3d)
{
"code": "200",
"updateTime": "2021-11-15T16:35+08:00",
"fxLink": "http://hfx.link/2ax1",
"daily": [
{
"fxDate": "2021-11-15",
"sunrise": "06:58",
"sunset": "16:59",
"moonrise": "15:16",
"moonset": "03:40",
"moonPhase": "盈凸月",
"moonPhaseIcon": "803",
"tempMax": "12",
"tempMin": "-1",
"iconDay": "101",
"textDay": "多云",
"iconNight": "150",
"textNight": "晴",
"wind360Day": "45",
"windDirDay": "东北风",
"windScaleDay": "1-2",
"windSpeedDay": "3",
"wind360Night": "0",
"windDirNight": "北风",
"windScaleNight": "1-2",
"windSpeedNight": "3",
"humidity": "65",
"precip": "0.0",
"pressure": "1020",
"vis": "25",
"cloud": "4",
"uvIndex": "3"
}
// Additional days...
]
}Hourly Weather Forecast (/weather/24h)
{
"code": "200",
"updateTime": "2021-11-15T16:35+08:00",
"fxLink": "http://hfx.link/2ax1",
"hourly": [
{
"fxTime": "2021-11-15T17:00+08:00",
"temp": "11",
"icon": "150",
"text": "晴",
"wind360": "335",
"windDir": "西北风",
"windScale": "3-4",
"windSpeed": "20",
"humidity": "73",
"pop": "7",
"precip": "0.0",
"pressure": "1013",
"cloud": "10",
"dew": "7"
}
// Additional hours...
]
}City Lookup (/city/lookup)
{
"code": "200",
"location": [
{
"name": "Beijing",
"id": "101010100",
"lat": "39.90499",
"lon": "116.40529",
"adm2": "Beijing",
"adm1": "Beijing",
"country": "China",
"tz": "Asia/Shanghai",
"utcOffset": "+08:00",
"isDst": "0",
"type": "city",
"rank": "10",
"fxLink": "http://hfx.link/2ax1"
}
// Additional locations...
]
}Configuration
You can configure various options through environment variables:
# API Configuration
export QWEATHER_API_KEY=your-api-key
export QWEATHER_API_URL=https://devapi.qweather.com/v7
export QWEATHER_GEO_API_URL=https://geoapi.qweather.com/v2
export WEATHER_DEFAULT_LOCATION=101010100 # Default location code or coordinates
# Default Options
export WEATHER_DEFAULT_UNITS=metric # or 'imperial'
export WEATHER_DEFAULT_LANGUAGE=en # language code
export WEATHER_INCLUDE_DETAILS=true # or 'false'
export WEATHER_FORECAST_DAYS=3 # number of days (max 30)Or in your MCP configuration:
{
"mcpServers": {
"weather": {
"command": "npx",
"args": ["-y", "mcp-weather-api"],
"env": {
"QWEATHER_API_KEY": "your-api-key",
"QWEATHER_API_URL": "https://devapi.qweather.com/v7",
"QWEATHER_GEO_API_URL": "https://geoapi.qweather.com/v2",
"WEATHER_DEFAULT_LOCATION": "101010100",
"WEATHER_DEFAULT_UNITS": "imperial",
"WEATHER_DEFAULT_LANGUAGE": "zh",
"WEATHER_INCLUDE_DETAILS": "true",
"WEATHER_FORECAST_DAYS": "7"
}
}
}
}Location Formats
You can specify locations in three formats:
City name: e.g., "New York", "London", "Beijing"
Coordinates: e.g., "119.98,30.24" (longitude,latitude)
QWeather location ID: e.g., "101010100" (Beijing)
When using coordinates, the format must be longitude,latitude (e.g., "119.98,30.24"), which will be passed directly to the QWeather API.
Use the lookupCity tool to find the appropriate location ID for more precise targeting.
China City Location Codes
For Chinese cities, you can use the QWeather location ID which provides more precise location targeting. The complete list of Chinese city codes can be found in the QWeather LocationList repository.
This CSV file contains location IDs for Chinese cities in the format:
Development
Prerequisites
Node.js 16 or higher
npm or yarn
Setup
Clone the repository
Install dependencies:
npm installBuilding
npm run buildRunning in Development
npm run devAvailable Tools
4 toolsgetHourlyWeatherC
Get hourly weather forecast for a location. Returns weather data hour by hour for the next 24 hours.
| Name | Required | Description | Default |
|---|---|---|---|
| location | No | The location to get hourly weather forecast for (city name, zip code, coordinates, etc.). If not provided, default location will be used. | |
| options | No | Hourly forecast configuration options, all fields are optional |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool returns data for 'the next 24 hours' and implies a default location, but doesn't cover error handling, rate limits, authentication needs, or data freshness. For a weather API tool with zero annotation coverage, this leaves significant gaps in understanding operational behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two concise sentences that efficiently convey the core functionality and scope. Every word earns its place with no redundancy or fluff, making it easy to parse and front-loaded with essential information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no annotations and no output schema, the description is incomplete for a weather forecasting tool. It lacks details on return format (e.g., what data fields are included), error cases (e.g., invalid location), and how it integrates with sibling tools, leaving the agent with insufficient context for reliable use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema fully documents both parameters (location and options with nested fields). The description adds no parameter-specific information beyond what's in the schema, such as format examples for location or default values beyond hours=24. This meets the baseline for high schema coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Get hourly weather forecast for a location' with the specific scope 'hour by hour for the next 24 hours.' It distinguishes from siblings like 'getWeather' (likely current weather) and 'getWeatherForecast' (likely daily forecast) by specifying hourly granularity, though it doesn't explicitly name these alternatives.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus its siblings (getWeather, getWeatherForecast, lookupCity). It mentions the default 24-hour scope but doesn't clarify if this is the only option or how it differs from other forecast tools, leaving the agent to infer usage context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
getWeatherC
Get current weather information for a location. Returns weather data including temperature, humidity, and conditions.
| Name | Required | Description | Default |
|---|---|---|---|
| location | No | The location to get weather for (city name, zip code, coordinates, etc.). If not provided, default location will be used. | |
| options | No | Weather configuration options, all fields are optional |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the tool 'Returns weather data including temperature, humidity, and conditions' which gives some output context, but lacks critical details like whether this is a read-only operation, if it requires authentication, rate limits, error handling, or what happens when location isn't provided (though schema covers this). For a tool with zero annotation coverage, this is insufficient.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two concise sentences that efficiently convey core functionality. First sentence states purpose, second describes return values. No wasted words, though it could be slightly more structured by separating usage guidance from behavior description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 2 parameters with 100% schema coverage but no annotations and no output schema, the description provides basic purpose and return value information. However, for a weather API tool that likely has behavioral considerations (rate limits, authentication needs, error cases), the description should do more to compensate for the lack of structured metadata. It's minimally adequate but has clear gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already fully documents both parameters (location and options with units/language). The description adds no parameter-specific information beyond what's in the schema. Baseline 3 is appropriate when schema does all the parameter documentation work.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Get current weather information for a location' with specific verb ('Get') and resource ('weather information'). It distinguishes from sibling tools by specifying 'current' weather (vs. 'hourly' or 'forecast'), but doesn't explicitly differentiate from 'lookupCity' which might be for location resolution rather than weather data.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance on when to use this tool versus alternatives like getHourlyWeather or getWeatherForecast. The description implies it's for current weather, but doesn't state when to choose it over siblings or mention any prerequisites or exclusions. Usage context is minimal.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
getWeatherForecastB
Get weather forecast for a location. Returns weather forecast for the next few days.
| Name | Required | Description | Default |
|---|---|---|---|
| location | No | The location to get weather forecast for (city name, zip code, coordinates, etc.). If not provided, default location will be used. | |
| options | No | Forecast configuration options, all fields are optional |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the tool 'Returns weather forecast for the next few days' which gives some output information, but doesn't describe error conditions, rate limits, authentication requirements, or what happens when location isn't provided (though the schema covers this). More behavioral context would be helpful for a tool with no annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise with just two sentences that directly state the tool's purpose and what it returns. Every word earns its place with no redundancy or unnecessary elaboration.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with 2 parameters, 100% schema coverage, but no annotations and no output schema, the description provides basic purpose but lacks guidance on sibling tool differentiation and behavioral context. It's minimally adequate but has clear gaps in usage guidance and behavioral transparency that would help an agent use it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema fully documents both parameters. The description doesn't add any parameter semantics beyond what's in the schema - it mentions 'location' and 'forecast for the next few days' but these are already covered. The baseline of 3 is appropriate when the schema does all the parameter documentation work.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Get weather forecast for a location' with the verb 'Get' and resource 'weather forecast'. It distinguishes from 'getHourlyWeather' by specifying 'for the next few days' rather than hourly, but doesn't explicitly differentiate from 'getWeather' or 'lookupCity'.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided about when to use this tool versus the sibling tools 'getHourlyWeather', 'getWeather', or 'lookupCity'. The description mentions 'Returns weather forecast for the next few days' which implies a multi-day forecast, but doesn't explicitly state this is for daily forecasts versus hourly or current weather.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
lookupCityB
Look up city information by name, ID, or coordinates. Returns city ID that can be used with other weather tools.
| Name | Required | Description | Default |
|---|---|---|---|
| location | Yes | The location to look up (city name, coordinates, etc.). Examples: 'London', 'New York', '39.9,116.3' | |
| options | No | Lookup configuration options, all fields are optional |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool returns a city ID, which is useful, but doesn't cover other behavioral traits such as error handling, rate limits, authentication needs, or what happens with ambiguous inputs. For a lookup tool with zero annotation coverage, this leaves significant gaps in understanding its operation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences, front-loaded with the core purpose and followed by a practical note about the return value's use. Every sentence earns its place by adding clarity and utility without any waste or redundancy, making it highly efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's low complexity (a simple lookup), no annotations, no output schema, and high schema coverage, the description is adequate but incomplete. It covers the basic purpose and return usage but lacks details on behavioral aspects like errors or performance, which are important for a tool with no structured safety or output information.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds minimal value beyond the schema by mentioning lookup methods (name, ID, coordinates) and the purpose of the returned ID. It doesn't provide additional syntax, format details, or examples beyond what's in 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.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Look up city information by name, ID, or coordinates.' It specifies the verb ('look up') and resource ('city information'), and mentions multiple lookup methods. However, it doesn't explicitly differentiate from sibling weather tools beyond noting the returned city ID can be used with them, which is helpful but not a full distinction.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage by stating the tool returns a city ID for use with other weather tools, suggesting it's a prerequisite for those siblings. However, it doesn't provide explicit guidance on when to use this tool versus alternatives (e.g., direct weather queries) or any exclusions. The context is clear but lacks detailed alternatives or when-not 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.
4 tool updates
v1.0.0- First observed
getHourlyWeather - First observed
getWeather - First observed
getWeatherForecast - First observed
lookupCity
TDQS
Scored across 4 tools
The tools have overlapping purposes that could cause confusion. getWeather, getHourlyWeather, and getWeatherForecast all retrieve weather data for a location, differing only in time granularity. While descriptions clarify the distinctions, an agent might misselect between them without careful reading. The lookupCity tool is clearly distinct, but the three weather retrieval tools create ambiguity.
Naming is mostly consistent with a verb_noun pattern, though there are minor deviations. getWeather, getHourlyWeather, and getWeatherForecast follow a clear get_<type>Weather pattern, while lookupCity uses a different verb (lookup vs. get). All use camelCase consistently, making them readable despite the verb variation.
Four tools is well-scoped for a weather API server. Each tool earns its place: current weather, hourly forecast, multi-day forecast, and city lookup provide complete coverage without bloat. This count aligns with typical server scopes (3-15 tools) and avoids being too thin or heavy.
The tool set covers core weather API operations effectively, with minor gaps. It includes current conditions, short-term and long-term forecasts, and location lookup, enabling agents to handle most weather queries. However, there are no tools for historical weather data or alerts, which could be useful extensions for the domain.
Maintenance
Related MCP Connectors
Global weather API: forecasts, historical data, marine, ski, astronomy and timezone.
Global weather via Open-Meteo: forecast, historical, marine, air quality, geocoding, elevation.
WeatherAPI.com MCP — wraps WeatherAPI.com (api.weatherapi.com)
Free, keyless real-time weather and 7-day forecasts for any city worldwide.
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides weather forecast data for locations in China through HeFeng Weather API, supporting real-time, hourly, and daily forecasts with full Chinese weather descriptions.312 npmISC
- AlicenseNot gradedqualityBmaintenanceProvides comprehensive weather data including forecasts, air quality, weather alerts, historical data, and astronomical information through the Hefeng Weather API. Supports real-time weather, multi-day forecasts, hourly predictions, and specialized data like sunrise/sunset times and precipitation forecasts.4MIT
- FlicenseNot gradedqualityDmaintenanceProvides weather query capabilities including current weather, daily/hourly forecasts, air quality data, and weather alerts through QWeather API integration with JWT-based authentication.-
- FlicenseNot gradedqualityDmaintenanceEnables querying weather forecasts (1-7 days) and meteorological warnings for Chinese cities using the QWeather API. Supports detailed weather data including temperature, humidity, wind, precipitation, UV index, and real-time weather alerts.2-