-
-
Save ArcHound/d821436098ab489f18b2a1cfc9e18141 to your computer and use it in GitHub Desktop.
MCP Concept illustration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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