weather-mcp
Click on "Install 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-mcpWhat's the 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 MCP Server
A Model Context Protocol (MCP) server that provides current weather information by integrating geocoding and weather data APIs. This project serves as an expanded example of an MCP server, building on the examples shown in the official TypeScript SDK. This project shows a server in the context of TypeScript tooling.
Features
Current Weather Service: Combines geocoding and weather data fetching into a single MCP tool
Location Flexibility: Supports city names with optional state and country parameters
Unit Preferences: Automatically detects locale preferences or allows manual unit specification
TypeScript Tooling: Includes build, linting, and type checking setup
MCP Compliance: Implements the Model Context Protocol for seamless integration with MCP clients
Related MCP server: Weather MCP Server
Architecture
This MCP server demonstrates several key concepts:
Multi-API Integration: The
currentWeatherfunction orchestrates two external API calls:OpenWeatherMap Geocoding API to convert location names to coordinates
OpenWeatherMap Current Weather API to fetch weather data
Smart Defaults: Automatically determines preferred units based on system locale (imperial for US, metric for others)
Error Handling: Graceful error handling with JSON error responses
TypeScript Best Practices: Full TypeScript setup with strict linting rules and proper module resolution
Installation
Prerequisites
Node.js >= 22
npm >= 11
OpenWeatherMap API key
Setup
Clone and install dependencies:
git clone <repository-url> cd weather-mcp npm installGet an OpenWeatherMap API key:
Visit OpenWeatherMap
Sign up for a free account
Generate an API key
Build the project:
npm run buildImportant: You must run
npm run buildbefore using the server or after making any changes to the source code.
Cursor Configuration
To use this MCP server with Cursor, add the following to your mcp.json configuration file:
{
"mcpServers": {
"weather-mcp": {
"command": "node",
"args": ["/path/to/weather-mcp/dist/esm/server.js"],
"env": {
"OPEN_WEATHER_API_KEY": "your_api_key_here"
}
}
}
}Replace /path/to/weather-mcp with the actual path to your weather-mcp directory and add your
actual API key.
For more information, see Cursor documentation.
Usage
The server provides one tool:
currentWeather
Fetches current weather data for a given location.
Development
Available Scripts
npm run build: Clean and build the project (types + ESM)npm run clean: Remove build artifactsnpm run typecheck: Run TypeScript type checking
Project Structure
src/
├── server.ts # MCP server setup and tool registration
├── functions.ts # Weather API integration logic
dist/
├── esm/ # Compiled JavaScript (ES modules)
└── types/ # TypeScript declaration filesCode Quality
The project includes ESLint configuration with:
TypeScript-specific rules
Import/export practices
Code style enforcement
Error prevention rules
Potential Improvements
Better Cross-Platform Locale Detection
The current locale detection using execSync('locale') is Unix-specific and may not work reliably
or at all on Windows. Consider implementing a more robust cross-platform solution. Keep an eye on
how Intl API functions in Node.js
Unit Testing
The project currently lacks unit tests. Consider adding:
Unit tests for the
currentWeatherfunctionMock API responses for testing
Error handling scenarios
Edge cases (invalid cities, API failures)
Additional Features
Weather forecast functionality
Historical weather data
Multiple weather providers for redundancy
Caching to reduce API calls
More granular location support (coordinates, postal codes)
OpenWeatherMap APIs Used
Geocoding API:
http://api.openweathermap.org/geo/1.0/directCurrent Weather API:
https://api.openweathermap.org/data/2.5/weather
Both APIs require the OPEN_WEATHER_API_KEY environment variable.
Links
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/JeffreyRuder/weather-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server