Weather MCP Server

Weather MCP Server

Enables AI assistants to fetch current weather conditions and forecasts for any city using the Open-Meteo API. Provides temperature, precipitation, and hourly forecast data through natural language queries.

Category
Visit Server

README

Practice MCP JS

A Model Context Protocol (MCP) server implementation in TypeScript that provides weather information tools for AI assistants.

Description

This project demonstrates how to create an MCP server that exposes weather-related tools to Large Language Models (LLMs). The server provides a fetch-weather tool that retrieves current weather data and forecasts for any city using the Open-Meteo API.

Features

  • Weather Tool: Fetch current weather conditions and forecasts for any city
  • Input Validation: Uses Zod for robust input/output validation
  • MCP Protocol: Compatible with AI assistants that support the Model Context Protocol
  • TypeScript: Fully typed implementation for better development experience

Prerequisites

  • Node.js (version 14 or higher)
  • npm or yarn package manager

Installation

  1. Clone the repository:
git clone <repository-url>
cd practice-mcp-js
  1. Install dependencies:
npm install

Usage

Running the Server

To start the MCP server:

npx tsx main.ts

The server will start and listen for MCP connections via stdio transport.

Available Tools

fetch-weather

Retrieves weather information for a specified city.

Parameters:

  • city (string): Name of the city to get weather information for

Example Response: The tool returns current weather conditions including:

  • Temperature
  • Precipitation
  • Day/night status
  • Rain information
  • Hourly forecast data

Project Structure

practice-mcp-js/
├── main.ts           # Main server implementation
├── package.json      # Project configuration and dependencies
├── package-lock.json # Dependency lock file
└── README.md         # This file

Dependencies

  • @modelcontextprotocol/sdk: Core MCP SDK for server implementation
  • zod: Schema validation library for input/output validation

API Integration

This project integrates with the following external APIs:

  1. Open-Meteo Geocoding API: For converting city names to coordinates
  2. Open-Meteo Weather API: For retrieving weather data and forecasts

How It Works

  1. The server creates an MCP server instance with the name "PRO INDUSTRIAL MCP SERVER"
  2. It defines a fetch-weather tool that:
    • Accepts a city name as input
    • Geocodes the city name to get coordinates
    • Fetches weather data using the coordinates
    • Returns formatted weather information
  3. The server connects via stdio transport for communication with AI assistants

Development

The main server logic is implemented in main.ts:7-55. Key components include:

  • Server initialization (main.ts:7-10)
  • Tool definition (main.ts:13-50)
  • Transport setup (main.ts:54-55)

Error Handling

The weather tool includes error handling for:

  • Cities that cannot be found
  • API request failures
  • Invalid input parameters (via Zod validation)

License

ISC

Contributing

This is a practice project for learning MCP server development. Feel free to fork and experiment with additional tools and features.

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