web-eval-agent

repository·main·Indexed 22 days ago

https://github.com/refreshdotdev/web-eval-agent

An MCP (Model Context Protocol) server that enables coding agents like Cursor and Claude Code to autonomously navigate, test, and debug web applications. It features a browser-use powered agent for UX evaluation via the `web_eval_agent` tool, which captures screenshots, console logs, and network logs. It also includes a `setup_browser_state` tool for manual authentication and state persistence.

Tokens
2.1K
Snippets
3
Records
14
Agent score
78%

What's inside web-eval-agent

  1. Install the web-eval-agent MCP Server

    main

    You can install the web-eval-agent MCP server using either a one-click integration or manual setup.

    One-Click Integration

    1. Get an API key from operative.sh/mcp.
    2. Use the "Add to Cursor" button for instant installation in Cursor.

    Manual Setup (macOS/Linux)

    1. Get an API key from operative.sh/mcp.
    2. Install uv using:
      curl -LsSf https://astral.sh/uv/install.sh | sh
    3. Source your environment (e.g., source ~/.zshrc or source ~/.bashrc).
    4. Install Playwright and its dependencies:
      npm install -g chromium playwright && uvx --with playwright playwright install --with-deps
    5. Add the MCP server configuration JSON to your IDE (Cursor, Cline, or Windsurf) and restart the editor.

    Manual Setup (Windows)

    1. Open your code editor terminal.
    2. Run the installer script:
      curl -LSf https://operative.sh/install.sh -o install.sh && bash install.sh && rm install.sh
    3. Get an API key from operative.sh/mcp.
    4. Install uv:
      curl -LsSf https://astral.sh/uv/install.sh | sh
    5. Install Playwright via uvx:
      uvx --from git+https://github.com/Operative-Sh/web-eval-agent.git playwright install
    6. Restart your code editor.
    curl -LSf https://operative.sh/install.sh -o install.sh && bash install.sh && rm install.sh
  2. Configure the web-eval-agent MCP server in your IDE

    main

    To manually add the web-eval-agent to your IDE (Cursor, Cline, or Windsurf), add the following JSON configuration. Replace <YOUR_KEY> with your actual API key from operative.sh/mcp.

    {
      "web-eval-agent": {
        "command": "uvx",
        "args": [
          "--refresh-package",
          "webEvalAgent",
          "--from",
          "git+https://github.com/Operative-Sh/web-eval-agent.git",
          "webEvalAgent"
        ],
        "env": {
          "OPERATIVE_API_KEY": "<YOUR_KEY>"
        }
      }
    }
  3. Update the web-eval-agent MCP server

    main

    If you are not receiving updates in your code editor, you can force a refresh by cleaning the uv cache and refreshing the MCP server. Use the following command to ensure you are using the latest version from the repository:

    uv cache clean

    Ensure your configuration uses the --refresh-package flag with uvx as shown in the configuration guide.

  4. Use the setup_browser_state tool

    main
    The setup_browser_state tool opens an interactive (non-headless) browser window. This allows you to perform manual actions like signing in once; the saved cookies and local storage are then reused by subsequent web_eval_agent runs, preventing the need to re-authenticate every time.
  5. Use the web_eval_agent tool

    main

    The web_eval_agent tool is an automated UX evaluator that drives a browser, captures screenshots, console logs, and network logs to return a rich UX report. You can trigger this tool directly from your IDE chat.

    Arguments:

    • url (required): The address of the running application (e.g., http://localhost:3000).
    • task (required): A natural-language description of the test to perform (e.g., "run through the signup flow and note any UX issues").
    • headless_browser (optional, default false): Set to true to hide the browser window.
    Evaluate my app at http://localhost:3000 – run web_eval_agent with the task "Try the full signup flow and report UX issues".
  6. Configure the OPERATIVE_API_KEY environment variable

    main

    The MCP server requires a valid OperativeAI API key to function. This key must be provided via the OPERATIVE_API_KEY environment variable.

    If the key is missing or invalid (e.g., free tier limit reached), the tools will return an error message directing you to subscribe at https://operative.sh.

  7. Configure the backend URL via USE_LOCAL_BACKEND

    main

    The web-eval-agent determines which backend to connect to using the USE_LOCAL_BACKEND environment variable.

    • To use a local backend (e.g., running on your own machine), set USE_LOCAL_BACKEND=true in your .env file or environment. This defaults the base URL to http://0.0.0.0:8000.
    • To use the hosted production backend, ensure USE_LOCAL_BACKEND is either unset or not set to true. This defaults the base URL to https://operative-backend.onrender.com.

    The agent automatically loads variables from a .env file if it exists in the current directory.

  8. Get the backend URL with get_backend_url()

    main

    The get_backend_url function constructs the full URL for the backend service. It handles base URL selection based on the USE_LOCAL_BACKEND environment variable and allows appending an optional path.

    Arguments:

    • path (str, optional): An optional path to append to the base URL. The function automatically handles leading/trailing slashes to ensure a valid URL structure.

    Returns:

    • str: The complete, formatted backend URL.
  9. Use the setup_browser_state tool

    main

    The setup_browser_state tool is used to launch a non-headless browser to allow for manual user interaction, such as logging in or performing authentication. Once the interaction is complete, the tool saves the browser state (cookies, local storage, etc.) to a local file for future use.

    When to use: Use this tool only when the user explicitly requests to set up browser state or authentication.

    Arguments:

    • url (Optional): The URL to navigate to upon opening the browser.
    • ctx: The MCP context (used for progress reporting).
  10. Setup browser state and authentication with `handle_setup_browser_state`

    main

    Use handle_setup_browser_state to launch an interactive, non-headless browser session. This allows you to manually perform actions like logging in or completing authentication flows. Once the session is finished (either by closing the browser tab or a 180-second timeout), the browser state (cookies and local storage) is saved to a local file for use in future automated sessions.

    Arguments:

    • arguments: A dictionary containing:
      • url (optional): The URL to navigate to. Defaults to about:blank.
    • ctx: The MCP context for reporting progress.
    • api_key: The API key (not used directly in this function).

    Storage Locations:

    • State File: ~/.operative/browser_state/state.json
    • Cookies File: ~/.operative/browser_state/cookies.json
    • User Data Directory: ~/.operative/browser_user_data

    Returns: Returns a list containing TextContent confirming the success or failure of the state saving.

  11. Validate an API key with validate_api_key()

    main
    Use the validate_api_key function to verify if a provided API key is valid against the Operative backend service. The function performs an asynchronous GET request to the api/validate-key endpoint, passing the key in the x-operative-api-key header. It returns True if the backend confirms the key is valid, and False otherwise (including in the event of network errors or exceptions).
  12. Perform a web evaluation with `handle_web_evaluation`

    main

    Use handle_web_evaluation to evaluate the user experience (UX/UI) of a web application. The function uses a browser-use agent to perform specific tasks and analyze interaction flows. It automatically starts a log server and opens a dashboard for live monitoring.

    Arguments:

    • arguments: A dictionary containing:
      • url (required): The URL of the web application to evaluate. If a protocol is missing, https:// is prepended.
      • task (required): A string describing the specific UX/UI aspect to test.
      • headless (optional): Boolean indicating whether to run the browser in headless mode. Defaults to True.
      • tool_call_id (optional): A unique identifier for the tool call. If not provided, a UUID is generated.
    • ctx: The MCP context for reporting progress.
    • api_key: The API key for authentication with the LLM service.

    Returns: Returns a list containing a single list of TextContent (the formatted report) and ImageContent (screenshots captured during the evaluation).