Skip to main content
Glama
Fadi88

LLM Inference Pricing Research Server

by Fadi88

scrape_websites

Extract pricing data from LLM inference provider websites using Firecrawl to collect and store content for research and comparison.

Instructions

Scrape multiple websites using Firecrawl and store their content.

Args:
    websites: Dictionary of provider_name -> URL mappings
    formats: List of formats to scrape ['markdown', 'html'] (default: both)
    api_key: Firecrawl API key (if None, expects environment variable)
    
Returns:
    List of provider names for successfully scraped websites

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
websitesYes
formatsNo
api_keyNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'scrape_websites' tool. It uses FirecrawlApp to scrape websites specified in a dict of provider_name to URL, saves content in markdown/html formats to files, updates metadata.json, and returns list of successfully scraped providers. Registered via @mcp.tool() decorator.
    @mcp.tool()
    def scrape_websites(
        websites: Dict[str, str],
        formats: List[str] = ['markdown', 'html'],
        api_key: Optional[str] = None
    ) -> List[str]:
        """
        Scrape multiple websites using Firecrawl and store their content.
        
        Args:
            websites: Dictionary of provider_name -> URL mappings
            formats: List of formats to scrape ['markdown', 'html'] (default: both)
            api_key: Firecrawl API key (if None, expects environment variable)
            
        Returns:
            List of provider names for successfully scraped websites
        """
        
        if api_key is None:
            api_key = os.getenv('FIRECRAWL_API_KEY')
            if not api_key:
                raise ValueError("API key must be provided or set as FIRECRAWL_API_KEY environment variable")
        
        app = FirecrawlApp(api_key=api_key)
        
        path = os.path.join(SCRAPE_DIR)
        os.makedirs(path, exist_ok=True)
        
        # save the scraped content to files and then create scraped_metadata.json as a summary file
        # check if the provider has already been scraped and decide if you want to overwrite
        metadata_file = os.path.join(path, "scraped_metadata.json")
        
        existing_metadata = {}
        if os.path.exists(metadata_file):
            try:
                with open(metadata_file, "r") as f:
                    existing_metadata = json.load(f)
            except json.JSONDecodeError:
                logger.warning(f"Could not decode {metadata_file}, starting fresh.")
    
        scraped_providers = []
    
        for provider, url in websites.items():
            logger.info(f"Scraping {provider} at {url}")
            
            try:
                scrape_result = app.scrape(url, formats=formats)
                
                # Prepare metadata entry
                timestamp = datetime.now().isoformat()
                domain = urlparse(url).netloc
                
                content_files = {}
                for fmt in formats:
                    content = getattr(scrape_result, fmt, "")
                    if content:
                        filename = f"{provider}_{fmt}.txt"
                        file_path = os.path.join(path, filename)
                        with open(file_path, "w", encoding="utf-8") as f:
                            f.write(content)
                        content_files[fmt] = filename
                
                # Handle metadata safely
                title = "Unknown Title"
                description = "No description"
                if hasattr(scrape_result, 'metadata'):
                    title = getattr(scrape_result.metadata, 'title', "Unknown Title")
                    description = getattr(scrape_result.metadata, 'description', "No description")
    
                metadata_entry = {
                    "provider_name": provider,
                    "url": url,
                    "domain": domain,
                    "scraped_at": timestamp,
                    "formats": formats,
                    "success": "true",
                    "content_files": content_files,
                    "title": title,
                    "description": description
                }
                
                existing_metadata[provider] = metadata_entry
                scraped_providers.append(provider)
                logger.info(f"Successfully scraped {provider}")
                
            except Exception as e:
                logger.error(f"Failed to scrape {provider}: {e}")
                # Optionally record failure in metadata
                existing_metadata[provider] = {
                    "provider_name": provider,
                    "url": url,
                    "scraped_at": datetime.now().isoformat(),
                    "success": "false",
                    "error": str(e)
                }
    
        with open(metadata_file, "w", encoding="utf-8") as f:
            json.dump(existing_metadata, f, indent=4)
    
        return scraped_providers
  • Registration of the scrape_websites tool using the FastMCP decorator.
    @mcp.tool()
  • Input/output schema defined by type hints and docstring: websites dict, optional formats list and api_key, returns list of str.
    def scrape_websites(
        websites: Dict[str, str],
        formats: List[str] = ['markdown', 'html'],
        api_key: Optional[str] = None
    ) -> List[str]:
        """
        Scrape multiple websites using Firecrawl and store their content.
        
        Args:
            websites: Dictionary of provider_name -> URL mappings
            formats: List of formats to scrape ['markdown', 'html'] (default: both)
            api_key: Firecrawl API key (if None, expects environment variable)
            
        Returns:
            List of provider names for successfully scraped websites
        """
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that content is stored, which implies persistence, but doesn't specify where or how. It also mentions the API key fallback to environment variables, which is useful context. However, it lacks critical behavioral details like rate limits, error handling, authentication requirements beyond the API key, or what happens if scraping fails for some websites.

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

Conciseness5/5

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

The description is appropriately sized and well-structured. It starts with a clear purpose statement, then lists parameters with helpful explanations, and ends with return information. Every sentence adds value with no redundancy or unnecessary details.

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

Completeness4/5

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

Given the tool's complexity (3 parameters, nested objects, no annotations) and the presence of an output schema (which covers return values), the description does a good job. It explains parameters thoroughly and states the return type. However, for a tool that performs web scraping and storage operations, more behavioral context (like error handling or storage details) would make it more 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 description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that 'websites' is a dictionary mapping provider names to URLs, clarifies that 'formats' accepts specific values with a default, and describes the 'api_key' parameter's behavior with environment variable fallback. This compensates well for the schema's lack of descriptions, though it doesn't fully document all parameter nuances.

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 the tool's purpose: 'Scrape multiple websites using Firecrawl and store their content.' This includes a specific verb ('scrape'), resource ('websites'), and technology ('Firecrawl'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from its sibling tool 'extract_scraped_info'.

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?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of the sibling tool 'extract_scraped_info' or any other context about appropriate use cases. The only implied usage is for scraping websites with Firecrawl, but no explicit when/when-not guidance is provided.

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/Fadi88/UDACITY_MCP'

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