agentleFS
ofershapofershap/real-browser-mcp/.cursor/rules/project.mdc

real-browser-mcp / rules

Cursor rule53 starsChanged 9 months agoMITView on GitHub

Core project context for real-browser-mcp

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository3 other files it gives its agents.

The file

We split this project.mdc into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    No build step. Reload in chrome://extensions after changes.

    line 55
  2. Very specific:

    Not negotiable without updating both server default (index.ts) AND extension default (background.js + popup.html).

    line 63

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
project.mdc
---
description: Core project context for real-browser-mcp
alwaysApply: true
---

# real-browser-mcp

MCP server (TypeScript) + Chrome extension (plain JS) that talk over WebSocket on localhost:7225.

## Versioning

Bump minor versions: 1.0.0 -> 1.1.0 -> 1.2.0. Three places must stay in sync:
1. `package.json` "version"
2. `extension/manifest.json` "version"
3. `mcp-server/src/index.ts` SERVER_VERSION

## Adding a Tool

Four files to touch:
1. `mcp-server/src/tools/<name>.ts` - ToolDefinition with Zod schema
2. `mcp-server/src/tools/index.ts` - add to allTools array
3. `extension/background.js` - add handler in dispatch() map + handler function
4. `tests/tools/` - add test

The schema type MUST be `z.ZodObject<z.ZodRawShape>`, not `z.ZodType`. The MCP SDK calls `.shape` on it.

## Tool inventory (18 tools)

Navigation: browser_navigate, browser_tabs
Interaction: browser_click (ref OR selector), browser_click_text (by visible text, CSP-safe), browser_type, browser_press_key, browser_scroll, browser_hover, browser_select
Reading: browser_snapshot (compact mode default), browser_screenshot, browser_text, browser_find
JS execution: browser_evaluate (via chrome.debugger CDP - bypasses CSP but shows debugger banner)
Dialogs: browser_handle_dialog (override alert/confirm/prompt)
Wait: browser_wait
Debug: browser_console (read-only), browser_network

## CSP and browser_evaluate

`browser_evaluate` uses chrome.debugger API (CDP Runtime.evaluate). This bypasses CSP but:
- Shows "is being debugged" infobar
- Attaching/detaching the debugger can steal focus and close open popups/dropdowns
- Requires `debugger` permission in manifest.json

For DOM interactions (clicking dropdown options, etc.), prefer `browser_click` with CSS selectors or `browser_click_text` instead. These use `chrome.scripting.executeScript` with compiled functions — no eval, no CSP issues.

Previous attempts using `new Function()` in MAIN world failed on GitHub/Google/strict-CSP sites. Sandbox/offscreen approaches can't access page DOM. chrome.debugger is the only universal eval but has the focus-stealing side effect.

## Snapshot modes

`compact: true` (default) - returns only interactive elements + landmarks, ~70% smaller output. No `tag` field.
`compact: false` - full accessibility tree with all visible elements. Includes `tag` for generic roles.

## Extension is plain JS

No build step. Reload in chrome://extensions after changes. Chrome kills service workers after 30s idle - the `chrome.alarms` keepalive handles this. Don't remove it.

## Element refs are ephemeral

`browser_snapshot` assigns `data-mcp-ref` attributes. These refs break after navigation, scroll, or DOM changes. Always re-snapshot before using refs.

## Port 7225

Not negotiable without updating both server default (index.ts) AND extension default (background.js + popup.html). Configurable via `WS_PORT` env var on server side, popup input on extension side.

## Tests need port isolation

Each test gets a unique port (counter starting at 19230). WebSocket servers take time to unbind - tests will flake without this.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.