Skip to content

Instantly share code, notes, and snippets.

@ArcHound
Last active April 30, 2025 06:16
Show Gist options
  • Save ArcHound/d821436098ab489f18b2a1cfc9e18141 to your computer and use it in GitHub Desktop.
Save ArcHound/d821436098ab489f18b2a1cfc9e18141 to your computer and use it in GitHub Desktop.
MCP Concept illustration
import os
import requests
from fastmcp import FastMCP
mcp_server = FastMCP(name="Example MCP Server")
WEATHER_API_KEY = os.environ.get("WEATHER_API_KEY")
@mcp_server.tool()
def weather(location: Annotated[str, Field(description="City (London) or ZIP (10001) or IATA (DXB) or coordinates (48.8567,2.3508) to get current weather for")]):
"""Get current weather for location specified by City (London) or ZIP (10001) or IATA (DXB) or coordinates (48.8567,2.3508)"""
if not WEATHER_API_KEY:
return "No weather API key provided"
return requests.get(f"https://api.weatherapi.com/v1/current.json?q={location}&key={WEATHER_API_KEY}").json().get("current", {})
if __name__ == "__main__":
mcp_server.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment