Skip to content

Latest commit

ย 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ‡ฎ๐Ÿ‡ณ Indian Weather MCP Server

A comprehensive Model Context Protocol (MCP) server providing detailed weather information, air quality data, and agricultural insights for Indian cities. Built with TypeScript and powered by Open-Meteo APIs.

โœจ Features

๐ŸŒค๏ธ Weather Forecasting

  • Current Weather: Real-time temperature, wind speed, and conditions
  • Hourly Forecast: 12-hour detailed weather predictions
  • Daily Forecast: 5-day weather outlook with min/max temperatures
  • Air Quality Index (AQI): PM2.5, PM10, and US AQI readings

๐Ÿ“Š Historical Weather Analysis

  • Historical Data: Up to 30 days of past weather information
  • Trend Analysis: Compare current conditions with historical averages
  • Weather Patterns: Identify temperature and precipitation trends

๐Ÿ™๏ธ Multi-City Comparison

  • City Comparison: Compare weather across 2-5 Indian cities simultaneously
  • Extreme Weather Detection: Identify hottest, coldest, and windiest locations
  • Temperature Ranges: Calculate temperature differences between cities

๐Ÿฅ Health & Comfort Indexes

  • Heat Index: Calculated using temperature and humidity
  • UV Index: Sun protection recommendations with safety levels
  • Comfort Level: Personalized comfort assessment
  • Health Recommendations: Weather-based health advice

๐Ÿšœ Agricultural Weather Intelligence

  • Soil Moisture Index: Based on recent rainfall and temperature
  • Growing Degree Days (GDD): For rice, wheat, and cotton crops
  • Monsoon Status: Current season identification
  • Farming Recommendations: Crop-specific weather advice

๐Ÿ› ๏ธ Installation

Prerequisites

  • Node.js 18+
  • npm or yarn
  • TypeScript (for development)

Setup

# Clone the repository
git clone https://github.com/yourusername/Indian-Weather-MCP-Server.git
cd Indian-Weather-MCP-Server.git

# Install dependencies
npm install

# Build the project
npm run build

๐Ÿš€ Usage

Standalone Server Usage

Direct Server Execution

# Start the MCP server directly
node build/index.js

The server will start and listen for MCP protocol messages via stdio. This is useful for:

  • Integration with MCP-compatible applications
  • Direct protocol communication
  • Server-only deployments

Server Output

๐Ÿ‡ฎ๐Ÿ‡ณ Indian Weather MCP Server running with AQI, Hourly Forecast, Historical Data, Multi-City Comparison, Health Indexes & Agricultural Weather

Client-Server Usage

Interactive Client Mode

# Navigate to client directory
cd client

# Start the interactive client
npm start

Automated Testing Mode

# Navigate to client directory
cd client

# Run automated tests
npm test

Client Features

  • Real-time Weather Queries: Interactive command-line interface
  • Automated Testing: Comprehensive test suite for all tools
  • Error Handling: Graceful error management and reporting
  • Performance Monitoring: Response time measurements

๐Ÿ› ๏ธ Available Tools

1. Weather Forecast

get_forecast_india(city: string)

Example: Get current weather and forecast for Mumbai

  • Current temperature, wind speed, and conditions
  • 12-hour hourly forecast
  • 5-day daily forecast
  • Air quality information

2. Historical Weather

get_historical_weather_india(city: string, days?: number)

Example: Get 7-day historical weather for Delhi

  • Historical temperature, precipitation, and wind data
  • Comparison with current conditions
  • Trend analysis and averages

3. City Comparison

compare_weather_india(cities: string[])

Example: Compare weather between Mumbai, Delhi, and Bangalore

  • Side-by-side weather comparison
  • Extreme weather identification
  • Temperature range analysis

4. Health & Comfort

get_health_comfort_india(city: string)

Example: Get health recommendations for Chennai

  • Heat index calculation
  • UV index with protection advice
  • Air quality health impacts
  • Personalized comfort level

5. Agricultural Weather

get_agricultural_weather_india(city: string, cropType?: string)

Example: Get farming advice for Punjab with rice crop

  • Soil moisture assessment
  • Growing degree days for major crops
  • Seasonal farming recommendations
  • Crop-specific weather advice

๐ŸŽฏ Usage Scenarios

Scenario 1: Standalone Server Integration

# Start server for MCP-compatible applications
node build/index.js

Use Cases:

  • Integration with Claude Desktop
  • Custom MCP applications
  • Server-only deployments
  • API gateway implementations

Scenario 2: Interactive Development & Testing

# Start interactive client for development
cd client
npm start

# Available commands:
forecast Mumbai
historical Delhi 14
compare Mumbai,Delhi,Bangalore
health Chennai
agricultural Punjab rice

Scenario 3: Automated Testing & Validation

# Run comprehensive test suite
cd client
npm test

Test Coverage:

  • All 5 weather tools
  • Error handling validation
  • Performance benchmarking
  • Response format verification

Scenario 4: Production Deployment

# Build and deploy server
npm run build
node build/index.js

# Or use as system service
pm2 start build/index.js --name weather-mcp

