Weather-MCP
š¤ļø ā ×Ŗ××××Ŗ ××× ××××ר ××שר××
פר×××§× ××××× ×פ××Ŗ×× MCP (Model Context Protocol): ×”××× (Agent) ××××”×” LLM ש××××¢ ×ש×××£ ×Ŗ××××Ŗ ××× ××××ר ×ער×× ××שר×× ×××ר×"×, ×××¢× ××Ŗ ×¢××× ××©×¤× ××פש××Ŗ ×צ'×× ×©××ר××× ×.
šÆ ××רת ×פר×××§×
××× ××Ŗ שרת MCP ×××¢××× ×©"××××" ××Ŗ ×-LLM ××צע ×ש××× ×©××× ×× ××××¢ ××× ā ×ש×××£ ×Ŗ××××Ŗ ××× ××××ר ××תר ×שר××× ×©××× ×× API.
××”××× ×¢××©× ×××Ŗ ××©×Ŗ× ×ר×××:
שרת ×שר×× (
weather-Israel) ā ××××× ×פ××¤× ××××Ŗ× ×¢× Playwright: פ××Ŗ× ××Ŗ weather2day.co.il/forecast, ××פש ×¢×ר, ×××ר ×××Ŗ×, ××× ×××ׄ ××Ŗ ×Ŗ××× ××£ ××Ŗ××××Ŗ ××××× ×××Ŗ× ×-LLM ××× ×©××¢× × ×עצ×× (××שת RAG).שרת ×ר×"× (
weather-USA) ā ש×××£ ×Ŗ××××Ŗ ××תרע××Ŗ ××Ø× ×-API ×רש×× ×©× ×-NWS (National Weather Service).
×-Host ×××ר ××Ŗ ×× ×שרת×× ×-LLM (Gemini, ××Ø× ×-API ××Ŗ×××-OpenAI), ×××”×£ ××× ××××××××Ŗ ××Ŗ ×× ×-Tools, ××ר×ׄ ×××××Ŗ צ'×× ×©×× ×-LLM ×××ר ××××× ××× ××שת×ש ××פע×× ×××Ŗ× ××× ××ר ×× ×¢× ×©××Ŗ×§×××Ŗ תש×××.
šļø ××× × ×פר×××§×
project-template/
āāā host.py # צ'×× ××ר××× × ×©×××ר ××Ŗ ×-LLM ××× ×©×Ø×Ŗ× ×-MCP
āāā client.py # MCP Client ×× ×Ø× (××Ŗ××ר ×שרת, ×ר×ׄ Tools)
āāā weather_USA.py # שרת MCP ××ר×"× ā ××Ø× NWS API
āāā weather_Israel.py # שרת MCP ××שר×× ā ××Ø× ××××× ×פ××¤× (Playwright)
āāā pyproject.toml # ×Ŗ×××××Ŗ ×פר×××§×
āāā README.md×-Tools ×©× ×©×Ø×Ŗ ×שר××
# | Tool | תפק×× |
1 |
| פ××Ŗ× ×פ××¤× Chromium ××× ××× ××תר ××Ŗ××××Ŗ |
2 |
| ××§××× ×©× ×¢×ר ×ש×× ×××פ×ש |
3 |
| ×××ר ××Ŗ ××¢×ר ×ר×ש×× × ×רש×××Ŗ ××צע××Ŗ |
4 |
| ×××ׄ ××Ŗ ×Ŗ××× ××£ ××Ŗ××××Ŗ (×××× iframes) ×××××ר ×××Ŗ× ×-LLM |
š” ש××שת ×ר×ש×× ×× ××××§×× ×××Ŗ× ×פ××¤× ××Ø× ××¦× ×××××× (
_page), ×× ×××× ×Ø×¦×× ××××Ŗ× ×Ŗ××××-שרת. ×ר×××¢× ×¢××ר ×¢× ×× ×-frames ×××£, ×× ××Ŗ××××Ŗ עצ×× × ××¢× ×Ŗ ××Ŗ××<iframe>ש×-body×ר××©× ×× ×Ø×××.
āļø ××Ŗ×§× × ××רצ×
×ר×ש××Ŗ ××§×××××Ŗ
Python ā„ 3.13
uv (×× ×× ××”×××× ×××Ŗ×××××Ŗ)
××¤×Ŗ× API ×-Gemini (×§×××Ŗ ××¤×Ŗ× ××× ××)
ש××××
# 1. ××Ŗ×§× ×Ŗ ××Ŗ×××××Ŗ ×××§××Ŗ ×”××××Ŗ ××¢××××
uv sync
# 2. ××Ŗ×§× ×Ŗ ×פ××¤× Chromium ×¢××ר Playwright
uv run playwright install chromium×××רת ××©×Ŗ× × ×”××××
×¦×Ø× ×§××ׄ .env ××Ŗ××§×××Ŗ ×פר×××§×:
GEMINI_API_KEY=your_api_key_here
GEMINI_MODEL=gemini-2.0-flash×רצ×
uv run host.py×××ר ××פע×× ×Ŗ×פ××¢ ש×רת Query: ā ××§×××× ×©××× (×× quit ××צ×××).
š¬ ×××××××Ŗ ×ש××××Ŗ ש××”××× ××××¢ ××¢× ××Ŗ ×¢××××
×Ŗ××××Ŗ ××שר×× (Playwright)
× ×¤×Ŗ× ×××× ×פ××¤× ×©×× ×Ø×××× ××Ŗ ××£ ××Ŗ××××Ŗ, ××-LLM ×× ×¢×× × ×צ'××.
"×× ××Ŗ××××Ŗ ××Ŗ× ××××?"
"××× ××¢×××Ŗ צפ××××Ŗ ××ר ××ר×ש×××?"
"××× ××× ×××××ר ××××¤× ××××?"
"תפת×× ×× ××Ŗ ××Ŗ××××Ŗ ×××ר ש××¢"
×Ŗ××××Ŗ ××תרע××Ŗ ××ר×"× (NWS API)
"What's the weather forecast for San Francisco?" (latitude/longitude)
"Are there any weather alerts in California?"
"Show me active weather alerts for NY"
š§© ××× ×× ×¢××× (תרש×× ×ר×××)
×שת×ש ā "×× ××Ŗ××××Ŗ ××Ŗ× ××××?"
ā
ā¼
Host āāāŗ LLM (Gemini) ×××ר Tools ××פע××
ā
ā¼ (שרת ×שר××, ××× ××ר ××)
open ā enter("×Ŗ× ××××") ā select ā get_content
ā
ā¼
×Ŗ××× ××Ŗ××××Ŗ ×××ר ×-LLM (RAG)
ā
ā¼
LLM ×××Ŗ× ×Ŗ×©××× ××©×¤× ××פש××Ŗ ×צ'×× āØš ×ער××Ŗ
×-LLM ××× ×× ×©××××× ×××× Tools ××פע×× ×××××× ×”×ר ā ×× ××Ŗ×× × ×××××§× ×§×©×××.
×©× × ×§××¦× ×©×Ø×Ŗ = ×©× × ×Ŗ×××××× × ×¤×Ø×××, ×××× ×× ××¦× ×ש××Ŗ×£ (××× ××פ××¤× ×פת××) ×× ××Ŗ×× ×©×Ø×Ŗ ××× ××××.