Weather Tool
MCP Weather Tool
Installation
npx mcp-server-weather-toolAsk AI about Weather Tool
Powered by Claude Β· Grounded in docs
I know everything about Weather Tool. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Weather MCP Tool π€οΈ
A Model Context Protocol (MCP) server that provides real-time weather information using the wttr.in API. This project was created during the learning phase of understanding MCP systems.

π About This Project
This is a custom MCP tool that demonstrates the core concepts of building MCP servers. The tool:
- Takes a location as user input (string format)
- Constructs a weather API URL using wttr.in
- Fetches real-time temperature and weather data
- Returns formatted results to the MCP client (Claude)
π Key Learnings
- β How to create a custom MCP Tool - Understanding MCP server architecture and tool registration
- β Using MCP Inspector - Testing and debugging MCP tools locally before deployment
- β
Connecting MCP tools with Claude - Configuration through
.configfiles to integrate with Claude Desktop - β Working with FastMCP - Simplified MCP server creation with decorators
- β Async Python patterns - Using async/await for non-blocking I/O operations
π Features
- π€οΈ Real-time weather information for any location worldwide
- π No API key required - Uses the free wttr.in service
- π§ Easy MCP integration with Claude Desktop
- β‘ Fast and lightweight - Uses Python's built-in urllib
- π Beginner-friendly codebase - Perfect for learning MCP concepts
- π― Production-ready - One-command setup and execution
π Prerequisites
- Python 3.8 or higher
- Internet connection (to fetch weather data)
- Claude Desktop (optional, for integration)
No API keys needed! β¨
π Quick Start
Option 1: Automatic Setup (Recommended)
Windows:
setup.bat
run.bat
Linux/Mac:
chmod +x setup.sh run.sh
./setup.sh
./run.sh
Option 2: Manual Setup
- Clone the repository
git clone https://github.com/Namangarg-01/Mcp-server-weather-tool.git
cd Mcp-server-weather-tool
- Create virtual environment
python -m venv .venv
# Activate:
# Windows:
.venv\Scripts\activate
# Linux/Mac:
source .venv/bin/activate
- Install dependencies
pip install -r requirements.txt
- Run the server
python main.py
π» Usage
Testing with MCP Inspector
Test your tool locally before connecting to Claude:
# Install MCP Inspector (one-time)
npm install -g @modelcontextprotocol/inspector
# Run inspector
npx @modelcontextprotocol/inspector python main.py
This opens a web interface where you can:
- View available tools
- Test the
check_weatherfunction - See request/response in real-time
Connecting to Claude Desktop
To use this MCP server with Claude Desktop, update your configuration file:
Config file location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Add this configuration:
{
"mcpServers": {
"weather": {
"command": "python",
"args": ["C:/Users/YourName/Desktop/Mcp-server-weather-tool/main.py"]
}
}
}
Important:
- Use absolute path to
main.py - Replace
YourNamewith your actual username - Use forward slashes
/even on Windows
After updating, restart Claude Desktop.
Using in Claude
Once connected, ask Claude:
"What's the weather in London?"
"Check the temperature in Tokyo"
"Tell me about the weather in Paris, France"
"How's the weather in Mumbai right now?"
Claude will automatically use your MCP tool to fetch real-time weather data! π
π How It Works
Architecture Overview
User Query β Claude Desktop β MCP Server β wttr.in API β Response
β β β
(stdio) check_weather() HTTP GET
Code Flow
- User asks Claude about weather
- Claude calls MCP tool with location parameter
- MCP server receives the request via stdio
check_weather()tool is invokedget_weather()function:- URL-encodes the location
- Constructs wttr.in URL
- Fetches weather data via HTTP
- Response returned to Claude
- Claude formats and displays to user
Key Components
main.py - MCP Server
@mcp.tool()
async def check_weather(location: str) -> Dict[str, Any]:
"""Get weather info for specific location."""
return get_weather(location)
tools/weather.py - Weather Fetcher
def get_weather(location: str) -> dict:
"""Fetches weather using wttr.in API"""
url = f"https://wttr.in/{location}?format=3"
# Returns: "London: β
οΈ +15Β°C"
π Project Structure
Mcp-server-weather-tool/
βββ tools/
β βββ weather.py # Weather fetching logic
βββ main.py # MCP server entry point
βββ requirements.txt # Python dependencies
βββ .gitignore # Git ignore rules
βββ setup.bat # Windows setup script
βββ setup.sh # Linux/Mac setup script
βββ run.bat # Windows run script
βββ run.sh # Linux/Mac run script
βββ Screenshot 2026-02-13 205352.png
βββ README.md # This file
π Troubleshooting
Server Won't Start
Error: ModuleNotFoundError: No module named 'mcp'
# Reinstall dependencies
pip install -r requirements.txt
Claude Can't Connect
Error: MCP server not responding
- Check that the path in
claude_desktop_config.jsonis absolute - Verify Python is accessible:
python --version - Restart Claude Desktop after config changes
- Check server runs manually:
python main.py
Weather Data Not Fetching
Error: urllib.error.URLError
- Check your internet connection
- Try accessing https://wttr.in/London in your browser
- The service might be temporarily down
MCP Inspector Issues
# If npx command not found, install Node.js first
# Then install inspector globally:
npm install -g @modelcontextprotocol/inspector
π Future Enhancements
Potential features to add:
- Multi-day forecast support
- Weather alerts and warnings
- Historical weather data
- Support for coordinates (lat/long)
- Caching for frequently requested locations
- Unit conversion (Celsius β Fahrenheit)
- More detailed weather information (humidity, wind, pressure)
π€ Contributing
This is a learning project, and contributions are welcome!
How to contribute:
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Test thoroughly with MCP Inspector
- Commit:
git commit -m 'Add amazing feature' - Push:
git push origin feature/amazing-feature - Open a Pull Request
Areas for contribution:
- Documentation improvements
- Error handling enhancements
- Additional weather features
- Testing and bug fixes
- Performance optimizations
π License
MIT License - see LICENSE file for details.
π§ Contact
Naman Garg
- GitHub: @Namangarg-01
- Project: Mcp-server-weather-tool
π Acknowledgments
- Built while learning Model Context Protocol (MCP)
- Weather data provided by wttr.in
- Thanks to Anthropic for Claude and MCP documentation
- Special thanks to the FastMCP library for simplifying MCP server creation
π Project Stats
- Language: Python 3.8+
- Dependencies: 2 (mcp, fastmcp)
- Lines of Code: ~50
- Setup Time: < 2 minutes
- API Keys Required: 0 β¨
Made with β€οΈ during the MCP learning journey
Happy weather checking! π€οΈ
