Skip to main content
Glama

TG Browser MCP

A lightweight, secure, token-efficient browser automation MCP server and TypeScript harness for AI agents. It drives real browsers (Chrome, Edge, Chromium, Firefox, WebKit) through Playwright and works with any MCP client — Claude Code, Codex, Kiro, Gemini CLI, Cursor, VS Code — without a browser extension or any AI-provider login.

Page: Create Request
URL: http://localhost:4200/request/create

- heading "Create Request" [level=1] [ref=e21]
- form "Request form" [ref=e22]
  - textbox "Customer Name" [required] [ref=e23]
  - combobox "Request Type" [ref=e24]: "-- choose --"
  - combobox "Priority" [collapsed] [ref=e25]: "Normal"
  - button "Submit" [ref=e29]
- status "Draft" [ref=e30]

After browser_click ref=e29 the agent receives only what changed:

✓ Clicked button "Submit" · 412ms · session=maker page=p1
Changed:
- button "Submit" [ref=e29] (+disabled)
- status "Pending Approval" [ref=e30] (name "Draft" → "Pending Approval")
- alert "Request REQ-1001 submitted successfully" [ref=e31] (name "" → "Request REQ-1001 submitted successfully")
Removed:
- button "Save Draft" [ref=e28]

Features

Area

What you get

Smart snapshots

Accessibility-based, ref-addressable, iframes + open shadow DOM, sensitive values masked, paginated, scoped (scope=<ref>), interactive-only mode, framework detection (Angular / Material / PrimeNG)

Diffs

After each action: Added / Changed / Removed instead of the whole page; stable refs within a document; stale refs detected (STALE_ELEMENT_REFERENCE)

Interaction

click, fill (single or batched form), type, press, hover, select (native + ARIA combobox: mat-select, p-select), check, drag, scroll (incl. virtual-scroll containers), upload, dialogs, tabs, frames

Debugging

Deduplicated console, JS errors, network with filters, request details (redacted), performance metrics, Playwright traces, CORS / micro-frontend hints

Sessions

Isolated contexts per user/role, project namespaces, encrypted storage-state save/restore (cookies, localStorage, IndexedDB), dedicated persistent profiles, CDP attach (localhost)

Workflows

Declarative multi-user workflows (maker → checker → maker), variables + extraction, dependencies, conditions, idempotency-aware retries, assertions, failure screenshots/diagnostics, checkpoints, cancellation, recording

Testing

Web-first assertions, Playwright Test generation (multi-context, semantic locators, secrets from env), Markdown + JUnit reports

Network

HTTP/HTTPS/SOCKS proxies, env (HTTP(S)_PROXY, NO_PROXY), per-session proxy, credentials from env only, corporate CA status, step-by-step diagnostics (policy → DNS → TCP/proxy → TLS → HTTP)

Security

Domain allow/deny lists, cloud-metadata + private-network blocking (incl. redirects, popups, sub-requests, WebSockets, DNS rebinding check), file-root restrictions, approval via MCP elicitation, audit log, redaction, no JS/shell eval tools

Profiles

minimal (8 tools) · developer (40) · testing (61) · full (69) — only enabled tools are advertised

SDK

BrowserHarness usable without MCP, typed lifecycle events for TG Studio

Related MCP server: Fast Browser MCP

Quick start

Requirements: Node.js ≥ 20.10 and Chrome/Edge installed (or npx playwright install chromium).

git clone <repo> tg-browser-mcp && cd tg-browser-mcp
npm install
npm run build
node dist/index.js doctor          # verify environment

Claude Code

claude mcp add tg-browser -- node /absolute/path/tg-browser-mcp/dist/index.js --profile developer

or .mcp.json in your project:

{
  "mcpServers": {
    "tg-browser": {
      "command": "node",
      "args": [
        "/absolute/path/tg-browser-mcp/dist/index.js",
        "--transport",
        "stdio",
        "--profile",
        "developer"
      ]
    }
  }
}

Codex, Kiro, Gemini CLI, Cursor and VS Code: see docs/CLIENTS.md.

Try it against the bundled demo app

npm run fixture          # http://127.0.0.1:4321 — users maker/maker123, checker/checker123

Then ask your agent: "Log in as maker on http://127.0.0.1:4321, create a loan request for ACME, then as checker approve it, and generate a Playwright test."

Use as a library

import { BrowserHarness } from 'tg-browser-mcp';

const harness = new BrowserHarness({ browser: { headless: true } });
harness.on('action.completed', (e) => console.log(e.action, e.durationMs));

const session = await harness.createSession({ name: 'frontend-agent', browser: 'chrome' });
await session.navigate('http://localhost:4200');
console.log((await session.snapshot()).text);
await session.click({ role: 'button', name: 'Create' });
await harness.close();

CLI

tg-browser-mcp [start] [--transport stdio|http] [--browser chrome|edge|chromium|firefox|webkit]
               [--headless] [--profile minimal|developer|testing|full] [--config file] [--project name]
tg-browser-mcp init | doctor [--url u] | browsers | sessions | workflows | --help | --version

Details: docs/CLI.md.

Measured token efficiency

Same 12-step scenario on the bundled fixture app (login → form → submit → dynamic updates → 1,500-item page), measured with npm run bench against @playwright/mcp 0.0.86 (docs/BENCHMARK.md):

TG Browser (developer)

Playwright MCP

Tool responses, normal pages (11 steps)

3,169 chars

5,138 chars

Snapshot of 1,500-link page

11,940 chars (page 1/N, paginated)

184,900 chars (full)

Total responses

27,139 chars (~6.8k tok)

190,267 chars (~47.6k tok)

Tool schema advertised

31,039 chars (40 tools)

21,199 chars (25 tools)

Honest notes: most of the total difference comes from paginating very large pages (the full content is still available via page=N or scope=<ref>). Our navigate/click responses are larger per call because they embed the snapshot or diff (saving a separate snapshot call). The developer profile advertises more tools and therefore a larger schema; minimal is ~7.7k chars.

Documentation

Architecture · Installation · Configuration · CLI · Tools · MCP clients · Proxy & enterprise network · Sessions · Angular · Workflows · Security model · Threat model · TG Studio · Benchmark · Deploy to Cloudflare · Roadmap · Progress · ADRs · Contributing

License

Apache-2.0. Built on Playwright (Apache-2.0) and the MCP TypeScript SDK (MIT). No source code was copied from microsoft/playwright-mcp; its public architecture was used as a reference. See NOTICE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      B
      maintenance
      Enables AI agents and developers to automate real Chrome/Chromium browsers through the Chrome DevTools Protocol, with token-efficient snapshots, multi-action batching, shadow DOM traversal, system-page control, extension management, and network/WebSocket inspection.
      95
      1
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to drive a Chromium-based browser for web research, testing, and automation with Playwright-compatible tools, persistent profiles, proxy matching, extension loading, and humanized input across local or containerized deployments.
      297 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to perform Playwright-compatible browser automation through unchanged upstream tools, using a Chromium runtime with persistent profiles, proxy matching, humanized interactions, and Docker or stdio/Streamable HTTP deployment options.
      297 npm
      MIT