A simple Model Context Protocol (MCP) server that fetches current temperature data for Bangalore and Delhi using the Open-Meteo API.
- ✅ Fetch current temperature for Bangalore and Delhi
- ✅ Returns temperature reading with timestamp
- ✅ No API key required (uses Open-Meteo free API)
- ✅ Simple REST API endpoints
- ✅ Error handling for network issues
- ✅ Unit tests with pytest
pip install -r requirements.txtStart the Flask server:
python app.pyThe server will start on http://127.0.0.1:5000
GET /
Returns server information and available endpoints.
GET /temperature?city=bangalore
GET /temperature?city=delhi
Response Example:
{
"city": "Bangalore",
"temperature": 24.5,
"unit": "°C",
"time": "2025-10-31T10:30",
"timezone": "Asia/Kolkata"
}GET /all
Returns temperature data for all supported cities.
Run the test suite:
pytest tests/Run tests with verbose output:
pytest tests/ -v# Get Bangalore temperature
curl http://127.0.0.1:5000/temperature?city=bangalore
# Get Delhi temperature
curl http://127.0.0.1:5000/temperature?city=delhi
# Get all cities
curl http://127.0.0.1:5000/allimport requests
# Get temperature for Bangalore
response = requests.get('http://127.0.0.1:5000/temperature?city=bangalore')
data = response.json()
print(f"{data['city']}: {data['temperature']}°C at {data['time']}")WeatherMCP/
├── app.py # Flask MCP server
├── weather.py # Weather fetching logic
├── requirements.txt # Python dependencies
├── README.md # This file
└── tests/
└── test_weather.py # Unit tests
This project uses the free Open-Meteo API which requires no API key and provides weather data under the CC BY 4.0 license.
-
Open VS Code Settings (JSON):
- Press
Ctrl+Shift+P(orCmd+Shift+Pon Mac) - Type "Preferences: Open User Settings (JSON)"
- Press Enter
- Press
-
Add the MCP server configuration to your
settings.json:
{
"github.copilot.chat.mcp.servers": {
"weather": {
"command": "python",
"args": [
"c:\\Users\\arush\\OneDrive\\Desktop\\WeatherMCP\\mcp_server.py"
]
}
}
}- Restart VS Code or reload the window (
Ctrl+Shift+P→ "Developer: Reload Window")
- The configuration is already in
.vscode/mcp-settings.json - Copy the contents to your VS Code User settings as shown above
Once configured, you can use it in GitHub Copilot Chat:
@weather get temperature for bangalore
@weather get temperature for delhi
@weather get all temperatures
Or ask natural language questions:
What's the current temperature in Bangalore?
Show me the weather for Delhi
- Run:
python app.py - Access via:
http://127.0.0.1:5000 - Use with curl, Postman, or any HTTP client
- Configure in VS Code settings (see above)
- Use with GitHub Copilot Chat
- Automatic integration with AI tools
- Temperature is returned in Celsius (°C)
- The API uses coordinates: Bangalore (12.97°N, 77.59°E), Delhi (28.70°N, 77.10°E)
- Timestamps are in ISO 8601 format with automatic timezone detection