Labsco
MCP SERVER

MCP Weather Server Demo

by RaulCalderon

A weather tool in one file — the smallest complete example of an MCP server, running on public APIs with no key.

Summary
Read it before you write your own.

This is an example project and says so — the value is that the whole path from tool declaration to a public API call fits in one file you can read in a sitting, with the inspector walkthrough included so you can watch the call happen. As a weather source it is fine; as a starting point for writing your own server it is the more likely use.

What it is

A sample MCP server built to be read. It exposes one tool that takes a city name and returns current weather from the Open-Meteo API, with the whole server and its tool in a single `main.ts`.

What you get
  • Current weather for any city by name — `fetch-weather`
  • Public APIs behind it: geocoding turns the city name into coordinates, then the weather lookup runs — no account in either step
  • Argument validation with `zod` on top of `@modelcontextprotocol/sdk`, so the tool shape is declared rather than assumed
  • A one-command inspector run — `npx -y @modelcontextprotocol/inspector npx -y tsx main.ts` — that lists the tool and lets you call it in a browser
Requirements

Node with the repository cloned and `npm install`, then `npx tsx main.ts`. No key and no account. The inspector path needs the proxy session token printed at startup, passed as `MCP_PROXY_AUTH_TOKEN`, with transport set to STDIO.

Setup effort

One command — npx -y mcp