Imel23/Meteo_MCP_server_tuto
If you are the rightful owner of Meteo_MCP_server_tuto and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This project demonstrates how to use the FastMCP framework to create a simple MCP server for weather forecasting and geolocation.
get_coords
Fetches the latitude and longitude of a given city.
get_current_weather
Retrieves the current weather information for the specified coordinates.
get_forecast
Provides a weather forecast for the specified number of days.
๐ Tutorial: Use FastMCP with GitHub Copilot in VS Code
A minimal weather tool demo using MCP over STDIO
This repo shows how to:
- Build an MCP server using
fastmcp
- Run it locally via
uv
and the STDIO protocol - Use GitHub Copilot Chat in VS Code to call your tools without any glue code
- Debug using MCP Inspector
๐ฆ Setup
git clone <your-repo-url>
cd <repo>
uv pip install -r requirements.txt
๐ง What tools are exposed?
Defined in meteo_mcp.py
:
Tool | Description |
---|---|
get_coords(city: str) | Returns (lat, lon) |
get_current_weather(lat: float, lon: float) | Returns current temperature and wind |
get_forecast(lat: float, lon: float, days: int = 3) | Returns a weather forecast for up to 3 days |
๐ ๏ธ Add MCP Server in VS Code (STDIO)
-
Open Command Palette:
Ctrl/โ + Shift + P
โMCP: Add Server
-
Choose:
- Transport:
Command (stdio)
- Command:
uv
- Arguments:
["run", "meteo_mcp.py"]
- Transport:
-
The config will be saved (or added to) under:
// .vscode/mcp.json
{
"servers": {
"my-mcp-server-f963fb24": {
"type": "stdio",
"command": "uv",
"args": ["run", "meteo_mcp.py"]
}
}
}
๐ง Use GitHub Copilot Chat (as a Tool-Calling Agent)
-
Open GitHub Copilot Chat panel
-
Click 3-dot menu (โฎ) โ Enable Agent Mode
-
Ask:
Whatโs the 3-day forecast for Paris?
Copilot will:
- Call
get_coords("Paris")
- Then call
get_forecast(lat, lon, 3)
โ No glue code or prompt engineering needed โ tools are invoked automatically via MCP!
๐งช Test with MCP Inspector
- Install Inspector CLI (requires Node.js v18 or later):
npm install -g @modelcontextprotocol/inspector
- Launch the MCP Inspector in STDIO mode:
uv run mcp dev meteo_mcp.py
This starts both:
- A web UI at
http://localhost:6274
- An MCP proxy for debugging requests/responses
-
In the UI:
- Select a tool (
get_coords
,get_forecast
, etc.) - Provide JSON input (e.g.
{ "city": "Berlin" }
) - Run and inspect results
- Select a tool (
๐ External APIs Used
API | Purpose |
---|---|
https://geocoding-api.open-meteo.com/v1/search | Geocoding |
https://api.open-meteo.com/v1/forecast | Weather forecast |
Let me know if you want a template version of this for new MCP tool projects or want to integrate logging or unit tests.