Skip to main content
Glama

get_weather_page_content

Retrieves and cleans raw weather data from weather2day.co.il to provide real-time Israel weather information for LLM responses.

Instructions

שלב 4 (RAG): שולף את הטקסט מהדף ומנקה אותו עבור ה-LLM. מחזיר את המידע הגולמי כדי שהמודל יוכל לענות למשתמש.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main tool handler - async function decorated with @mcp.tool() that extracts weather forecast content from the page. It waits for body, tries specific CSS selectors (.forecast-text, .temp-value, .city-title, h1, .forecast-content), falls back to full body text if none found, cleans whitespace, and returns up to 4500 chars.
    @mcp.tool()
    async def get_weather_page_content() -> str:
        """
        שלב 4 (RAG): שולף את הטקסט מהדף ומנקה אותו עבור ה-LLM.
        מחזיר את המידע הגולמי כדי שהמודל יוכל לענות למשתמש.
        """
        page = await browser_mgr.ensure_page()
        try:
            # המתנה לטעינת התוכן המרכזי
            await page.wait_for_selector("body", timeout=10000)
            
            # חילוץ אלמנטים רלוונטיים (כותרות וטקסט תחזית)
            # ננסה לחלץ סלקטורים ספציפיים לתחזית בישראל
            selectors = [".forecast-text", ".temp-value", ".city-title", "h1", ".forecast-content"]
            extracted_texts = []
            
            for selector in selectors:
                elements = await page.query_selector_all(selector)
                for el in elements:
                    txt = await el.inner_text()
                    if txt.strip():
                        extracted_texts.append(txt.strip())
            
            # אם לא מצאנו סלקטורים ספציפיים, ניקח את כל ה-body
            if not extracted_texts:
                raw_text = await page.inner_text("body")
            else:
                raw_text = "\n".join(extracted_texts)
                
            # ניקוי רווחים כפולים ושורות ריקות לחיסכון ב-Tokens
            clean_text = "\n".join([line.strip() for line in raw_text.splitlines() if line.strip()])
            
            # החזרת התוכן (מוגבל באורך כדי לא להעמיס על הקונטקסט)
            return f"--- נתוני תחזית גולמיים ---\n{clean_text[:4500]}\n--- סוף נתונים ---"
        except Exception as e:
            return f"ERROR: חילוץ התוכן נכשל: {str(e)}"
  • Tool registered via @mcp.tool() decorator on the async function, using FastMCP framework.
    @mcp.tool()
  • The handler takes no parameters and returns a string (str return type annotation). No Pydantic or validation schema defined.
    async def get_weather_page_content() -> str:
  • Shared global WeatherBrowserManager instance (browser_mgr) used by the handler to get the Playwright page.
    # יצירת מופע גלובלי לניהול הדפדפן
    browser_mgr = WeatherBrowserManager()
  • WeatherBrowserManager class with ensure_page() helper that manages browser lifecycle and page creation for Playwright.
    class WeatherBrowserManager:
        """מנהל דפדפן יציב שתומך בשימוש חוזר בדף ובמעקף חסימות"""
        def __init__(self):
            self.playwright = None
            self.browser = None
            self.context = None
            self.page = None
    
        async def ensure_page(self):
            """מוודא שהדפדפן והדף פתוחים ומוכנים לעבודה"""
            if self.page is None or self.browser is None:
                self.playwright = await async_playwright().start()
                # headless=False כדי שנוכל לראות את הקסם קורה
                self.browser = await self.playwright.chromium.launch(headless=False)
                
                # הגדרות קריטיות לנטפרי (ignore_https_errors) ולזיהוי בוטים
                self.context = await self.browser.new_context(
                    ignore_https_errors=True,
                    user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
                )
                
                self.page = await self.context.new_page()
                # הגנה נוספת מפני זיהוי כבוט
                await self.page.add_init_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")
                
            return self.page
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions 'retrieves and cleans' but does not disclose side effects, whether it makes external calls, or what 'cleaning' entails. Transparency is low.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two sentences, no wasted words. It is front-loaded with the step and purpose. Could be slightly more structured, but effective.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no parameters and an output schema exists (so return values not needed), the description is minimal but functional. However, it lacks context about which page is being referred to and how it fits with sibling tools, so it is not fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has zero parameters, so schema description coverage is 100%. The description does not need to add parameter information, and the baseline score of 4 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states that the tool retrieves text from a page and cleans it for the LLM, indicating a specific action and resource. However, it does not specify which page or distinguish it from sibling tools, so it is not a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives. The description only mentions it is 'Step 4 (RAG)', but does not explain context or when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lea-blum/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server