使用说明
MCP Weather Server
A Model Context Protocol (MCP) server that provides weather information tools accessible via the streamable-http transport.
Overview
This MCP weather server provides a simple weather lookup tool that can be used by MCP clients to get weather information for any city.
The server runs on port 8081 using the streamable-http transport protocol.
Prerequisites
- Python 3.13+
Installation
uv sync
Running
uv run main.py
The server will start on http://localhost:8081/mcp and wait for MCP client connections.
Architecture
- FastMCP: Simplified MCP server framework
- streamable-http: Transport protocol for server-client communication
- Tool Definitions: Weather lookup tool exposed as an MCP tool
API Endpoints
The server provides a streamable-http endpoint at:
http://localhost:8081/mcp
Tools
get_weather(city: str) -> str
Returns weather information for a given city.
Parameters:
city(str): The name of the city to get weather for
Returns:
- Weather information as a string
Example:
get_weather("New York")
# Returns: "The weather in New York is sunny."
Dependencies
mcp: Model Context Protocol libraryfastmcp: Simplified MCP server framework