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.
| 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.
- Node.js 22
- A free API key from weatherapi.com
npm install
npm run buildTwo environment variables are required:
| Variable | Value |
|---|---|
WEATHER_API_BASE_URL |
https://api.weatherapi.com/v1/current.json |
WEATHER_API_KEY |
your WeatherAPI key |
WEATHER_API_BASE_URL=https://api.weatherapi.com/v1/current.json \
WEATHER_API_KEY=your_key \
node dist/index.jsThe 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.
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.
src/index.ts the whole server — tool listing, tool body, stdio transport
tsconfig.json compiles src/ to dist/ as ESNext / NodeNext modules
MIT