Skip to main content
Glama
WhiteNightShadow

camoufox-reverse-mcp

get_console_logs

Retrieve console logs from a page with optional filtering by log level or keyword, and clear the buffer after retrieval.

Instructions

Get console output collected from the page.

Args: level: Filter by log level - "log", "warn", "error", or "info". keyword: Filter logs containing this keyword in the text. clear: If True, clear the log buffer after retrieval.

Returns: List of dicts with level, text, timestamp, and location.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
levelNo
keywordNo
clearNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The get_console_logs handler function decorated with @mcp.tool(). Collects console logs from browser_manager._console_logs, with optional filtering by level/keyword and clearing.
    @mcp.tool()
    async def get_console_logs(
        level: str | None = None,
        keyword: str | None = None,
        clear: bool = False,
    ) -> list[dict]:
        """Get console output collected from the page.
    
        Args:
            level: Filter by log level - "log", "warn", "error", or "info".
            keyword: Filter logs containing this keyword in the text.
            clear: If True, clear the log buffer after retrieval.
    
        Returns:
            List of dicts with level, text, timestamp, and location.
        """
        try:
            logs = list(browser_manager._console_logs)
            if level:
                logs = [l for l in logs if l["level"] == level]
            if keyword:
                logs = [l for l in logs if keyword in (l.get("text") or "")]
            if clear:
                browser_manager._console_logs.clear()
            return logs
        except Exception as e:
            return [{"error": str(e)}]
  • The hooking module (which contains get_console_logs) is imported and registered via from .tools import hooking in the server module.
    from .tools import navigation      # noqa: E402, F401  — browser control + page interaction
    from .tools import script_analysis  # noqa: E402, F401  — scripts() + search_code()
    from .tools import debugging        # noqa: E402, F401  — evaluate_js
    from .tools import hooking          # noqa: E402, F401  — hook_function + inject_hook_preset + remove_hooks
    from .tools import network          # noqa: E402, F401  — network_capture + list/get requests
  • The _console_logs deque is initialized in BrowserManager.__init__ with a maxlen of 2000, storing collected console messages.
    self._console_logs: deque[dict] = deque(maxlen=MAX_LOG_SIZE)
  • The _on_console method captures console messages from the page and appends them to _console_logs with level, text, timestamp, and location fields.
    def _on_console(self, msg) -> None:
        text = msg.text
        if text and text.startswith("__MCP_TRACE__:"):
            try:
                import json
                payload = json.loads(text[len("__MCP_TRACE__:"):])
                path = payload.pop("__path__", "unknown")
                self._persistent_traces.setdefault(path, []).append(payload)
            except Exception:
                pass
            return
    
        self._console_logs.append({
            "level": msg.type,
            "text": text,
            "timestamp": int(time.time() * 1000),
            "location": str(msg.location) if hasattr(msg, "location") else None,
        })
  • The _attach_listeners method registers _on_console as the console event handler on Playwright pages.
    def _attach_listeners(self, page: Page) -> None:
        """Attach console, network, and trace-collection listeners to a page."""
        page.on("console", self._on_console)
        page.on("request", self._on_request)
Behavior3/5

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

With no annotations, the description carries full burden. It discloses the clear buffer behavior and return structure, but does not mention page requirements, safety, or potential side effects. Adequate but not comprehensive.

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?

One-line purpose, then structured Args and Returns sections. Front-loaded and efficient with no wasted sentences.

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?

Covers all parameters and return format. Lacks prerequisites like requiring an open page or error handling, but for a simple retrieval tool, it is mostly complete.

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?

Schema description coverage is 0%, so the description fully compensates by detailing each parameter: level valid values, keyword as substring filter, clear buffer boolean. Adds significant meaning beyond the bare schema.

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

Purpose5/5

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

The description clearly states 'Get console output collected from the page', using a specific verb and resource. It distinguishes the tool from siblings by focusing on console logs, which is unique among the listed sibling tools.

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 like 'list_network_requests' or 'cookies'. The description implies usage for console log inspection but does not provide context or exclude scenarios.

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/WhiteNightShadow/camoufox-reverse-mcp'

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