Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weather MCP Server

A Model Context Protocol server exposing a single get-weather tool. An MCP client — Claude Desktop, or any agent that speaks MCP — calls the tool with a city name and gets the current temperature back.

Built on the official TypeScript SDK, communicating over stdio, with tool input validated by Zod.

The tool

Name get-weather
Input { "city": string }
Output Current temperature in Istanbul: 21.3°C
Upstream WeatherAPI.com current.json

Failed upstream requests and unknown tool names come back as plain text content rather than protocol errors, so the calling model can recover instead of losing the turn.

Requirements

Setup

npm install
npm run build

Two environment variables are required:

Variable Value
WEATHER_API_BASE_URL https://api.weatherapi.com/v1/current.json
WEATHER_API_KEY your WeatherAPI key

Running it

WEATHER_API_BASE_URL=https://api.weatherapi.com/v1/current.json \
WEATHER_API_KEY=your_key \
node dist/index.js

The server talks MCP over stdio, so it prints nothing on its own — it waits for a client to connect. Running it by hand is only useful to check that it starts without crashing.

Connecting it to Claude Desktop

Add the server to claude_desktop_config.json:

  • macOS — ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows — %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "weather": {
      "command": "node",
      "args": ["/absolute/path/to/getWeather-MCPServer/dist/index.js"],
      "env": {
        "WEATHER_API_BASE_URL": "https://api.weatherapi.com/v1/current.json",
        "WEATHER_API_KEY": "your_key"
      }
    }
  }
}

Run npm run build first — the config points at the compiled output, not the TypeScript source. Then restart Claude Desktop. The tool appears under the connector icon, and asking "what is the temperature in Izmir?" triggers a get-weather call.

Project layout

src/index.ts    the whole server — tool listing, tool body, stdio transport
tsconfig.json   compiles src/ to dist/ as ESNext / NodeNext modules

License

MIT

About

Model Context Protocol server exposing a get-weather tool: Zod-validated input, stdio transport, built on the official TypeScript MCP SDK.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages