TruePx

v0.1.6
io.github.thyitachi/truepx-mcp Checked 1 day ago Published 1 day ago

Lets AI coding agents measure, inspect, edit and audit web pages in your Chrome through TruePx.

Local bridge between MCP-compatible AI agents (Claude Code, Cursor, Windsurf, Cline, Continue) and the TruePx browser extension. 1. Add the bridge to your agent. Claude Code: 2. Restart the AI client, then open TruePx Settings → AI agents → Connect. 3. Turn TruePx on in the tabs the agent should see, then ask it to list tabs.

Summary extracted from the README.

truepx-mcp

Local bridge between MCP-compatible AI agents (Claude Code, Cursor, Windsurf, Cline, Continue) and the TruePx browser extension.

agent (MCP stdio) ⇄ truepx-mcp ⇄ ws://127.0.0.1:47830 ⇄ extension

Connect

  1. Add the bridge to your agent. Claude Code:
claude mcp add truepx -- npx -y truepx-mcp

Other clients (mcp.json):

{ "mcpServers": { "truepx": { "command": "npx", "args": ["-y", "truepx-mcp"] } } }
  1. Restart the AI client, then open TruePx Settings → AI agents → Connect.
  2. Turn TruePx on in the tabs the agent should see, then ask it to list tabs.

Port override (e.g. a second bridge): TRUEPX_MCP_PORT=18732 npx -y truepx-mcp. From a checkout: node packages/mcp-bridge/server.mjs.

Unpacked builds

The bridge only accepts TruePx's Chrome Web Store build (hbbeoljknddklhijknnppcccmlbmbbkd). An unpacked dev or test build has its own extension id, so list it in TRUEPX_MCP_EXTENSION_IDS (comma-separated):

claude mcp add truepx -e TRUEPX_MCP_EXTENSION_IDS=<id> -- npx -y truepx-mcp

In mcp.json, add "env": { "TRUEPX_MCP_EXTENSION_IDS": "<id>" } to the server.

Find the id on chrome://extensions (it shows on the card with Developer mode on), or compute it: Chrome takes the SHA-256 of the folder's real path and maps the first 32 hex digits 0–f to a–p:

node -e "const p=require('fs').realpathSync(process.argv[1]);console.log(require('crypto').createHash('sha256').update(p).digest('hex').slice(0,32).replace(/./g,(c)=>String.fromCharCode(97+parseInt(c,16))))" dist/chrome-mv3

A rejected build shows in the bridge's log as rejected bridge connection from origin chrome-extension://<id>.

Rules: the agent only sees tabs where TruePx is on (tabs_list); only one AI client drives the extension at a time (extra clients relay through the first instead of fighting over the port).

Protocol

  • stdin/stdout: MCP over stdio via @modelcontextprotocol/sdk (initialize, tools/list, tools/call).
  • Bridge → extension: {"id","type","payload"} (type = tool name). First frame per socket is a hello ({id:"__handshake__", type:"handshake", version, client}) carrying the bridge version + agent identity.
  • Extension → bridge: {"id","payload"} where payload is data, {error}, or {success:false,message}; screenshots arrive as {ok,dataUrl,note?} and are re-emitted as MCP image blocks.
  • Tool catalog mirrors src/mcp/catalog.ts (61 tools). Every tab-bound tool requires a numeric tabId from tabs_list; element ids are per-tab/per-viewport strings from the element tools.
  • Multi-client: the first bridge to bind the port becomes leader; later instances join as followers and relay (relay / relay_result).
  • Security: the port binds 127.0.0.1 and the handshake gates on Origin, since WebSocket handshakes ignore CORS and any local page or installed extension could otherwise reach the port. Only two kinds of connection pass: no Origin (another bridge process on this computer) and TruePx itself (chrome-extension://hbbeoljknddklhijknnppcccmlbmbbkd, plus ids in TRUEPX_MCP_EXTENSION_IDS). Web pages and other extensions get a 403. Bridge-to-bridge frames (relay, __follower__, __takeover__) count only on connections with no Origin. css_fetch_stylesheet additionally blocks non-http(s) URLs and localhost/private IPs.

Smoke test

node packages/mcp-bridge/smoke.mjs   # also wired as tests/e2e/mcp-smoke.mjs