weather-mcp-server

weather-mcp-server

3.6

If you are the rightful owner of weather-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

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

Weather API MCP Server

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.

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 .

License

This MCP server is licensed under the .