Skip to main content
Glama
weather_mcp

weather_mcp

by AronSoldok

Прогноз погоды через MCP

Учебный проект: MCP-сервер ходит в публичный API Open-Meteo, консольный клиент спрашивает город (кириллицей или латиницей) и печатает прогноз на 7 дней.

Что такое MCP

MCP (Model Context Protocol) — открытый стандарт Anthropic (конец 2024). Коротко для собеседования: это «USB-C для ИИ». Один протокол, чтобы подключать к модели внешние системы (API, файлы, БД) без самописного плагина под каждый чат.

Три роли:

  • Host — приложение, в котором живёт модель (Cursor, Claude Desktop) или, как здесь, наше CLI.

  • Client — сторона, которая говорит с сервером по протоколу: handshake, список инструментов, вызов.

  • Server — процесс, который отдаёт инструменты. Он не чат и не модель, а розетка с функциями.

Три примитива протокола (в этом проекте только первый):

  • Tools — функции с JSON Schema аргументов. Методы tools/list и tools/call. У нас это get_forecast(city).

  • Resources — данные «как файлы» по URI. Не используем.

  • Prompts — шаблоны промптов. Не используем.

Связь — JSON-RPC 2.0. Локально идёт по stdio: клиент запускает сервер как subprocess и пишет JSON-строки в его stdin. Поэтому сервер нельзя логировать через print() — это попадёт в тот же поток, что и протокол, и сломает его. Логи только в stderr (logging).

Чем этот проект отличается от Cursor

«Классический» хост — Cursor: модель сама решает, какой tool вызвать. Здесь хост — client.py: город вводит человек, клиент явно вызывает get_forecast. Протокол тот же, LLM нет. Так проще увидеть handshake, list_tools и call_tool без «магии модели».

«Зачем MCP, если есть REST?»

REST — как сервер разговаривает с Open-Meteo. MCP — как ИИ-приложение разговаривает с вашим сервером: единый каталог инструментов, схемы аргументов, один транспорт. Сервер пишете один раз — его могут вызвать Cursor, Claude Desktop или этот CLI.

Спецификация: modelcontextprotocol.io.

Related MCP server: Weather MCP Server

Как это устроено здесь

  1. Вы запускаете клиент и вводите город (Москва или Moscow).

  2. Клиент поднимает MCP-сервер по stdio и вызывает tool get_forecast.

  3. Сервер ищет координаты в Geocoding API (кириллица → language=ru, иначе en) и берёт 7 дней из Forecast API.

  4. Клиент печатает таблицу: дата, день недели, погода, мин/макс, осадки, ветер.

Ключ API не нужен.

Запуск

Нужны Python 3.10+ и uv.

cd Checking_weather_MCP
uv sync
uv run python -m weather_mcp.client

Если команда uv не находится, тот же CLI ставится через pip: py -m pip install uv, дальше py -m uv sync и py -m uv run python -m weather_mcp.client.

Появится приглашение Город:. После ввода — таблица на неделю.

Сервер отдельно обычно не запускают: без клиента он просто ждёт JSON-RPC на stdin. Если нужно вручную:

uv run python -m weather_mcp.server

Available Tools

1 tool
get_forecastA

7-дневный прогноз по названию города (кириллица или латиница).

Inputs: city (required). Returns: city, days, country, latitude, +2 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 1 tool

    Disambiguation5/5

    Only one tool exists, so there is no possibility of confusion or overlap. The single tool's purpose is clearly defined as a 7-day forecast by city name.

    Naming Consistency4/5

    The tool name get_forecast follows a clear verb_noun convention that would be consistent with a broader weather toolset. However, with only one tool, the naming pattern is not fully demonstrable.

    Tool Count1/5

    A single tool is far too few for a weather server, which typically requires current conditions, geocoding, unit preferences, and alerts. This feels like an extreme under-scoping of the domain.

    Completeness1/5

    The tool surface is severely incomplete for a weather service. It only provides a 7-day forecast, leaving out current weather, location search, weather alerts, and other common weather data operations.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to fetch current weather conditions and forecasts for any city using the Open-Meteo API. Provides temperature, precipitation, and hourly forecast data through natural language queries.
      ISC
    • A
      license
      B
      quality
      D
      maintenance
      Enables real-time weather queries for cities worldwide using Open-Meteo API. Provides 7-day forecasts with detailed information including temperature, wind, humidity, precipitation, and comfort level assessments in both Chinese and English.
      1
      15 npm
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides current weather and multi-day forecasts for any city using the Open-Meteo API, with natural language city names and optional forecast duration.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides weather forecast tools using Open-Meteo, enabling users to get current conditions, multi-day forecasts, and umbrella recommendations through natural language queries.
      -