mcpField
🌦
🌦️ MCP Weather Scraper

🌦️ MCP Weather Scraper

Local
github.com/EXPESRazaBrowser Automation0Updated 80w ago

About 🌦️ MCP Weather Scraper

MCP Weather Scraper is a FastAPI prototype for developers exploring LLM and MCP tool interactions. It parses open web content and uses OpenAI to turn weather information into structured data.

Key features

  1. 01Scrapes and parses web weather data
  2. 02Uses OpenAI to extract structured data
  3. 03Provides weather queries as an MCP tool
  4. 04Caches responses to avoid repeated requests
  5. 05Shows results and metrics in a Streamlit UI

Use cases

  1. 01Query current weather by location
  2. 02Convert web weather content into structured results
  3. 03Review request time and OpenAI token usage

MCP support

The server exposes a weather-query tool to MCP clients. It scrapes open web sources and returns structured weather data.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

🌦️ MCP Weather Scraper

This project is an experimental implementation of the Model Context Protocol (MCP) using a lightweight LLM via ** OpenAI** and FastAPI to fetch and structure real-time weather information from open web sources. The goal is to explore how LLMs can interact with tools and serve as intelligent agents for retrieving and reasoning over unstructured web data.


Python License Issues


πŸš€ Features

  • βœ… MCP-compliant server with weather scraping via browser search
  • βœ… Integration with OpenAI LLM (e.g., gpt-3.5-turbo)
  • βœ… FastAPI server provides weather info as callable MCP tool
  • βœ… Automatic HTML parsing using selectolax for performance
  • βœ… LLM handles unstructured web content extraction into structured schema
  • βœ… Streamlit app frontend for user interaction
  • βœ… Response caching using functools.lru_cache

🧠 Refresh Before You Dive In

Top 5 Concepts to Brush Up On for This Repo

🧩 ConceptπŸ” What It Isβš™οΈ Why It Matters
Model Context Protocol (MCP)A new protocol for tool-calling in LLMsPowers structured AI-agent communication
UvicornFast ASGI server for Python web appsHosts the FastAPI-based MCP server
SelectolaxHigh-speed HTML parserEfficiently scrapes and extracts weather data
functools.lru_cacheBuilt-in Python decorator to cache function callsBoosts performance by avoiding repeated fetches
Token Usage Metrics (OpenAI)Info on how many tokens were used in an LLM callHelps track cost and optimize prompt design

πŸ’‘ Even if you're familiar with Python and APIs, these tools represent cutting-edge AI stack engineering and are worth a quick look!


πŸ“Š Token Usage & Performance Metrics

The Streamlit UI now includes:

  • ⏱️ Response Time
    Time taken to fetch and process weather info

  • 🧠 Prompt Tokens
    Tokens used in the LLM prompt

  • πŸ’¬ Completion Tokens
    Tokens generated in the LLM response

  • πŸ”’ Total Tokens
    Total token count per request, useful for cost tracking

These are displayed in a clean visual layout under each result card.


πŸ–₯️ Streamlit App Preview

README image


Requirements

  • Python 3.9 or higher
  • Dependencies listed in requirements.txt

πŸ› οΈ Setup

  1. Clone the repo
    git clone https://github.com/your-username/mcp_weather_scraper.git
    cd mcp_weather_scraper
    
  2. Create and activate a virtual environment
    python -m venv .venv
    .venv\Scripts\activate  # On Windows
    
  3. Install dependencies
    pip install -r requirements.txt
    
  4. Set environment variables Create a .env file in the root directory and add your OpenAI API key
    OPENAI_API_KEY=your_openai_api_key
    
  5. Running the Server
    uvicorn server:app --reload
    
    The server will be available at http://localhost:8000. You can access the API documentation at:
  6. Making a Request
    python client.py
    
    OR
    curl -X POST http://localhost:8000/weather -H "Content-Type: application/json" -d '{"location": "Seattle"}'
    
    The script sends a POST request with the following payload:
    {
      "location": "Seattle"
    }
    
    The server will respond with weather data in JSON format, such as:
    {
      "location": "Seattle",
      "temperature": "15Β°C",
      "humidity": "80%",
      "air_quality": "Good",
      "condition": "Cloudy"
    }
    

πŸ“¦ Folder Structure

.
πŸ“ mcp_weather_scraper/
β”‚
β”œβ”€β”€ assets/
β”‚   └── streamlit_screenshot.png
β”œβ”€β”€ server.py          # MCP-compatible tool server
β”œβ”€β”€ client.py          # MCP client that interacts with model + tools
β”œβ”€β”€ data_models.py     # Pydantic schemas for request/response
β”œβ”€β”€ utils.py           # HTML cleaning, scraping, etc.
β”œβ”€β”€ requirements.txt
└── .env

πŸ“„ License

This project is licensed under the MIT License.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.