Skip to main content
Glama
ronantakizawa

Search History MCP Server

get_recent_history

Retrieve recent browsing history entries from browsers like Chrome, Firefox, Safari, or Edge to access past visited websites with titles, URLs, and timestamps.

Instructions

Get the most recent browsing history entries.

Args: limit: Maximum number of results to return (default: 50, max: 500) browser: Which browser to query ("brave", "safari", "chrome", "firefox", "edge", "arc", "opera", or "duckduckgo")

Returns: Formatted list of recent history entries with titles, URLs, and visit times

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
browserNobrave

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Handler function for the 'get_recent_history' MCP tool. Decorated with @mcp.tool for registration. Queries browser history databases (supporting multiple browsers like Brave, Safari, Chrome, etc.) using specific SQL queries, processes timestamps appropriately for each browser, and returns a formatted string list of recent history entries with titles, URLs, visit counts, and last visit times.
    @mcp.tool
    def get_recent_history(limit: int = 50, browser: Literal["brave", "safari", "chrome", "firefox", "edge", "arc", "opera", "duckduckgo"] = "brave") -> str:
        """
        Get the most recent browsing history entries.
    
        Args:
            limit: Maximum number of results to return (default: 50, max: 500)
            browser: Which browser to query ("brave", "safari", "chrome", "firefox", "edge", "arc", "opera", or "duckduckgo")
    
        Returns:
            Formatted list of recent history entries with titles, URLs, and visit times
        """
        if limit > 500:
            limit = 500
    
        if browser == "duckduckgo":
            if is_duckduckgo_encrypted():
                # DuckDuckGo macOS - encrypted database schema
                query = """
                    SELECT
                        ZURLENCRYPTED,
                        ZTITLEENCRYPTED,
                        ZNUMBEROFTOTALVISITS,
                        ZNUMBEROFTRACKERSBLOCKED,
                        ZLASTVISIT
                    FROM ZHISTORYENTRYMANAGEDOBJECT
                    WHERE ZURLENCRYPTED IS NOT NULL
                    ORDER BY ZLASTVISIT DESC
                    LIMIT ?
                """
                results = query_duckduckgo_db(query, (limit,))
            else:
                # DuckDuckGo Windows - Chromium-based
                query = """
                SELECT url, title, visit_count, last_visit_time
                FROM urls
                WHERE url NOT LIKE 'https://static.ddg.local/%'
                ORDER BY last_visit_time DESC
                LIMIT ?
                """
                results = query_history_db(query, (limit,), browser)
    
        elif browser == "safari":
            # Safari database schema
            query = """
            SELECT
                history_items.url as url,
                history_visits.title as title,
                COUNT(history_visits.id) as visit_count,
                MAX(history_visits.visit_time) as last_visit_time
            FROM history_items
            JOIN history_visits ON history_items.id = history_visits.history_item
            GROUP BY history_items.url
            ORDER BY last_visit_time DESC
            LIMIT ?
            """
        elif browser == "firefox":
            # Firefox database schema (places.sqlite)
            query = """
            SELECT
                url, title, visit_count,
                last_visit_date as last_visit_time
            FROM moz_places
            WHERE hidden = 0
            ORDER BY last_visit_time DESC
            LIMIT ?
            """
        else:
            # Chromium-based browsers (Brave/Chrome/Edge/Arc/Opera) database schema
            query = """
            SELECT url, title, visit_count, last_visit_time
            FROM urls
            ORDER BY last_visit_time DESC
            LIMIT ?
            """
    
        # Query databases (DuckDuckGo already queried above)
        if browser != "duckduckgo":
            results = query_history_db(query, (limit,), browser)
    
        if not results:
            return f"No history entries found in {browser.capitalize()}"
    
        output = [f"Most recent {len(results)} {browser.capitalize()} browsing history entries:\n"]
    
        for i, entry in enumerate(results, 1):
            title = entry['title'] or "No title"
            url = entry['url']
            visit_count = entry['visit_count']
    
            if browser == "duckduckgo":
                if is_duckduckgo_encrypted():
                    # macOS encrypted version has trackers blocked
                    last_visit = cocoa_timestamp_to_datetime(entry['last_visit_time'])
                    trackers_blocked = entry.get('trackers_blocked', 0)
                    output.append(f"{i}. {title}")
                    output.append(f"   URL: {url}")
                    output.append(f"   Visits: {visit_count} | Trackers blocked: {trackers_blocked} | Last visited: {last_visit}")
                    output.append("")
                else:
                    # Windows Chromium version
                    last_visit = chrome_timestamp_to_datetime(entry['last_visit_time'])
                    output.append(f"{i}. {title}")
                    output.append(f"   URL: {url}")
                    output.append(f"   Visits: {visit_count} | Last visited: {last_visit}")
                    output.append("")
            elif browser == "safari":
                last_visit = safari_timestamp_to_datetime(entry['last_visit_time'])
                output.append(f"{i}. {title}")
                output.append(f"   URL: {url}")
                output.append(f"   Visits: {visit_count} | Last visited: {last_visit}")
                output.append("")
            elif browser == "firefox":
                last_visit = firefox_timestamp_to_datetime(entry['last_visit_time'])
                output.append(f"{i}. {title}")
                output.append(f"   URL: {url}")
                output.append(f"   Visits: {visit_count} | Last visited: {last_visit}")
                output.append("")
            else:
                last_visit = chrome_timestamp_to_datetime(entry['last_visit_time'])
                output.append(f"{i}. {title}")
                output.append(f"   URL: {url}")
                output.append(f"   Visits: {visit_count} | Last visited: {last_visit}")
                output.append("")
    
        return "\n".join(output)
  • mcp_server.py:609-609 (registration)
    The @mcp.tool decorator registers the get_recent_history function as an MCP tool.
    @mcp.tool
  • Type hints and docstring define the input schema (limit: int, browser: Literal[...]), output str, and description for the tool.
    def get_recent_history(limit: int = 50, browser: Literal["brave", "safari", "chrome", "firefox", "edge", "arc", "opera", "duckduckgo"] = "brave") -> str:
        """
        Get the most recent browsing history entries.
    
        Args:
            limit: Maximum number of results to return (default: 50, max: 500)
            browser: Which browser to query ("brave", "safari", "chrome", "firefox", "edge", "arc", "opera", or "duckduckgo")
    
        Returns:
            Formatted list of recent history entries with titles, URLs, and visit times
        """
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 the tool 'gets' data (implying read-only), but doesn't address important behavioral aspects like authentication requirements, rate limits, privacy implications, or whether it accesses local browser data versus a centralized service. The description is minimal on behavioral context.

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 perfectly structured and concise. It starts with the core purpose, then provides clear parameter documentation in a well-organized format, and ends with return value information. Every sentence earns its place with no wasted words.

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 moderate complexity (2 parameters, read operation), the description is quite complete. It explains the purpose, documents both parameters thoroughly, and describes the return format. With an output schema present, the description doesn't need to detail return values extensively. The main gap is the lack of sibling tool differentiation.

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

Parameters5/5

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

The description provides excellent parameter semantics despite 0% schema description coverage. It clearly explains what 'limit' means ('Maximum number of results to return') with default and max values, and explains 'browser' as 'Which browser to query' with a complete list of options. This fully compensates for the lack of schema descriptions.

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 with a specific verb ('Get') and resource ('most recent browsing history entries'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_most_visited' or 'search_history', which would be needed for a perfect score.

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 the sibling tools 'get_most_visited' and 'search_history'. It mentions what the tool does but offers no context about when it's appropriate versus alternatives, leaving the agent to guess based on tool names alone.

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/ronantakizawa/search-history-mcp'

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