Weather & Location MCP Server

Weather & Location MCP Server

Provides weather and air quality information for cities using OpenWeather API.

Category
Visit Server

README

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 dotenv
  • Input validation with zod
  • TypeScript response types for API data
  • Helpful error handling

Tech Stack

  • TypeScript
  • Node.js
  • @modelcontextprotocol/sdk
  • OpenWeather API
  • dotenv
  • zod

Project Structure

weather-location-mcp-server/
|- src/
|  |- index.ts
|  |- weatherApi.ts
|  `- types.ts
|- .env.example
|- .gitignore
|- package.json
|- README.md
`- tsconfig.json

Setup

1. Install dependencies

npm install

2. Create your environment file

Create a .env file in the project root:

OPENWEATHER_API_KEY=your_api_key_here

You can copy from .env.example and replace the placeholder value with your real OpenWeather API key.

3. Build the project

npm run build

Run the Server

Development mode

npm run dev

Production build

npm run build
npm run start

The 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 = 60

Then restart Codex or open a new thread in the project.

Notes

  • Keep .env out 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

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
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

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