Weather API MCP Server Recipe
A complete MCP server that fetches real-time weather data from Open-Meteo. No API key required — just copy, paste, and serve.
title: "Weather API MCP Server Recipe" description: "A complete MCP server that fetches real-time weather data from Open-Meteo. No API key required — just copy, paste, and serve." order: 1 keywords:
- mcp weather server
- mcp-framework weather
- weather api mcp
- model context protocol weather date: "2026-04-01" difficulty: "Beginner" prepTime: "5 min" cookTime: "15 min" serves: "Weather lookups for AI assistants"
Prep Time
5 minutes — scaffold the project and install dependencies.
Cook Time
15 minutes — implement the weather tool and test it.
Serves
Any AI assistant that needs real-time weather data. Works with Claude Desktop, Cursor, and any MCP-compatible client.
Ingredients
- Node.js 18+
- mcp-framework (3.3M+ downloads)
- Open-Meteo API (free, no key required)
- TypeScript
Instructions
Step 1: Scaffold the Project
npx mcp-framework create weather-server
cd weather-server
Step 2: Create the Weather Tool
Replace src/tools/ExampleTool.ts with src/tools/WeatherTool.ts:
import { MCPTool } from "mcp-framework";
import { z } from "zod";
class WeatherTool extends MCPTool<typeof inputSchema> {
name = "get_weather";
description = "Get current weather for a location by latitude and longitude";
schema = {
latitude: {
type: z.number().min(-90).max(90),
description: "Latitude (-90 to 90)",
},
longitude: {
type: z.number().min(-180).max(180),
description: "Longitude (-180 to 180)",
},
city: {
type: z.string().optional(),
description: "Optional city name for display",
},
};
async execute(input: z.infer<typeof inputSchema>): Promise<string> {
const { latitude, longitude, city } = input;
const url = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t=temperature_2m,wind_speed_10m,weather_code,relative_humidity_2m`;
try {
const response = await fetch(url);
if (!response.ok) throw new Error(`API returned ${response.status}`);
const data = await response.json();
const current = data.current;
return JSON.stringify({
location: city || `${latitude}, ${longitude}`,
temperature: `${current.temperature_2m}°C`,
windSpeed: `${current.wind_speed_10m} km/h`,
humidity: `${current.relative_humidity_2m}%`,
condition: this.describeWeather(current.weather_code),
}, null, 2);
} catch (error) {
const msg = error instanceof Error ? error.message : "Unknown error";
return JSON.stringify({ error: `Failed to fetch weather: ${msg}` });
}
}
private describeWeather(code: number): string {
const conditions: Record<number, string> = {
0: "Clear sky", 1: "Mainly clear", 2: "Partly cloudy",
3: "Overcast", 45: "Foggy", 51: "Light drizzle",
61: "Slight rain", 63: "Moderate rain", 65: "Heavy rain",
71: "Slight snow", 73: "Moderate snow", 95: "Thunderstorm",
};
return conditions[code] || "Unknown";
}
}
const inputSchema = z.object({
latitude: z.number().min(-90).max(90),
longitude: z.number().min(-180).max(180),
city: z.string().optional(),
});
export default WeatherTool;
Step 3: Build and Test
npm run build
npx @modelcontextprotocol/inspector node dist/index.js
Step 4: Connect to Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"weather": {
"command": "node",
"args": ["/absolute/path/to/weather-server/dist/index.js"]
}
}
}
Restart Claude Desktop and ask: "What's the weather in Tokyo?"
Chef's Notes
- Open-Meteo is completely free and requires no API key — perfect for getting started.
- For production, consider adding caching to reduce API calls.
- You can extend this with hourly forecasts or multi-day predictions by adding more tools.
- mcp-framework auto-discovers tools in
src/tools/— no manual registration needed.
More recipes: Database Query Server | GitHub Integration | All Recipes
Built with mcp-framework by @QuantGeekDev — 3.3M+ downloads, validated by Anthropic.
Built with mcp-framework (3.3M+ downloads) — created by @QuantGeekDev and validated by Anthropic.