MCPcopy Index your code
hub / github.com/ezh0v/weather-mcp-server

github.com/ezh0v/weather-mcp-server @v1.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.3.0 ↗ · + Follow
30 symbols 101 edges 17 files 2 documented · 7%
What it actually does AI analysis from the code graph — generated when you open this
loading…
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.

Extension points exported contracts — how you extend this code

WeatherAPIProvider (Interface)
go:generate mockgen --source external.go --destination mock/external_mock.go --package mock [2 implementers]
internal/server/services/external.go
Services (Interface)
go:generate mockgen --source services.go --destination mock/mock.go --package mock [1 implementers]
internal/server/services/services.go
WeatherService (Interface)
(no doc) [2 implementers]
internal/server/services/services.go
ToolFunc (FuncType)
(no doc)
internal/server/tools/tools.go

Core symbols most depended-on inside this repo

Current
called by 7
internal/server/services/services.go
Weather
called by 3
internal/server/services/services.go
New
called by 2
internal/server/services/core/core.go
CurrentWeather
called by 2
internal/server/handlers/weather.go
New
called by 1
pkg/weatherapi/weatherapi.go
Current
called by 1
pkg/weatherapi/weatherapi.go
Run
called by 1
internal/server/server.go
serveSSE
called by 1
internal/server/server.go

Shape

Function 11
Struct 8
Method 7
Interface 3
FuncType 1

Languages

Go100%

Modules by API surface

internal/server/services/services.go4 symbols
pkg/weatherapi/weatherapi.go3 symbols
internal/server/services/core/core.go3 symbols
pkg/weatherapi/models/other.go2 symbols
pkg/weatherapi/models/current.go2 symbols
internal/server/services/external.go2 symbols
internal/server/services/core/weather.go2 symbols
internal/server/server.go2 symbols
internal/server/config.go2 symbols
pkg/weatherapi/weatherapi_test.go1 symbols
internal/server/tools/weather_test.go1 symbols
internal/server/tools/weather.go1 symbols

For agents

$ claude mcp add weather-mcp-server \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page