How ticktockbent/charlotte works
1. What this repository is
Charlotte is a TypeScript/Node.js MCP server that sits between an AI agent and a live Chromium browser. Its core job is to turn browser state into compact, structured page representations and expose browser actions as MCP tools over stdio.
2. Top-level runtime boundaries
There are three major runtime surfaces:
- the MCP server in src/
- the benchmark harness in benchmarks/
- the marketing/documentation site in site/
The server is the product; the other two support evaluation and distribution.
3. Server entrypoint and transport
src/index.ts, src/cli.ts, and src/server.ts define the process startup path and MCP transport. The server is designed to be launched locally or in Docker and communicate with clients via standard input/output, not via HTTP.
4. Browser control subsystem
src/browser/ manages the persistent browser session and tab/page lifecycle. The key responsibilities are browser startup/shutdown, page switching, and lower-level CDP session handling. This is the boundary where MCP actions become browser operations.
5. Rendering and page decomposition pipeline
src/renderer/ is the architectural core. It extracts and fuses browser signals into a PageRepresentation, including:
- accessibility tree data
- layout/bounding boxes
- structural landmarks and headings
- interactive element metadata
- content summaries
- stable element IDs
The pipeline is what enables Charlotte’s token-efficient output: it decides how much detail to return for navigate, observe, and related tools.
6. State, snapshots, and diffs
src/state/ holds cross-call page state:
- snapshot storage
- artifact storage
- structural differ
This supports screenshot persistence, comparison against prior snapshots, and page-diff workflows. State is a distinct layer from rendering so tools can reason over time, not just a single page view.
7. Tool layer and capability groups
src/tools/ defines the MCP surface area: navigation, observation, interaction, monitoring, session management, dev mode, evaluation, and meta-tool/profile management. The repo’s profile system is important architecturally: it selectively exposes subsets of tools to reduce tool-definition overhead, so tool registration is not a flat “all tools always on” model.
8. Interaction model
Charlotte’s interaction tools are built around stable element IDs and structured page metadata. Actions such as click, type, select, drag, and submit depend on the renderer’s IDs and the browser layer’s current page context. This creates a clear flow: render page → identify target → perform browser action → re-render or update state.
9. Development-mode subsystem
src/dev/ adds a local feedback loop for working on sites:
- static file serving
- file watching
- audit checks
- state tracking for dev mode
This is separate from core browsing because it supports serving local content, live reload, and automated audits rather than agent browsing of arbitrary remote pages.
10. External-facing page types and representation
The README’s minimal/summary/full detail levels map directly to the rendering layer’s output strategy. Charlotte is optimized for progressive disclosure: first return orientation, then targeted detail, then full text only when explicitly requested. That output contract is the main product boundary clients consume.
11. Benchmarking and evaluation harness
benchmarks/ contains reproducible scenarios, test runners, metrics collection, and saved raw results. This is an independent subsystem used to validate the token-efficiency and tool-overhead claims against Charlotte profiles and against Playwright MCP-style behavior.
12. Test architecture
tests/unit/ and tests/integration/ cover the server at multiple levels, with HTML fixtures under tests/fixtures/pages/ and sandbox pages under tests/sandbox/. The integration tests exercise browser behavior, rendering, interaction, session management, and artifact handling against real pages rather than mocks.
13. Packaging and deployment
The repo includes Dockerfiles, compose config, and GitHub Actions for CI and image publishing. That means the server is expected to be deployable as a self-contained local process, with containerization as a first-class distribution path.
14. Documentation and consumer surface
docs/ and the Next.js site/ form the external-facing documentation and benchmark presentation layer. They do not participate in runtime behavior, but they are important for understanding configuration, profiles, and the expected MCP client integration model.
15. Overall data flow to draw
The central architecture diagram should show:
AI agent/MCP client → MCP server/tools → browser manager/CDP → renderer pipeline → structured page/state outputs → back to agent.
Side flows branch from the server to dev-mode file serving/auditing, and from the repo to benchmarks, tests, docs, and Docker packaging.
Main entry points: renderer-pipeline.ts Renderer · server.ts Server · browser-manager.ts Browser · snapshot-store.ts State
Components 23
Runtime
Core MCP server and browser-facing execution path
- Entry · Process startup and CLI handoff
src/index.ts - CLI · Command-line startup and configuration
src/cli.ts - Server · MCP server wiring over stdio
src/server.ts - Browser · Persistent Chromium session and tab lifecycle
src/browser/browser-manager.ts - Pages · Page switching and page-scoped operations
src/browser/page-manager.ts - CDP · Low-level Chrome DevTools Protocol session handling
src/browser/cdp-session.ts - Renderer · Builds compact structured page representations
src/renderer/renderer-pipeline.ts - A11y · Accessibility tree extraction
src/renderer/accessibility-extractor.ts - Layout · Bounding boxes and layout signals
src/renderer/layout-extractor.ts - Interactives · Interactive elements and stable IDs
src/renderer/interactive-extractor.ts - Structure · Landmarks, headings, and structural tree
src/renderer/structural-tree-extractor.ts - Content · Page text and content summaries
src/renderer/content-extractor.ts
State
Page state, snapshots, and diffs
Support
Development mode and shared helpers
Evaluation
Benchmarks and harness
- Benchmarks · Reproducible scenarios and saved results
benchmarks/run-benchmarks.ts
Docs
Documentation and marketing site
Quality
Test coverage and fixtures
- Integration · End-to-end tests against real browser behavior
tests/integration/renderer-pipeline.test.ts - Unit · Focused tests for browser, renderer, state, and tools
tests/unit/tools/create-server.test.ts
Delivery
Packaging and deployment
- Docker · Container build and self-contained runtime distribution
Dockerfile
Connections 24
- Entry → CLI: starts · Entry delegates to CLI startup
- CLI → Server: creates · CLI configures and launches the MCP server
- Server → Tools: registers · Server exposes grouped MCP capabilities and profiles
- Server → Browser: drives · Tools translate client requests into browser operations
- Browser → Pages: manages · Browser session hands off page/tab lifecycle
- Browser → CDP: uses · Browser control is mediated through CDP sessions
- Pages → Renderer: renders · Current page context is rendered into structured output
- Renderer → A11y: fuses · Pipeline incorporates accessibility signals
- Renderer → Layout: fuses · Pipeline incorporates layout signals
- Renderer → Interactives: fuses · Pipeline incorporates interactive metadata and stable IDs
- Renderer → Structure: fuses · Pipeline incorporates structural landmarks and headings
- Renderer → Content: fuses · Pipeline incorporates text and summary signals
- Renderer → State: emits · Rendered representations are stored and reused across calls
- State → Artifacts: persists · Snapshots link to saved artifacts such as screenshots
- State → Diffs: compares · Prior snapshots are used for structural diffs
- Tools → Dev mode: exposes · One capability group covers development mode operations
- Dev mode → Browser: controls · Dev mode still routes through the browser/session layer when needed
- Server → State: shares · Server tools read and update page state
- Benchmarks → Tools: measures · Benchmark harness evaluates profiles and tool overhead
- Site → Docs: publishes · Site surfaces docs and benchmark narratives
- Integration → Renderer: covers · Integration tests validate the render pipeline
- Integration → Browser: covers · Integration tests exercise browser control and interactions
- Unit → Tools: covers · Unit tests validate server profiles and tool assembly
- Docker → Server: packages · Container builds the local MCP server runtime