mcp-python-tutorial

mcp-python-tutorial

0

A Python-based MCP server providing weather forecasts and alerts, utilizing the National Weather Service API. The service supports weather data retrieval through various endpoints and offers seamless integration with MCP-compatible applications.

Weather Service

A Python-based weather service built on the Model Context Protocol (MCP) that provides weather forecasts and alerts using the National Weather Service (NWS) API.

Features

  • Get weather forecasts by city and state
  • Get weather forecasts using coordinates
  • Get active weather alerts for any US state
  • Lookup coordinates for US cities

Overview

This service is implemented as an MCP server using FastMCP, allowing it to be easily integrated into MCP-compatible applications. It provides a clean interface for accessing weather data through well-defined tool endpoints.

Available MCP Tools

get_weather_by_city(city: str, state: str)

Get a detailed weather forecast for a specific US city and state.

get_forecast(location: str)

Get weather forecast for either a city/state combination or coordinates.

get_alerts(state: str)

Get active weather alerts for a US state.

get_coordinates(city: str, state: str)

Look up the latitude/longitude coordinates for a US city.

Technical Details

  • Uses the National Weather Service (NWS) API for weather data
  • Uses OpenStreetMap's Nominatim service for geocoding
  • Implements proper error handling and logging
  • Runs as an MCP server over stdio transport