Skip to main content
Glama
WhiteNightShadow

camoufox-reverse-mcp

intercept_request

Intercept network requests matching a URL pattern to log, block, modify, mock, or stop them.

Instructions

Intercept network requests matching a pattern.

Args: url_pattern: URL glob pattern (e.g. "**/api/login*"). action: "log", "block", "modify", "mock", or "stop" (unroute). modify_headers: Headers to add/override (action="modify"). modify_body: Request body replacement (action="modify"). mock_response: Dict with "status", "headers", "body" (action="mock").

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
url_patternYes
actionNolog
modify_headersNo
modify_bodyNo
mock_responseNo

Implementation Reference

  • The main handler for the intercept_request MCP tool. Registers a Playwright page.route() with a closure that handles four actions: log (records request to console_logs), block (aborts the request), modify (overrides headers/body), and mock (fulfills with a custom response). Also supports 'stop' action to unroute.
    @mcp.tool()
    async def intercept_request(
        url_pattern: str,
        action: str = "log",
        modify_headers: dict | None = None,
        modify_body: str | None = None,
        mock_response: dict | None = None,
    ) -> dict:
        """Intercept network requests matching a pattern.
    
        Args:
            url_pattern: URL glob pattern (e.g. "**/api/login*").
            action: "log", "block", "modify", "mock", or "stop" (unroute).
            modify_headers: Headers to add/override (action="modify").
            modify_body: Request body replacement (action="modify").
            mock_response: Dict with "status", "headers", "body" (action="mock").
        """
        try:
            page = await browser_manager.get_active_page()
    
            if action == "stop":
                if url_pattern:
                    await page.unroute(url_pattern)
                    return {"status": "stopped", "pattern": url_pattern}
                else:
                    await page.unroute("**/*")
                    return {"status": "stopped_all"}
    
            async def handler(route):
                if action == "log":
                    browser_manager._console_logs.append({
                        "level": "info",
                        "text": f"[INTERCEPT:log] {route.request.method} {route.request.url}",
                        "timestamp": time.time() * 1000, "location": None,
                    })
                    await route.continue_()
                elif action == "block":
                    await route.abort()
                elif action == "modify":
                    overrides = {}
                    if modify_headers:
                        overrides["headers"] = {**dict(route.request.headers), **modify_headers}
                    if modify_body:
                        overrides["post_data"] = modify_body
                    await route.continue_(**overrides)
                elif action == "mock":
                    resp = mock_response or {}
                    await route.fulfill(
                        status=resp.get("status", 200),
                        headers=resp.get("headers", {"content-type": "application/json"}),
                        body=resp.get("body", "{}"),
                    )
    
            await page.route(url_pattern, handler)
            return {"status": "intercepting", "pattern": url_pattern, "action": action}
        except Exception as e:
            return {"error": str(e)}
  • Input schema for intercept_request: url_pattern (required URL glob), action (log/block/modify/mock/stop, default 'log'), modify_headers (optional dict), modify_body (optional string), mock_response (optional dict with status/headers/body). Returns a dict.
        url_pattern: str,
        action: str = "log",
        modify_headers: dict | None = None,
        modify_body: str | None = None,
        mock_response: dict | None = None,
    ) -> dict:
        """Intercept network requests matching a pattern.
    
        Args:
            url_pattern: URL glob pattern (e.g. "**/api/login*").
            action: "log", "block", "modify", "mock", or "stop" (unroute).
            modify_headers: Headers to add/override (action="modify").
            modify_body: Request body replacement (action="modify").
            mock_response: Dict with "status", "headers", "body" (action="mock").
        """
  • Registration of intercept_request via the @mcp.tool() decorator, where 'mcp' is a FastMCP instance from the server module.
    @mcp.tool()
Behavior3/5

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

Describes actions (log, block, modify, mock, stop) and conditional parameters, but lacks details on side effects like persistence or prerequisites (e.g., network capture enabled).

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

Conciseness4/5

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

Concise docstring format with clear front-loaded purpose; each sentence adds value, though slightly repetitive in listing parameters.

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

Completeness2/5

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

Despite 5 parameters and no schema coverage, description fails to fully document return value, data types for complex objects, and prerequisite conditions.

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

Parameters3/5

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

Adds meaning to parameters beyond the schema (e.g., 'url_pattern: URL glob pattern', 'action: log, block, ...'), but lacks precise formats for modify_headers and mock_response dicts.

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?

Clearly states the verb 'Intercept' and resource 'network requests matching a pattern', distinguishing it from siblings like get_network_request and list_network_requests.

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 siblings like get_network_request or list_network_requests; description focuses only on arguments.

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