Weather & Location 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 & Location MCP Server get current weather in Paris"
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 & Location MCP Server
A beginner-friendly MCP server built with TypeScript, Node.js, the MCP TypeScript SDK, OpenWeather API, dotenv, and zod.
Features
getCurrentWeather(city)getForecast(city)getAirQuality(city)Sunrise and sunset information
Environment variable support with
dotenvInput validation with
zodTypeScript response types for API data
Helpful error handling
Related MCP server: Weather MCP Server
Tech Stack
TypeScript
Node.js
@modelcontextprotocol/sdkOpenWeather API
dotenvzod
Project Structure
weather-location-mcp-server/
|- src/
| |- index.ts
| |- weatherApi.ts
| `- types.ts
|- .env.example
|- .gitignore
|- package.json
|- README.md
`- tsconfig.jsonSetup
1. Install dependencies
npm install2. Create your environment file
Create a .env file in the project root:
OPENWEATHER_API_KEY=your_api_key_hereYou can copy from .env.example and replace the placeholder value with your real OpenWeather API key.
3. Build the project
npm run buildRun the Server
Development mode
npm run devProduction build
npm run build
npm run startThe server runs over stdio, so it will wait quietly for an MCP client to connect.
Available Tools
getCurrentWeather
Input:
{
"city": "Delhi"
}Returns:
City name
Country
Weather condition and description
Temperature
Feels-like temperature
Humidity
Sunrise time
Sunset time
getForecast
Input:
{
"city": "Delhi"
}Returns:
City name
Country
First 5 forecast entries
Temperature
Weather condition and description
getAirQuality
Input:
{
"city": "Delhi"
}Returns:
AQI value
AQI label
CO
NO2
O3
PM2.5
PM10
Using with Codex
If you want Codex to use this server as an MCP tool provider, add a project config file at .codex/config.toml:
[mcp_servers.weather_location]
command = "node"
args = ["dist/index.js"]
cwd = "D:\\My PC\\Coding\\web development\\Weather & Location MCP Server"
enabled = true
startup_timeout_sec = 20
tool_timeout_sec = 60Then restart Codex or open a new thread in the project.
Notes
Keep
.envout of GitHub because it contains your API key.Keep
.codex/out of GitHub if it contains your personal local Codex setup.This project uses Node.js native
fetch.
License
ISC
Available Tools
3 toolsgetAirQualityGet Air QualityB
Get air quality information for a city
Inputs: city (required).
getCurrentWeatherGet Current WeatherC
Get the current weather for a city
Inputs: city (required).
getForecastGet ForecastC
Get a weather forecast for a city
Inputs: city (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool returns a distinct type of weather information (air quality, current weather, forecast), so an agent can easily select the correct one without ambiguity.
All tool names follow a consistent 'get' + noun pattern in camelCase (getAirQuality, getCurrentWeather, getForecast), making them predictable and easy to remember.
Three tools is a well-scoped set for a weather service, covering the most common queries without being overly sparse or bloated.
The set covers the essential weather operations (current, forecast, air quality). One could argue for additional tools like weather alerts or historical data, but the core is complete.
Maintenance
Related MCP Connectors
Weather forecast for any city, UV index, sunrise and sunset, pollen and air quality. Free, no key.
Free, keyless real-time air quality (US AQI plus PM2.5, PM10, ozone, NO2, SO2, CO) for any city.
Global weather via Open-Meteo: forecast, historical, marine, air quality, geocoding, elevation.
Weather, air quality and nearest live sensors anywhere, each with a signed receipt. Free, no key.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides access to real-time weather data, 5-day forecasts, and air quality information for any city using the OpenWeatherMap API.MIT
- AlicenseNot gradedqualityDmaintenanceProvides access to real-time weather data, 5-day forecasts, air quality information, and weather comparisons across multiple cities using the free OpenWeatherMap API.MIT
- AlicenseNot gradedqualityDmaintenanceEnables querying real-time weather and 5-day forecasts for any city using the OpenWeatherMap API.8 npm5MIT
- FlicenseNot gradedqualityDmaintenanceProvides weather data, forecasts, air quality, and location services via OpenWeatherMap API integration.13-