Skip to main content
Glama
lmanchu

Weather MCP Server

by lmanchu

Weather MCP Server - Sample Implementation

Reference implementation for ASUS and OEM partners

A simple, production-ready MCP server demonstrating how to integrate external services with AI PCs using the Model Context Protocol.

License: MIT Node.js Version MCP SDK


๐ŸŽฏ Purpose

This sample MCP server demonstrates:

  • โœ… How to create an MCP server from scratch

  • โœ… How to expose tools (functions) to AI clients

  • โœ… How to integrate external APIs (OpenWeather API)

  • โœ… Production-ready error handling

  • โœ… Clean, well-documented code

Perfect for: OEM partners building AI PC features, developers learning MCP, proof-of-concept projects


Related MCP server: Weather MCP Server

๐ŸŒŸ Features

Available Tools

  1. get_current_weather - Get real-time weather for any city

    • Temperature, conditions, humidity, wind speed

    • Supports both Celsius and Fahrenheit

  2. get_weather_forecast - Get 5-day forecast

    • Daily high/low temperatures

    • Weather conditions per day


๐Ÿš€ Quick Start

Prerequisites

  • Node.js >= 18.0.0

  • OpenWeather API key (free tier available)

Installation

# Clone or download this repository
cd weather-mcp-server

# Install dependencies
npm install

# Configure API key
cp .env.example .env
# Edit .env and add your OpenWeather API key

Get API Key

  1. Visit OpenWeather API

  2. Sign up for free account

  3. Generate API key

  4. Add to .env file

Run the Server

# Start the server
npm start

# Or with auto-reload during development
npm run dev

๐Ÿ“– Usage Examples

Configure in Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "weather": {
      "command": "node",
      "args": ["/absolute/path/to/weather-mcp-server/index.js"],
      "env": {
        "OPENWEATHER_API_KEY": "your_api_key_here"
      }
    }
  }
}

Test with AI Client

Once configured, you can ask your AI assistant:

"What's the weather like in Taipei?"
"Give me a 5-day forecast for Tokyo"
"What's the temperature in New York in Fahrenheit?"

The AI will automatically call the appropriate MCP tools!


๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   AI Client     โ”‚ (Claude, ChatGPT, etc.)
โ”‚  (Claude Desktop)โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚ MCP Protocol (stdio)
         โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Weather MCP    โ”‚ โ† This server
โ”‚     Server      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚ HTTPS
         โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ OpenWeather API โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Components

  • index.js - Main server implementation

  • @modelcontextprotocol/sdk - Official MCP SDK

  • StdioServerTransport - Communicates via stdin/stdout

  • OpenWeather API - External weather data source


๐Ÿ“ Project Structure

weather-mcp-server/
โ”œโ”€โ”€ package.json          # Dependencies and scripts
โ”œโ”€โ”€ index.js              # Main MCP server code
โ”œโ”€โ”€ .env.example          # Environment variables template
โ”œโ”€โ”€ .env                  # Your API keys (git-ignored)
โ”œโ”€โ”€ README.md             # This file
โ”œโ”€โ”€ README.zh-TW.md       # ็น้ซ”ไธญๆ–‡็‰ˆ
โ”œโ”€โ”€ PARTNER-GUIDE.md      # Detailed guide for OEM partners
โ””โ”€โ”€ examples/
    โ””โ”€โ”€ client-example.js # Example client code

๐Ÿ› ๏ธ Development

Code Structure

The server is organized into clear sections:

  1. Configuration - API keys, URLs

  2. WeatherServer Class - Main server logic

  3. Tool Registration - Define available tools

  4. Tool Handlers - Implement tool functionality

  5. Error Handling - Robust error management

Adding New Tools

// 1. Add tool definition in setupToolHandlers()
{
  name: 'your_new_tool',
  description: 'What this tool does',
  inputSchema: {
    type: 'object',
    properties: {
      param1: { type: 'string', description: 'Parameter description' }
    },
    required: ['param1']
  }
}

// 2. Add handler in CallToolRequestSchema
case 'your_new_tool':
  return await this.yourNewTool(args.param1);

// 3. Implement the method
async yourNewTool(param1) {
  // Your logic here
  return {
    content: [{
      type: 'text',
      text: 'Result'
    }]
  };
}

๐Ÿงช Testing

Manual Testing

# Test the MCP server directly
npm test

Integration Testing

Use the included examples/client-example.js to test tool calls programmatically.


๐Ÿ“ API Reference

Tool: get_current_weather

Parameters:

  • city (string, required) - City name (e.g., "Taipei", "Tokyo")

  • units (string, optional) - "metric" (default) or "imperial"

Returns:

๐ŸŒค๏ธ Current Weather in Taipei, TW

Temperature: 25.3ยฐC (feels like 26.1ยฐC)
Condition: Clear - clear sky
Humidity: 65%
Wind Speed: 3.2 m/s
Pressure: 1013 hPa
Visibility: 10.0 km

Last updated: 11/14/2025, 10:30:00 AM

Tool: get_weather_forecast

Parameters:

  • city (string, required) - City name

  • units (string, optional) - "metric" (default) or "imperial"

Returns:

๐Ÿ“… 5-Day Weather Forecast for Taipei, TW

11/14/2025:
  High: 26.5ยฐC | Low: 22.1ยฐC
  Condition: Clear

11/15/2025:
  High: 27.2ยฐC | Low: 23.4ยฐC
  Condition: Clouds

...

