Download server.py from ZarakShah/mcp_tools: direct link, hf CLI and curl.
- Browser
- Download file 750 Bytes
-
https://huggingface.co/spaces/ZarakShah/mcp_tools/resolve/main/server.py
- Command line
-
hf download hf://spaces/ZarakShah/mcp_tools/server.py
-
curl -L -o server.py https://huggingface.co/spaces/ZarakShah/mcp_tools/resolve/main/server.py
750 Bytes
| from mcp.server.fastmcp import FastMCP | |
| # Create an MCP server | |
| mcp = FastMCP("Weather Service") | |
| # Tool implementation | |
| def get_weather(location: str) -> str: | |
| """Get the current weather for a specified location.""" | |
| return f"Weather in {location}: Sunny, 72°F" | |
| # Resource implementation | |
| def weather_resource(location: str) -> str: | |
| """Provide weather data as a resource.""" | |
| return f"Weather data for {location}: Sunny, 72°F" | |
| # Prompt implementation | |
| def weather_report(location: str) -> str: | |
| """Create a weather report prompt.""" | |
| return f"""You are a weather reporter. Weather report for {location}?""" | |
| # Run the server | |
| if __name__ == "__main__": | |
| mcp.run() |