AI Experiment · 2026

AI Weather Agent

A weather agent that leads with verified data: search a place, see Open-Meteo current conditions, hourly, and 7-day cards first, then read a short Claude narrative written only from those numbers, with every step visible in an agent trace.

What changed: weather answers stopped being guesses. Verified live data leads, and the AI explains the numbers instead of inventing them.

AI / LLMs Tool Use APIs JavaScript Anthropic

Overview

What I Built

This project is a weather agent that leads with verified data instead of a chat box. Search for a place and the first thing you see is not a paragraph but structured cards from Open-Meteo: current conditions, the next 12 hours, the 7-day outlook, precipitation, wind, and air quality. Only then does Claude write a short narrative, and it writes strictly from the numbers on screen, so nothing it says can be a hallucinated forecast.

What makes it interesting isn't the weather part. It's the architecture underneath. The core pattern is what the AI community calls tool use: instead of having Claude guess or hallucinate an answer, we give it structured capability definitions ("tools") that it can choose to invoke when it needs real-world information. Each tool has a name, a natural-language description, and a typed input schema, defined directly in JavaScript and passed to the Anthropic Messages API alongside the user's question. There is no MCP server involved. The tools are hardcoded locally in this single HTML file, and the tool execution logic (geocoding, API calls, data parsing) runs entirely in the browser.

In a production system, you might host these same tool definitions on an MCP (Model Context Protocol) server: a standardized way to expose tools so that any compatible AI client can discover and invoke them over a network protocol. This project skips that layer intentionally: by defining and executing the tools locally, every step of the agentic loop is visible in one file without any infrastructure in the way.

The problem it solves is a real one: most APIs return raw JSON that requires parsing, formatting, and presentation logic before it's useful to a person. With tool use, the AI handles both sides: it decides when to call the API, passes the right inputs, interprets the structured result, and composes a response that makes sense in context. You write less glue code, and the interface becomes far more flexible.

Try It

Live Demo

Search for a place. If several places share the name, pick the right one from the list. The agent then fetches current, hourly, 7-day, and air quality data in parallel and renders verified cards before any AI narrative appears.

Open-Meteo weather, geocoding, and air quality calls are free and require no key. The short narrative is routed through a Cloudflare Worker proxy; the Anthropic API key is stored as a Worker secret and never exposed client-side. The narrative is written only from the fetched numbers shown below.
Search for a place above to see verified weather cards.

Agent trace

    Architecture

    How It Works

    The agent runs a fixed, visible pipeline instead of an open-ended chat loop. Search resolves a place through geocoding, with disambiguation when several places share a name. One parallel fetch then pulls current conditions, hourly, 7-day daily, and air quality from Open-Meteo. Structured cards render from those responses first. Only then does Claude write a short narrative, and its prompt contains nothing but the numbers already on screen. Follow-up questions resolve against the cached forecast, so they never re-fetch.

    Why data leads: A chat-first agent can answer fluently about weather it never fetched, and the visitor cannot tell. When cards render before any model text, and the trace shows exactly which endpoints returned which numbers, the visitor can check every claim. The model becomes a summarizer with receipts, which is the only role where its fluency cannot invent a forecast.

    Reflection

    What I Learned

    Rebuilding the demo data-first changed what I thought the interesting problem was:

    Tools Used

    Tech Stack

    Built entirely without frameworks or build tools: a single HTML file, vanilla JavaScript, and two free public APIs.

    Claude Sonnet Anthropic Messages API Agent Trace Open-Meteo Weather API Open-Meteo Geocoding API Open-Meteo Air Quality API Vanilla JavaScript (ES2022+) HTML / CSS

    Keep exploring

    Head back to the projects page.