๐Ÿ”’ Security Best Practices

Implemented in this sample:

  • โœ… API keys stored in environment variables (not in code)

  • โœ… Input validation for all parameters

  • โœ… Proper error handling (no sensitive data leakage)

  • โœ… HTTPS for external API calls

  • โœ… Minimal dependencies (reduces attack surface)

For production deployments:

  • ๐Ÿ” Use secrets management system (AWS Secrets Manager, Azure Key Vault)

  • ๐Ÿ” Implement rate limiting

  • ๐Ÿ” Add request logging/monitoring

  • ๐Ÿ” Use TLS for MCP communication if deployed remotely


๐ŸŒ Localization

This server supports multiple languages through the OpenWeather API:

// Add language parameter to API call
const url = `${API_BASE_URL}/weather?q=${city}&units=${units}&lang=zh_tw&appid=${API_KEY}`;

Supported languages: en, zh_tw, zh_cn, ja, ko, and 50+ more


๐Ÿ› Troubleshooting

Common Issues

"City not found"

  • Check spelling of city name

  • Try including country code: "Taipei,TW"

"Weather API error: Unauthorized"

  • Verify your API key in .env

  • Check API key is active at openweathermap.org

"Module not found"

  • Run npm install

  • Check Node.js version >= 18.0.0

MCP server not detected in Claude

  • Verify claude_desktop_config.json path

  • Restart Claude Desktop

  • Check server logs for errors


๐Ÿ“š Learn More

MCP Resources

Weather API


๐Ÿค For OEM Partners

See PARTNER-GUIDE.md for:

  • Detailed integration guide

  • Deployment options

  • Customization examples

  • Production checklist

  • Support information

Contact: partners@irisgo.ai


๐Ÿ“„ License

MIT License - see LICENSE file


๐Ÿ™ Credits

  • Created by: IrisGo.AI Team

  • MCP Protocol: Anthropic

  • Weather Data: OpenWeather

  • For: ASUS and AI PC OEM partners


๐Ÿ“ฎ Support


Last Updated: 2025-11-14 Version: 1.0.0

Available Tools

2 tools
get_current_weatherA

Get current weather information for a specific city

ParametersJSON Schema
NameRequiredDescriptionDefault
cityYesCity name (e.g., "Taipei", "Tokyo", "New York")
unitsNoTemperature units: "metric" (Celsius) or "imperial" (Fahrenheit)metric

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It only indicates a read operation ('Get') but lacks details on data freshness, rate limits, or other behavioral traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with purpose, no extraneous words. Every part is essential.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with 2 parameters and no output schema, the description covers the purpose and required parameter. However, it lacks usage guidelines and behavioral context, making it barely adequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds no extra meaning beyond what the schema already states (city and units).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves current weather for a specific city, with verb 'Get' and resource 'current weather information', and the term 'current' distinguishes it from the sibling tool 'get_weather_forecast'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

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 vs the sibling 'get_weather_forecast'. The usage is implied by the name and description, but no when-not-to or alternatives are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_weather_forecastA

Get 5-day weather forecast for a specific city

ParametersJSON Schema
NameRequiredDescriptionDefault
cityYesCity name (e.g., "Taipei", "Tokyo", "New York")
unitsNoTemperature units: "metric" (Celsius) or "imperial" (Fahrenheit)metric

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description carries the full burden. It discloses the 5-day forecast aspect but does not mention any other behaviors (e.g., data source, update frequency, or limitations). There is no contradiction.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence of 9 words, perfectly concise. It front-loads the verb 'Get' and the key noun 'forecast', making it immediately scannable.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple 2-parameter read tool with no output schema, the description covers the essential purpose and parameter. It could mention that the forecast includes temperature and conditions, but overall it is mostly complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema coverage is 100%; both parameters ('city' and 'units') are well described in the schema. The description adds no extra detail beyond what the schema provides, meeting the baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get'), the resource ('5-day weather forecast'), and the target ('specific city'). It effectively distinguishes from the sibling tool 'get_current_weather' by specifying the forecast duration.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit when-to-use or when-not-to-use guidance is provided. The contrast with the sibling tool 'get_current_weather' is implied by the description, but direct advice on selecting between them is absent.

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. Dates show when Glama detected each change.

  1. 2 tool updates
    • First observedget_current_weather
    • First observedget_weather_forecast

TDQS

A3.7/5.0

Scored across 2 tools

Disambiguation5/5

Tools have clearly distinct purposes: one retrieves current weather, the other provides a forecast. No overlap in functionality.

Naming Consistency5/5

Both tools follow a consistent verb_noun pattern using snake_case: get_current_weather and get_weather_forecast. The pattern is predictable.

Tool Count3/5

With only 2 tools, the set is minimal but borderline for a weather server. A few more (e.g., hourly forecast, alerts) would be more appropriate.

Completeness3/5

The tool surface covers current weather and a 5-day forecast, but misses common weather operations like hourly forecasts, weather alerts, or location-based queries.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    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.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides weather information through OpenWeather API, enabling users to get current weather conditions, 5-day forecasts, and perform temperature conversions for any city. Offers a secure interface for AI assistants to access comprehensive weather data including temperature, humidity, wind, and pressure information.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides real-time weather data and forecasts for locations worldwide using the OpenWeatherMap API. It enables AI assistants to retrieve current conditions, temperature, and forecasts through a simple tool-based interface.
    MIT

Latest Blog Posts

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/lmanchu/weather-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server