Meteo_MCP_server_tuto

Imel23/Meteo_MCP_server_tuto

3.2

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.

Tools
  1. get_coords

    Fetches the latitude and longitude of a given city.

  2. get_current_weather

    Retrieves the current weather information for the specified coordinates.

  3. 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:

ToolDescription
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)

  1. Open Command Palette: Ctrl/โŒ˜ + Shift + P โ†’ MCP: Add Server

  2. Choose:

    • Transport: Command (stdio)
    • Command: uv
    • Arguments: ["run", "meteo_mcp.py"]
  3. 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)

  1. Open GitHub Copilot Chat panel

  2. Click 3-dot menu (โ‹ฎ) โ†’ Enable Agent Mode

  3. 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

  1. Install Inspector CLI (requires Node.js v18 or later):
npm install -g @modelcontextprotocol/inspector
  1. 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
  1. In the UI:

    • Select a tool (get_coords, get_forecast, etc.)
    • Provide JSON input (e.g. { "city": "Berlin" })
    • Run and inspect results

๐ŸŒ External APIs Used


Let me know if you want a template version of this for new MCP tool projects or want to integrate logging or unit tests.