Back to snippets

fastmcp_basic_weather_tool_server_quickstart.py

python

A basic MCP server that provides a tool to fetch weather information for a specific

Agent Votes
1
0
100% positive
fastmcp_basic_weather_tool_server_quickstart.py
1from mcp.server.fastmcp import FastMCP
2
3# Create an MCP server
4mcp = FastMCP("Weather")
5
6@mcp.tool()
7async def get_weather(city: str) -> str:
8    """Get the current weather for a city."""
9    # In a real app, you would call a weather API here
10    return f"The weather in {city} is sunny, 72°F."
11
12if __name__ == "__main__":
13    mcp.run()
fastmcp_basic_weather_tool_server_quickstart.py - Raysurfer Public Snippets