Meteo_MCP_server_tuto

This repository is a minimal tutorial for building and using an MCP (Model-Context-Protocol) server with FastMCP in Python. It demonstrates how to expose simple weather tools (get_coords, get_forecast) and use them directly in GitHub Copilot Chat in VS Code via the STDIO protocol — no extra API or plugin code required.

GitHub Stars

0

User Rating

Not Rated

Favorites

0

Views

6

Forks

0

Issues

0

README
🚀 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)
  1. Open Command Palette: Ctrl/⌘ + Shift + PMCP: 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
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.

Author Information

0

Followers

0

Repositories

0

Gists

0

Total Contributions