weather-mcp-server

MCP.Pizza Chef: TuanKiri

The weather-mcp-server is a lightweight Model Context Protocol server that provides AI models like Claude with real-time weather data. It enables AI assistants to retrieve, interpret, and integrate up-to-date weather information into their workflows, enhancing context-aware responses and decision-making. This server is designed for easy integration, reliability, and efficient data delivery in AI-enhanced applications.

Use This MCP server To

Provide real-time weather updates to AI chatbots Integrate weather data into virtual assistant workflows Enable AI models to interpret current weather conditions Support location-based weather queries in AI applications Automate weather report generation for user requests Enhance travel planning tools with live weather info Trigger alerts based on severe weather conditions

README

example output template

Weather API MCP Server

License Go Version Go Report Card Build Tests

Report Bug | Request Feature

A lightweight Model Context Protocol (MCP) server that enables AI assistants like Claude to retrieve and interpret real-time weather data.

demo example

Installing on Claude Desktop

To use your MCP server with Claude Desktop, add it to your Claude configuration:

1. Local mode

{
  "mcpServers": {
    "weather-mcp-server": {
      "command": "/path/to/weather-mcp-server",
      "env": {
        "WEATHER_API_KEY": "your-api-key"
      }
    }
  }
}

You can get an API key from your personal account on WeatherAPI.

2. Remote mode

{
  "mcpServers": {
    "weather-mcp-server": {
      "url": "http://host:port/sse"
    }
  }
}

Build from source

You can use go to build the binary in the cmd/github-mcp-server directory.

go build -o weather-mcp-server ./cmd/weather-mcp-server

Using MCP with Docker Containers

1. Build the Docker Image:

docker build -t weather-mcp-server .

2. Run the Docker Container:

docker run -e WEATHER_API_KEY=your-api-key -d --name weather-mcp-server -p 8000:8000 weather-mcp-server

Replace your-api-key with your actual WeatherAPI API key.

Tools

  • current_weather - Gets the current weather for a city

    • city: The name of the city (string, required)

Project Structure

The project is organized into several key directories:

├── cmd
│   └── weather-mcp-server
├── internal
│   └── server
│       ├── handlers # MCP handlers
│       ├── services # Business logic layer
│       │   ├── core # Core application logic
│       │   └── mock # Mock services for testing
│       ├── tools # MCP tools
│       └── view # Templates for displaying messages
└── pkg

Testing

If you're adding new features, please make sure to include tests for them.

1. Install the mockgen tool:

go install go.uber.org/mock/mockgen@latest

See the installation guide on go.uber.org/mock.

2. Use the following command to generate mock files:

make generate-mocks

3. To run unit tests:

make run-tests

Contributing

Feel free to open tickets or send pull requests with improvements. Thanks in advance for your help!

Please follow the contribution guidelines.

License

This MCP server is licensed under the MIT License.

weather-mcp-server FAQ

How do I install the weather-mcp-server?
You can install it by cloning the GitHub repository and following the build instructions using Go modules, as detailed in the README.
What weather data sources does the server use?
The server integrates with popular weather APIs to provide accurate, real-time weather data for various locations.
Can this server be used with multiple LLM providers?
Yes, it is compatible with LLMs like OpenAI, Claude, and Gemini, enabling broad AI assistant integration.
How does the server handle location queries?
It accepts location parameters in requests and returns weather data specific to those locations, supporting flexible geographic queries.
Is the weather data updated in real-time?
Yes, the server fetches and delivers up-to-date weather information to ensure AI responses reflect current conditions.
What programming language is the server built with?
The weather-mcp-server is built in Go, ensuring efficient performance and easy deployment.
How can I contribute to the project?
Contributions are welcome via GitHub pull requests; please follow the contribution guidelines in the repository.
Does the server support severe weather alerts?
Yes, it can provide alerts and notifications based on severe weather conditions to enhance AI assistant capabilities.