๐Ÿ—๏ธ Architecture

Project Structure

โ”œโ”€โ”€ src/                      # Source code
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ constants.ts      # API endpoints and thresholds
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”œโ”€โ”€ geocoding.ts     # City coordinate lookup
โ”‚   โ”‚   โ”œโ”€โ”€ weather-api.ts   # Weather data fetching
โ”‚   โ”‚   โ””โ”€โ”€ weather-processor.ts # Data processing and formatting
โ”‚   โ”œโ”€โ”€ tools/
โ”‚   โ”‚   โ”œโ”€โ”€ forecast-tool.ts # Weather forecasting
โ”‚   โ”‚   โ”œโ”€โ”€ historical-tool.ts # Historical analysis
โ”‚   โ”‚   โ”œโ”€โ”€ comparison-tool.ts # Multi-city comparison
โ”‚   โ”‚   โ”œโ”€โ”€ health-tool.ts   # Health and comfort
โ”‚   โ”‚   โ””โ”€โ”€ agricultural-tool.ts # Agricultural insights
โ”‚   โ”œโ”€โ”€ types/
โ”‚   โ”‚   โ””โ”€โ”€ weather.ts       # TypeScript interfaces
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ””โ”€โ”€ calculations.ts  # Weather calculations
โ”‚   โ””โ”€โ”€ index.ts             # Main server file
โ”œโ”€โ”€ client/                  # MCP Client
โ”‚   โ”œโ”€โ”€ index.js            # Interactive client
โ”‚   โ”œโ”€โ”€ test-client.js      # Automated test suite
โ”‚   โ”œโ”€โ”€ package.json        # Client dependencies
โ”‚   โ””โ”€โ”€ README.md           # Client documentation
โ”œโ”€โ”€ build/                   # Compiled JavaScript
โ”œโ”€โ”€ package.json            # Server dependencies
โ””โ”€โ”€ README.md               # This documentation

Data Sources

  • Open-Meteo: Weather forecasts and historical data
  • Open-Meteo Air Quality: Air quality and pollution data
  • Nominatim: Geocoding for Indian cities

๐Ÿ”ง Configuration

Environment Variables

No API keys required - uses free Open-Meteo APIs.

Customization

Edit src/config/constants.ts to modify:

  • API endpoints
  • AQI thresholds
  • UV index levels
  • Crop base temperatures
  • Monsoon season definitions

๐Ÿ“Š API Endpoints

The server integrates with multiple Open-Meteo endpoints:

  • Weather Forecast: https://api.open-meteo.com/v1/forecast
  • Historical Data: https://archive-api.open-meteo.com/v1/archive
  • Air Quality: https://air-quality-api.open-meteo.com/v1/air-quality
  • Geocoding: https://nominatim.openstreetmap.org/search

๐Ÿงฎ Weather Calculations

Heat Index

Uses the National Weather Service formula for heat index calculation based on temperature and humidity.

Growing Degree Days (GDD)

Calculated for different crops:

  • Rice: Base temperature 10ยฐC
  • Wheat: Base temperature 0ยฐC
  • Cotton: Base temperature 15ยฐC

Soil Moisture Index

Based on recent rainfall and average temperature to assess soil moisture levels.

๐ŸŒ Supported Cities

All major Indian cities are supported through Nominatim geocoding:

  • Mumbai, Delhi, Bangalore, Chennai, Kolkata
  • Hyderabad, Pune, Ahmedabad, Jaipur, Surat
  • And many more...

๐Ÿ”ง Development

Quick Start

# Clone and setup
git clone https://github.com/yourusername/Indian-Weather-MCP-Server.git
cd Indian-Weather-MCP-Server
npm install
npm run build

# Test the server
cd client
npm install
npm test

Development Workflow

# 1. Make changes to TypeScript files in src/
# 2. Build the project
npm run build

# 3. Test with client
cd client
npm start

# 4. Run automated tests
npm test

Client Development

# Interactive development
cd client
npm run dev  # Auto-restart on changes

# Test specific scenarios
node test-client.js

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes and test them:
    npm run build
    cd client && npm test
  4. Commit your changes (git commit -m 'Add amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

๐Ÿ“ License

This project is licensed under the ISC License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support

Getting Help

  • GitHub Issues: Create an issue for bugs or feature requests
  • Documentation: Check both main README and client README
  • Code Examples: Review the client implementation for usage patterns

Common Issues

Server Won't Start

# Ensure project is built
npm run build

# Check if build directory exists
ls build/

Client Connection Failed

# Ensure server is built first
cd .. && npm run build && cd client

# Test server directly
node ../build/index.js

API Errors

  • Check internet connection
  • Verify Open-Meteo API accessibility
  • Ensure Nominatim geocoding service is available

Performance Tips

  • Server: Runs efficiently with minimal memory usage
  • Client: Optimized for fast response times
  • Caching: Consider implementing response caching for production

Built with โค๏ธ for Indian weather intelligence

๐ŸŒŸ Star this repository if you find it useful!

About

A comprehensive Model Context Protocol (MCP) server providing detailed weather information, air quality data, and agricultural insights for Indian cities.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages