Weather Travel Advisory MCP Server
Enables weather-based travel advisory generation using wttr.in API, including tools to fetch forecasts, calculate travel risk, and produce structured advisory reports.
README
P004 Case Study 2 — Weather and Travel Advisory MCP Server
An MCP (Model Context Protocol) server that exposes weather-related tools, resources, and prompts, using the public wttr.in weather API to generate a structured, deterministic travel advisory report.
This implements the PRD: P004 Case Study 2: Weather and Travel Advisory MCP Server Using wttr.in API. Section references below (e.g. "PRD 10.3") point back to that document.
1. Project Overview
The server accepts a destination city, fetches live weather data, normalizes it into a clean schema, deterministically calculates a travel weather risk (LOW / MEDIUM / HIGH), and produces a JSON travel advisory report — all through well-defined MCP primitives rather than a generic chatbot loop.
2. Business Use Case
A traveler wants a quick, structured answer to questions like:
- "Should I travel to Jaipur this weekend?"
- "What should I pack for Pune based on the weather?"
- "Is Mumbai risky for outdoor travel?"
Out of scope (PRD Section 5): flight/hotel/train booking, medical advice, disaster alerts, visa/immigration rules, paid travel services. This is a weather-based advisory only, not a guaranteed travel decision.
3. Technology Stack
| Layer | Choice |
|---|---|
| MCP framework | mcp (FastMCP) |
| HTTP client | requests |
| Data validation | pydantic |
| Testing | pytest, pytest-mock |
| Config | python-dotenv |
| Language | Python 3.10+ |
4. wttr.in API Usage Details (PRD Section 6–7)
- Endpoint:
GET https://wttr.in/{city_name}?format=j1 - No API key required.
- Fallback domain:
https://wttr.is/{city_name}?format=j1 - City names with spaces: replace spaces with
+(e.g.New+Delhi). - Timeout: 10 seconds.
- Numeric fields in the raw response arrive as strings and are converted
to
int/floatduring normalization (PRD 7.6).
All networking lives in src/api_client.py. Per PRD Section 9, it is the
only module that talks to the wttr.in API.
5. MCP Tools (PRD Section 10)
| Tool | Purpose |
|---|---|
validate_city_input_tool |
Validates/cleans the destination city name. No API call. |
get_weather_forecast_tool |
Calls wttr.in (only tool allowed to hit the network). |
normalize_weather_data_tool |
Converts raw wttr.in JSON into the normalized schema. |
calculate_weather_risk_tool |
Deterministic LOW/MEDIUM/HIGH risk calculation. No LLM. |
save_travel_advisory_tool |
Validates + saves the final report as JSON. |
6. MCP Resources (PRD Section 11)
| Resource URI | Content |
|---|---|
resource://travel/checklist |
Static travel-readiness checklist |
resource://travel/advisory-rules |
Static LOW/MEDIUM/HIGH interpretation rules |
resource://weather/normalized-forecast-schema |
JSON description of the normalized schema |
Resources are static reference content only — they never call APIs.
7. MCP Prompts (PRD Section 12)
| Prompt | Purpose |
|---|---|
travel_readiness_prompt |
Template for a concise travel-readiness advisory |
weather_risk_summary_prompt |
Template explaining why the risk level was assigned |
packing_recommendation_prompt |
Template for practical packing suggestions |
Prompts only render natural-language template text — they never call APIs
and never perform risk math (that's calculate_weather_risk_tool's job).
8. Setup Instructions
git clone <this-repo>
cd p004_mcp_weather_travel_advisory
python3 -m venv .venv && source .venv/bin/activate # optional but recommended
pip install -r requirements.txt
cp .env.example .env # no API key needed, defaults already work
9. How to Run the MCP Server
python src/server.py
This starts the MCP server on stdio transport, ready to be connected from any MCP-compatible client (e.g. Claude Desktop, an MCP Inspector, or a custom client configured to launch this command).
10. How to Run Tests
pytest tests/
This runs all unit tests (37 tests) using mocked wttr.in responses — no
network access or API key required. pytest.ini excludes integration tests
by default (-m "not integration").
11. How to Run Integration Tests
pytest -m integration
This runs test_real_wttr_api_for_jaipur, which makes a real HTTP call to
wttr.in. Status: written but unverified in this delivery — the
development sandbox used to build this project only allowed network egress
to package registries (PyPI/npm/GitHub), not to wttr.in/wttr.is, so this
specific test could not be executed live here. It is ready to run in any
environment with normal internet access.
12. How to Generate Sample Reports
python src/server.py --sample-city Jaipur
python src/server.py --sample-city Pune
Each command runs the full PRD Section 13 pipeline once and prints the
resulting JSON report, saving it to outputs/travel_advisory_report.json.
Pre-generated examples (built from mocked weather data, since this sandbox
cannot reach wttr.in) are checked in at:
sample_outputs/sample_jaipur_advisory.json(MEDIUM risk scenario)sample_outputs/sample_pune_advisory.json(HIGH risk scenario)
13. Final Report Schema (PRD Section 14)
{
"destination": "",
"region": "",
"country": "",
"forecast_days": 3,
"current_weather": {
"temperature_c": 0,
"humidity": 0,
"precipitation_mm": 0,
"wind_speed_kmph": 0,
"weather_description": ""
},
"daily_forecast": [
{
"date": "",
"max_temp_c": 0,
"min_temp_c": 0,
"avg_temp_c": 0,
"total_precipitation_mm": 0,
"max_wind_kmph": 0,
"max_chance_of_rain": 0,
"weather_description": ""
}
],
"weather_risk": "LOW | MEDIUM | HIGH",
"risk_factors": [],
"recommended_actions": [],
"packing_suggestions": [],
"travel_readiness_advisory": "",
"weather_risk_explanation": "",
"resources_used": [],
"tools_used": [],
"prompts_used": []
}
The report is validated against this schema (via src/schemas.py, a
pydantic model) before it is written to disk.
14. Known Limitations
- No live LLM call for prompt outputs.
travel_readiness_advisory,weather_risk_explanation, andpacking_suggestionsare conceptually meant to be produced by feeding the rendered prompt templates (PRD Section 12) to an LLM. This environment has no LLM API key / network access to an LLM provider, sosrc/server.py::_render_llm_fieldcontains the intended (commented-out) Anthropic API call, clearly marked "written but unverified — no API key/network access to test live", and falls back to a small deterministic text generator so the pipeline still produces a complete, schema-valid report end to end. - No live wttr.in access from the build sandbox. The environment used
to build and test this project could only reach package registries
(PyPI, npm, GitHub), not wttr.in/wttr.is. All unit tests therefore use
realistic mocked fixtures (
tests/conftest.py), and the one real-network test is marked@pytest.mark.integrationand flagged as unverified here. - Risk model is a fixed rule set. Thresholds (e.g.
max_temp_c >= 40) come directly from PRD Section 10.4 and are not configurable via environment variables in this version. - 3-day forecast cap. Per PRD 10.3 rule 5, only the first 3 days returned by wttr.in are normalized, even if more are available.
15. Future Improvements
- Wire up the real Anthropic Messages API call in
_render_llm_fieldonce an API key is available, and add a live/offline toggle via an env var. - Add response caching for repeated queries to the same city within a short time window, to reduce load on wttr.in.
- Make risk thresholds configurable via
.envfor easier tuning. - Add more cities to
sample_outputs/(New Delhi, Mumbai, Bengaluru) once live API access is available. - Add an MCP resource that returns the list of supported/validated example cities for quick client-side testing.
Project Structure
p004_mcp_weather_travel_advisory/
├── README.md
├── requirements.txt
├── .env.example
├── pytest.ini
├── src/
│ ├── server.py # MCP server wiring + orchestration flow (PRD 13)
│ ├── tools.py # 5 mandatory MCP tools (PRD 10)
│ ├── resources.py # 3 mandatory MCP resources (PRD 11)
│ ├── prompts.py # 3 mandatory MCP prompts (PRD 12)
│ ├── api_client.py # wttr.in HTTP client (PRD 6, 7, 18)
│ ├── schemas.py # pydantic schemas (PRD 10.3, 14)
│ └── report_writer.py # JSON persistence + schema validation (PRD 10.5)
├── tests/
│ ├── conftest.py # mocked wttr.in fixtures
│ ├── test_api_client.py
│ ├── test_tools.py
│ ├── test_resources.py
│ ├── test_prompts.py
│ └── test_report_schema.py
├── outputs/
│ └── travel_advisory_report.json # generated at runtime
└── sample_outputs/
├── sample_jaipur_advisory.json
└── sample_pune_advisory.json
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。