Templates / AI agent tools

Weather MCP tool for Claude, ChatGPT and Cursor

An MCP tool that gives AI agents a 3-day forecast for any city, using the free Open-Meteo API. No API key; works in Claude, ChatGPT and Cursor.

The “hello world” of MCP tools, and genuinely useful: an agent asks for the weather in a city and gets structured data back. Open-Meteo needs no API key, so it works the moment it’s deployed.

Build it with Wisp

Type this into Wisp, or press Build this — it writes the code below, deploys it and gives you a URL:

An MCP tool get_forecast that takes a city name, geocodes it with Open-Meteo and returns the next 3 days of max/min temperature and chance of rain.

The code

GET /get-forecast · API · MCP

export async function handler(req) {
  const city = String(req.query.city ?? '').trim();
  if (!city) return { status: 400, body: { error: 'city is required' } };

  const geo = await (await fetch(`https://geocoding-api.open-meteo.com/v1/search?count=1&name=${encodeURIComponent(city)}`)).json();
  const place = geo.results?.[0];
  if (!place) return { status: 404, body: { error: `No place called "${city}"` } };

  const params = new URLSearchParams({
    latitude: place.latitude, longitude: place.longitude, timezone: 'auto', forecast_days: '3',
    daily: 'temperature_2m_max,temperature_2m_min,precipitation_probability_max',
  });
  const f = await (await fetch(`https://api.open-meteo.com/v1/forecast?${params}`)).json();
  return {
    body: {
      place: `${place.name}, ${place.country}`,
      days: f.daily.time.map((date, i) => ({
        date,
        maxC: f.daily.temperature_2m_max[i],
        minC: f.daily.temperature_2m_min[i],
        rainChance: f.daily.precipitation_probability_max[i],
      })),
    },
  };
}

Try it

Connect the project’s MCP server to Claude (Settings → Connectors → Add custom connector, paste the MCP URL from Connect → MCP) and ask “What’s the weather in Lisbon this weekend?”. Or call it directly: curl "https://<your-project-url>/get-forecast?city=Lisbon".

How it works

Variations

Questions

Do I need to write an MCP server? No. Every Wisp project is an MCP server; each function with MCP ticked is a tool. The protocol, transport and tool listing are handled for you.

Build it with Wisp — free trial

Related