Skip to main content
Glama
WhiteNightShadow

camoufox-reverse-mcp

scripts

List all loaded scripts, retrieve full source of a specific script, or save script source to a local file. Used for inspecting scripts during JavaScript reverse engineering.

Instructions

Script inspection (v0.9.0 unified).

Replaces list_scripts / get_script_source / save_script.

Args: action: "list" — list all loaded scripts (src, type, inline preview) "get" — get full source of one script (requires url; use "inline:" for inline scripts) "save" — save script source to local file (requires url + save_path) url: Script URL or "inline:" (required for "get" and "save"). save_path: Local file path (required for "save").

Returns: For "list": list of script info dicts. For "get": dict with source string. For "save": dict with status, path, size.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes
urlNo
save_pathNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `scripts` MCP tool handler - dispatches list/get/save actions for script inspection. Registered via @mcp.tool() decorator.
    @mcp.tool()
    async def scripts(
        action: str,
        url: str | None = None,
        save_path: str | None = None,
    ) -> dict | list | str:
        """Script inspection (v0.9.0 unified).
    
        Replaces list_scripts / get_script_source / save_script.
    
        Args:
            action:
              "list" — list all loaded scripts (src, type, inline preview)
              "get"  — get full source of one script (requires url;
                       use "inline:<index>" for inline scripts)
              "save" — save script source to local file (requires url + save_path)
            url: Script URL or "inline:<index>" (required for "get" and "save").
            save_path: Local file path (required for "save").
    
        Returns:
            For "list": list of script info dicts.
            For "get": dict with source string.
            For "save": dict with status, path, size.
        """
        if action == "list":
            return await _list_scripts()
        elif action == "get":
            if not url:
                return {"error": "url is required for action='get'"}
            src = await _get_script_source(url)
            return {"source": src, "url": url, "length": len(src) if isinstance(src, str) else 0}
        elif action == "save":
            if not url:
                return {"error": "url is required for action='save'"}
            if not save_path:
                return {"error": "save_path is required for action='save'"}
            return await _save_script(url, save_path)
        else:
            return {"error": f"unknown action: {action}. Use list/get/save"}
  • The `search_code` MCP tool handler - searches keywords in loaded scripts across all or a single script.
    @mcp.tool()
    async def search_code(
        keyword: str,
        script_url: str | None = None,
        context_chars: int = 200,
        context_lines: int = 3,
        max_results: int = 200,
    ) -> dict:
        """Search keyword in loaded scripts (v0.9.0 unified).
    
        Replaces search_code (all scripts) + search_code_in_script (single script).
    
        Args:
            keyword: The keyword to search for (case-sensitive substring match).
            script_url: If None, search across ALL loaded scripts.
                If given, search within that one script only (supports
                "inline:<index>" for inline scripts). Single-script mode
                auto-detects minified files and uses character-based context.
            context_chars: Context window in char mode (default 200 = +/-200 chars).
                Used when searching single minified scripts.
            context_lines: Context window in line mode (default 3).
            max_results: Maximum matches to return (default 200).
    
        Returns:
            dict with matches, total_matches, mode ("line" | "char"), etc.
        """
        if script_url is None:
            return await _search_code_all(keyword, max_results)
        else:
            return await _search_code_in_script(
                script_url, keyword, context_lines, context_chars, max_results
            )
  • Internal helper `_list_scripts` - enumerates all <script> elements on the page via DOM query.
    async def _list_scripts() -> list[dict]:
        try:
            page = await browser_manager.get_active_page()
            scripts_list = await page.evaluate("""() => {
                const scripts = document.querySelectorAll('script');
                return Array.from(scripts).map((s, i) => ({
                    index: i,
                    src: s.src || null,
                    type: s.type || 'text/javascript',
                    is_module: s.type === 'module',
                    inline_length: s.src ? 0 : (s.textContent || '').length,
                    preview: s.src ? null : (s.textContent || '').substring(0, 200)
                }));
            }""")
            # v1.0.1: add hint for large scripts
            for s in scripts_list:
                size = s.get("inline_length", 0)
                src = s.get("src")
                if src and size == 0:
                    # For external scripts, we don't know size yet from DOM alone
                    # but we can hint based on common patterns
                    pass
                elif size > 100_000:
                    s["hint"] = (
                        f"Large script ({size} bytes). Consider saving for "
                        f"offline analysis: scripts(action='save', "
                        f"url='inline:{s['index']}', save_path='./script_{s['index']}.js')"
                    )
            return scripts_list
        except Exception as e:
            return [{"error": str(e)}]
  • Internal helper `_get_script_source` - retrieves inline or external script source via page.evaluate.
    async def _get_script_source(url: str) -> str:
        try:
            page = await browser_manager.get_active_page()
            if url.startswith("inline:"):
                idx = int(url.split(":")[1])
                source = await page.evaluate(f"""() => {{
                    const scripts = document.querySelectorAll('script');
                    return scripts[{idx}] ? scripts[{idx}].textContent : null;
                }}""")
                return source or f"Inline script at index {idx} not found"
            else:
                source = await page.evaluate(f"""async () => {{
                    try {{
                        const resp = await fetch("{url}");
                        return await resp.text();
                    }} catch(e) {{
                        return "Fetch error: " + e.message;
                    }}
                }}""")
                return source
        except Exception as e:
            return f"Error: {e}"
  • Registration import that loads the script_analysis module (and thus the @mcp.tool() decorated functions) into the server.
    from .tools import script_analysis  # noqa: E402, F401  — scripts() + search_code()
Behavior3/5

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

No annotations are provided, so description carries full burden. It discloses return formats for each action and the save action's side effect (writing to local file). However, it does not detail file overwrite behavior or potential permissions needed.

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 well-structured with a title, version note, replacement info, clear args list, and returns. Every sentence adds value, and it is front-loaded with the core purpose. No unnecessary words.

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?

Output schema exists, but description still provides return info. However, it lacks error handling details and there is a slight mismatch: schema makes 'url' optional but description implies it's required for get/save. Adequate but incomplete for edge cases.

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?

Schema coverage is 0%, so description compensates well. It explains the 'action' parameter with its three string values, the 'url' format including inline scripts, and 'save_path' requirement. Adds meaning beyond the schema's type-only definitions.

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 it's for 'Script inspection' and unifies three previous tools. It specifies three actions (list, get, save) with distinct purposes, and is distinguishable from sibling tools focused on browser automation.

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

Usage Guidelines4/5

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

The description explains when to use each action (list, get, save) and their requirements. It mentions replacing previous tools, providing good context, but does not explicitly state when not to use or offer alternatives among siblings.

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