Weather Pro
A production-grade MCP server that provides real-time weather data and demonstrates the complete MCP protocol surface including tools, resources, prompts, and structured output.
README
Weather Pro — a production-grade MCP server
A Model Context Protocol server that exposes real-time weather, built to demonstrate the full MCP surface — not just tools — and to run like a real service (dual transport, auth, caching, retries, tests, Docker, CI).
It is the "after" to a deliberately minimal "before"
(../mcp-real-weather-api), which exposes a single
get_weather tool over stdio and nothing else.
Targets the current stable spec, MCP 2025-11-25, via
@modelcontextprotocol/sdk.
What it demonstrates
| MCP concept | Where to see it | What it proves |
|---|---|---|
| Structured output | get_weather outputSchema → structuredContent |
Tool results are typed & machine-readable, not opaque text |
| Tool annotations | readOnlyHint, openWorldHint on both tools |
Server signals to the host that a tool is safe to auto-run |
| Input validation | Zod inputSchema on every tool |
Bad arguments are rejected before our code runs |
| Elicitation | get_weather on an ambiguous city ("Springfield") |
Server pauses to ask the user a structured question |
| Sampling | get_weather includeAdvice |
Server asks the client's LLM for advice — ships no LLM SDK itself |
| Progress | compare_weather over several cities |
Long-running tool streams incremental progress + supports cancel |
| Resources (direct) | weather://reference/conditions |
Fixed, read-only context (WMO code table) |
| Resource templates | weather://current/{city}, weather://forecast/{city}/{date} |
Parameterised, discoverable data (RFC 6570 URIs) |
| Completions | {city} autocomplete on templates & the prompt |
Suggests valid argument values as you type |
| Prompts | plan-my-day |
Reusable, user-invoked workflow (slash command) |
| Logging | sendLoggingMessage in tools |
Structured observability over the protocol |
See DEMO.md for the guided walkthrough / talking points.
Quick start
npm install
npm test # unit tests (offline, deterministic)
npm run inspect # open the MCP Inspector against the stdio server
Run it
# Local (stdio) — for Claude Desktop, IDEs
npm start
# Remote (HTTP) — for multi-client / deployment
MCP_TRANSPORT=http PORT=3000 MCP_AUTH_TOKEN=changeme npm run start:http
End-to-end smoke tests (hit the live Open-Meteo API):
npm run smoke # spawns + drives the stdio server
# In one terminal: MCP_TRANSPORT=http PORT=3030 MCP_AUTH_TOKEN=demo-secret npm start
npm run smoke:http # drives the running HTTP server
Connect a client
Claude Desktop / IDE (stdio)
Add to your MCP client config (e.g. claude_desktop_config.json):
{
"mcpServers": {
"weather-pro": {
"command": "node",
"args": ["/absolute/path/to/mcp-weather-pro/src/index.js"]
}
}
}
Remote (Streamable HTTP)
{
"mcpServers": {
"weather-pro": {
"type": "http",
"url": "http://localhost:3000/mcp",
"headers": { "Authorization": "Bearer changeme" }
}
}
}
Architecture
src/
index.js entrypoint — selects transport from MCP_TRANSPORT
config.js env-driven config (one source of truth)
logger.js structured JSON logs → stderr (stdout is the protocol!)
cache.js bounded TTL cache (hit/miss stats)
httpClient.js axios + timeout + retry/backoff for upstream calls
schemas.js Zod input/output schemas (validation + structured output)
server.js builds the McpServer and registers every primitive
services/
geo.js geocoding + ambiguity detection (powers elicitation)
weather.js current + forecast + WMO code mapping + units
cities.js static list for completions
features/
tools.js get_weather, compare_weather
resources.js direct resource + two templates
prompts.js plan-my-day
transports/
stdio.js local transport + graceful shutdown
http.js Streamable HTTP + Bearer auth + sessions + /health
Production concerns covered
- Dual transport (stdio + Streamable HTTP) from one codebase.
- Auth — Bearer token on every HTTP
/mcpcall;/healthleft open. - Resilience — per-call timeouts, bounded exponential backoff with jitter.
- Caching — geocoding (24h) and weather (5m) with bounded size + eviction.
- Validation — Zod on all tool inputs; SDK validates structured output.
- Graceful degradation — elicitation/sampling are used only if the client supports them; otherwise the tool still returns a correct result.
- Observability — structured stderr logs + protocol-level logging.
- Tests & CI — unit tests on Node 18/20/22 + a Docker build in GitHub Actions.
- Containerised — multi-stage-friendly Dockerfile with a healthcheck.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。