| 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() |