Skip to main content
Glama

tool_monitor_changes

Monitor web page changes by comparing content hashes to detect modifications over time, providing change detection reports for tracking updates.

Instructions

Check if a page has changed.

Tracks content modifications over time.

Args: url: URL to monitor. previous_hash: Previous content hash to compare against.

Returns: Change detection report with content hash.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
previous_hashNo

Implementation Reference

  • The actual implementation of the monitor_changes logic, which fetches the page and performs content comparison.
    async def monitor_changes(url: str, previous_content: str | None = None) -> str:
        """Check if a page has changed since last check.
    
        Args:
            url: URL to monitor.
            previous_content: Previous content hash or snippet to compare.
    
        Returns:
            Change detection report.
    
        Example:
            >>> changes = await monitor_changes("https://example.com", previous_hash)
        """
        try:
            doc = await _scraper.fetch(url, retry=1)
            current_content = doc.content
    
            # Generate content hash
            import hashlib
    
            current_hash = hashlib.sha256(current_content.encode()).hexdigest()[:16]
    
            report_lines = [
                f"# Change Monitor: {doc.title}\n",
                f"> URL: {url}\n",
                f"> Checked: {doc.fetched_at.strftime('%Y-%m-%d %H:%M:%S')}\n",
                "\n## Status\n",
            ]
    
            if previous_content:
                if previous_content == current_hash:
                    report_lines.append("✓ **No changes detected**\n")
                else:
                    report_lines.append("⚠️ **Content has changed**\n")
                    report_lines.append(f"\n- Previous hash: `{previous_content}`\n")
                    report_lines.append(f"- Current hash: `{current_hash}`\n")
            else:
                report_lines.append("ℹ️ **First check - baseline established**\n")
                report_lines.append(f"\n- Content hash: `{current_hash}`\n")
    
            # Add content preview
            report_lines.append("\n## Current Content Preview\n")
            preview = current_content[:500].strip()
            report_lines.append(f"{preview}...\n")
  • The MCP tool registration and wrapper function tool_monitor_changes that delegates to the monitor_changes helper.
    @mcp.tool()
    async def tool_monitor_changes(url: str, previous_hash: str | None = None) -> str:
        """Check if a page has changed.
    
        Tracks content modifications over time.
    
        Args:
            url: URL to monitor.
            previous_hash: Previous content hash to compare against.
    
        Returns:
            Change detection report with content hash.
        """
        return await monitor_changes(url, previous_hash)

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/Y4NN777/devlens-mcp'

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