Python Weather Server
About
A FastAPI-based server that provides weather information from the National Weather Service API, secured with OAuth 2.1.
Details
- Author
- azure-samples
- Categories
- Developer Tools, Other, API
- Tags
- #weather, #data-analysis
Jump to
Setup
Install Python Weather Server in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/azure-samples/remote-mcp-webapp-python-auth-oauth
Follow the installation instructions in the repository README, then restart your MCP client.
Python MCP Weather Server with OAuth 2.1 Authentication
A production-ready Model Context Protocol (MCP) server built with FastAPI that provides weather information using the National Weather Service API. Featuresfull MCP OAuth 2.1 compliancewith PKCE, dynamic client registration, and Azure AD integration. Ready for deployment to Azure App Service with Azure Developer CLI (azd).
- MCP OAuth 2.1 Specification Compliant: Complete implementation of MCP Authorization Specification (2025-03-26)
- PKCE Required: Secure authorization with Proof Key for Code Exchange (RFC 7636, S256 method)
- Dynamic Client Registration: Automatic client registration per RFC 7591
- Authorization Server Metadata: Discovery endpoint per RFC 8414
- Third-Party Authorization: Uses Azure AD as authorization server
- MCP Protocol Headers: Full support forMCP-Protocol-Version: 2025-03-26
- JWT Token Management: Secure token-based authentication
- Weather Tools:
- get_alerts: Get weather alerts for any US state
- get_forecast: Get detailed weather forecast for any location
This server implements the completeMCP Authorization Specification (2025-03-26):
- GET /.well-known/oauth-authorization-server- Authorization server metadata (RFC 8414)
- POST /register- Dynamic client registration (RFC 7591)
- GET /authorize- Authorization endpoint with PKCE (RFC 7636)
- POST /token- Token endpoint for code exchange and refresh
- GET /auth/azure/callback- Third-party authorization callback
- ✅Protocol Version Headers:MCP-Protocol-Version: 2025-03-26
- ✅PKCE Required: All clients must use S256 method
- ✅Dynamic Registration: Automatic client onboarding
- ✅JWT Authentication: Bearer token validation on MCP endpoints
- ✅Proper Error Handling: 401/403/400 responses with details
- ✅Azure AD Integration: Enterprise-grade authorization server
⚠️ Important: Complete OAuth setup required before use. SeeAUTH_SETUP.mdfor Azure AD configuration instructions.
- Python 3.8+
- Azure account with completed OAuth setup (seeAUTH_SETUP.md)
-
Complete OAuth setup first: Follow the instructions inAUTH_SETUP.mdto create your Azure App Registration.
git clone <your-repo-url> cd remote-mcp-webapp-python-auth-oauth python -m venv venv .\venv\Scripts\Activate.ps1 # Windows # source venv/bin/activate # macOS/Linux pip install -r requirements.txt
cp .env.example .env # Edit .env with your Azure OAuth credentials from AUTH_SETUP.md
.\start_server.ps1 # Windows # or manually: uvicorn main:app --host 0.0.0.0 --port 8000 --reload
- Server:http://localhost:8000/
- Health Check:http://localhost:8000/health
- OAuth 2.1 Test Interface:http://localhost:8000/mcp_oauth_test.html
- API Docs:http://localhost:8000/docs
Before connecting any MCP client, you must authenticate:
- Get JWT Token: Visithttp://localhost:8000/mcp_oauth_test.html
- Complete OAuth Flow: Use the built-in OAuth 2.1 test interface
- Copy JWT Token: Use the token in your MCP client configuration
-
In a new terminal window, install and run MCP Inspector:
CTRL+click the URLdisplayed by the app (e.g.http://localhost:5173/#resources)
- Set transport type toHTTP
- Set URL to:http://localhost:8000/
- Add Authorization header:Bearer <your-jwt-token>
💡Getting your JWT token: Visithttp://localhost:8000/mcp_oauth_test.htmlto complete the OAuth 2.1 flow and obtain your JWT token.
Test the connection: List Tools, click on a tool, and Run Tool
{ "mcpServers": { "weather-mcp-server-local": { "transport": { "type": "http", "url": "http://localhost:8000/", "headers": { "Authorization": "Bearer <your-jwt-token>" } }, "name": "Weather MCP Server (Local with Auth)", "description": "Authenticated MCP Server with weather tools" } } } > 💡 Replace <your-jwt-token> with the actual JWT token obtained from the OAuth 2.1 flow at /mcp_oauth_test.html. ## 🚀 Quick Deploy to Azure ### Prerequisites - Azure CLI - Azure Developer CLI (azd) - Active Azure subscription - Completed OAuth setup (see AUTH_SETUP.md) ### Deploy in 5 Commands `bash # 1. Login to Azure azd auth login # 2. Initialize the project azd init # 3. Set OAuth environment variables (from your AUTH_SETUP.md) azd env set AZURE_CLIENT_ID "your-client-id" azd env set AZURE_TENANT_ID "your-tenant-id" azd env set AZURE_CLIENT_SECRET "your-client-secret" azd env set JWT_SECRET_KEY "your-secure-jwt-secret" # 4. Deploy to Azure (first time to get the URL) azd up # 5. Update environment with deployed URL and redeploy azd env set BASE_URL "https://app-web-[unique-id].azurewebsites.net" azd env set AZURE_REDIRECT_URI "https://app-web-[unique-id].azurewebsites.net/auth/azure/callback" azd env set ENVIRONMENT "production" azd up
⚠️ Critical: After deployment, you must update your Azure App Registration:
- Note your deployed URL:https://app-web-[unique-id].azurewebsites.net/
- Go to Azure Portal → Microsoft Entra ID → App registrations → Your App
- ClickAuthentication→ Add redirect URI:https://app-web-[unique-id].azurewebsites.net/auth/azure/callback
- ClickSave
💡Note: The redirect URI must be/auth/azure/callback(not/auth/callback) for the MCP OAuth 2.1 flow to work correctly.
After deployment, your authenticated MCP server will be available at:
- OAuth 2.1 Test Interface:https://<your-app>.azurewebsites.net/mcp_oauth_test.html
- Health Check:https://<your-app>.azurewebsites.net/health
- MCP Capabilities:https://<your-app>.azurewebsites.net/mcp/capabilities
- API Docs:https://<your-app>.azurewebsites.net/docs
Follow the same guidance as the local setup, but use your Azure App Service URL and ensure you have a valid JWT token from the deployed authentication endpoint.
{ "mcpServers": { "weather-mcp-server-azure": { "transport": { "type": "http", "url": "https://<your-app>.azurewebsites.net/", "headers": { "Authorization": "Bearer <your-jwt-token>" } }, "name": "Weather MCP Server (Azure with Auth)", "description": "Authenticated MCP Server hosted on Azure" } } }``
- Local: Visithttp://localhost:8000/mcp_oauth_test.html
- Azure: Visit
https://<your-app>.azurewebsites.net/mcp_oauth_test.html
- Complete OAuth 2.1 Flow: Dynamic client registration → Authorization → Token exchange
- PKCE Validation: Test the full Proof Key for Code Exchange flow
- MCP Endpoint Testing: Test authenticated weather tools
- JWT Token Display: View and validate your authentication tokens
- Client Callback Testing: Includes/client-callbackendpoint for OAuth flow validation
The server implements a complete OAuth 2.1 flow:
- Client Registration: Dynamic client registration with auto-generated credentials
- Authorization: User redirected to Azure AD for authentication
- Azure Callback: Server receives Azure auth code at
/auth/azure/callback
- Client Callback: Server redirects to client's callback (e.g.,/client-callback`) with authorization code- Token Exchange: Client exchanges authorization code for JWT access token
Test with any MCP-compatible client using the authenticated endpoints and your JWT token.
This server uses the National Weather Service (NWS) API:
- Real-time weather alerts and warnings
- Detailed weather forecasts
- Official US government weather data
- No API key required
- High reliability and accuracy
- ✅OAuth 2.1 Compliance: Full MCP Authorization Specification implementation
- ✅PKCE Required: S256 method for all authorization flows
- ✅Dynamic Client Registration: Secure automatic client onboarding
- ✅Azure AD Integration: Enterprise-grade authorization server
- ✅JWT Token Security: Configurable expiration and secure validation
- ✅Protocol Version Enforcement: MCP-Protocol-Version header validation
- ✅Request Logging: Full audit trail with user identification
- ✅CORS Protection: Proper cross-origin resource sharing policies
This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.
Integrates the Korea Meteorological Administration's public weather API to provide climate data.
Fetches precipitation forecast data for a specific location using the Buienradar service.
GribStream MCP is a hosted Model Context Protocol server for weather forecast data. It helps AI agents discover GribStream datasets, resolve exact forecast variables and levels, validate request bodies, and build runnable GribStream Weather API requests for GFS, ECMWF IFS, NBM, HRRR, and other models.
Access meteorological data for Portugal from the IPMA public API using natural language.
62 real-time data tools for AI agents via MCP. Finance, crypto, FMCSA, sanctions, courts, weather, vehicles, cybersecurity. One bearer token, one bill. Free tier available.
Provides accurate Islamic prayer times for locations throughout Malaysia using the waktusolat.app API.
The Meteomatics MCP server allows AI agents to securely access Meteomatics weather data tools.
Access global weather data and forecasts using the OpenMeteo API, including current conditions, historical data, and location search.
A production-clean MCP server for the free Open-Meteo weather API (geocoding, forecast, air quality) with SRE-grade rate limiting, backoff, and structured logging.
SkyLinkAPI MCP Server | Aviation Data MCP Server
Connect SkyLink API to Claude Desktop, Cursor, or any MCP client in under a minute. Ask about live flights, weather, NOTAMs, and ADS-B positions — your AI gets real data, not hallucinations.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





