Created
December 14, 2025 17:55
-
-
Save Proteusiq/0c0a09f7862847de1fc0d0a4becd1faa to your computer and use it in GitHub Desktop.
things mcp
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
| from fastmcp import FastMCP | |
| from fastmcp.server.auth.providers.jwt import StaticTokenVerifier | |
| from agents.tools import get_coordinates, get_dmi_weather | |
| # define autheticifacation mechanism | |
| verifier = StaticTokenVerifier( | |
| tokens={ | |
| "generatedtoken": { | |
| "client_id": "prayson@42.com", | |
| "scopes": ["read:data", "write:data", "admin:users"] | |
| }, | |
| }, | |
| required_scopes=["read:data"] | |
| ) | |
| mcp = FastMCP( | |
| name="DMIWeather", | |
| auth=verifier, | |
| ) | |
| @mcp.tool( | |
| name="get_dmi_weather", | |
| description="Get weather information of a give place in Denmark.", | |
| tags={"catalog", "information"}, | |
| meta={"version": "0.1", "author": "prayson-42"} | |
| ) | |
| def get_weather(location: str) -> str: | |
| address = "+".join(location.split()) | |
| latitude, longitude = get_coordinates(query=address) | |
| weather_report = get_dmi_weather(latitude=latitude, longitude=longitude) | |
| return weather_report | |
| if __name__ == "__main__": | |
| mcp.run(transport="streamable-http", port=9000) | |
| # Or run with: fastmcp run server.py --port 9000 --transport http |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment