A Model Context Protocol (MCP) server that provides weather information using FastMCP. This is the Python implementation - other language examples available separately.
- Weather Tool: Get current weather information for any city (currently returns hardcoded data)
- MCP Prompt Templates: Pre-built prompts for weather inquiries and travel advice
- STDIO Transport: Compatible with Claude Desktop and MCP Inspector
- Python 3.10+
- uv (recommended) or pip
-
Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh -
Clone and setup the project:
git clone <your-repo> cd weather_mcp_python
-
Create the package structure (if not already done):
# Make sure you have the weather_mcp directory with required files mkdir -p weather_mcp # Copy your original weather-mcp.py content to weather_mcp/server.py # Create weather_mcp/__init__.py with the provided content
-
Install dependencies:
# Install MCP with CLI extras (provides the 'mcp' command) uv add "mcp[cli]" # Install in development mode uv pip install -e .
-
Verify installation:
# Check that the package is installed uv run python -c "import weather_mcp; print('Package installed successfully')" # Check that MCP CLI is available uv run mcp --help
# Option 1: Run directly with uv
uv run python -m weather_mcp.server
# Option 2: Use the MCP CLI (recommended for development)
uv run mcp run weather_mcp/server.py
# Option 3: If installed as a package script
uv run weather-mcp- Open the project in VS Code
- Use F5 to run with the "Run Weather MCP Server" configuration
- Or use Ctrl+Shift+P → "Python: Run Python File in Terminal"
npx @modelcontextprotocol/inspector- Start the MCP Inspector in your browser
- Add your server with one of these commands:
# Recommended: Use MCP CLI uv run mcp run weather_mcp/server.py # Alternative: Direct Python execution uv run python -m weather_mcp.server
- Test the available tools and prompts:
- get_weather tool: Try with different cities
- weather_inquiry prompt: Generate weather inquiry templates
- weather_travel_advice prompt: Get travel advice prompts
If you have Claude Desktop installed, you can register your server:
# Register your server with Claude Desktop
uv run mcp install weather_mcp/server.py --name "Weather Server"This will automatically add your server to Claude Desktop's configuration.
Returns weather information for the specified city.
Example:
{
"city": "New York"
}Generates a prompt for weather inquiries.
Generates prompts for travel weather advice.
weather_mcp_python/
├── pyproject.toml
├── weather_mcp/
│ ├── __init__.py
│ └── server.py
├── .vscode/
│ └── launch.json
└── README.md
- Currently returns hardcoded weather data (45°F, Clear conditions)
- Real weather API integration planned for future versions
- Logging output goes to stderr to avoid interfering with MCP STDIO communication