looking-glass-mcp 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sahib Sawhney
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,283 @@
1
+ <p align="center">
2
+ <img src=".github/assets/looking-glass-logo.png" alt="Looking Glass" width="600" />
3
+ </p>
4
+
5
+ # Looking Glass
6
+
7
+ **Give your AI agent real eyes.** Looking Glass is an MCP server that hands Claude Code a full Chromium browser — 63 tools for navigating, clicking, screenshotting, testing, auditing, and automating any web application.
8
+
9
+ Built by Sahib Sawhney. [MIT License](LICENSE).
10
+
11
+ ---
12
+
13
+ ## Why Looking Glass?
14
+
15
+ Claude Code is powerful, but it is blind. It cannot see your web app, click your buttons, or verify your login flow actually works. Looking Glass fixes that.
16
+
17
+ ```
18
+ You: "Does the checkout flow work on staging?"
19
+
20
+ Claude: Opens a real browser. Navigates to staging. Fills the cart.
21
+ Enters payment details. Clicks submit. Screenshots every step.
22
+ Checks for console errors. Monitors API responses.
23
+ "Checkout completes successfully. One warning: the /api/payment
24
+ endpoint took 4.2s — see the performance audit below."
25
+ ```
26
+
27
+ This is not a mock. Not a simulation. Claude controls a real browser, sees real screenshots, and reads real DOM trees.
28
+
29
+ ---
30
+
31
+ ## Get Running in 60 Seconds
32
+
33
+ **Option A** — Add directly to Claude Code:
34
+
35
+ ```bash
36
+ claude mcp add looking-glass -- npx looking-glass-mcp
37
+ ```
38
+
39
+ **Option B** — Install globally:
40
+
41
+ ```bash
42
+ npm install -g looking-glass-mcp
43
+ ```
44
+
45
+ **Option C** — Configure `.mcp.json` manually:
46
+
47
+ ```json
48
+ {
49
+ "mcpServers": {
50
+ "looking-glass": {
51
+ "command": "npx",
52
+ "args": ["looking-glass-mcp"],
53
+ "env": {
54
+ "BROWSER_HEADLESS": "false"
55
+ }
56
+ }
57
+ }
58
+ }
59
+ ```
60
+
61
+ Then just talk to Claude:
62
+
63
+ ```
64
+ "Open localhost:3000 and tell me what you see"
65
+ "Run an accessibility audit on the landing page"
66
+ "Test the signup flow with an invalid email"
67
+ "Explore the entire site and map all the pages"
68
+ ```
69
+
70
+ ---
71
+
72
+ ## The 63-Tool Arsenal
73
+
74
+ Looking Glass ships with **63 MCP tools** organized across 7 categories. Every interaction and navigation tool automatically returns a **page state envelope** — URL, title, console errors, failed requests, and a screenshot — so the agent never needs follow-up calls to see what happened.
75
+
76
+ ### Core Browser Control
77
+
78
+ | Tool | What it does |
79
+ |------|-------------|
80
+ | `browser_navigate` | Go to any URL |
81
+ | `browser_click` | Click by CSS selector or plain text |
82
+ | `browser_smart_click` | Click by natural language description ("the blue Submit button") |
83
+ | `browser_type` | Fill input fields |
84
+ | `browser_hover` | Hover over elements |
85
+ | `browser_drag` | Drag and drop |
86
+ | `browser_select_option` | Choose from dropdowns |
87
+ | `browser_press_key` | Keyboard input (Enter, Tab, Escape, etc.) |
88
+ | `browser_scroll` | Scroll page or scroll to a specific element |
89
+ | `browser_go_back` / `browser_go_forward` | History navigation |
90
+ | `browser_tab_new` / `browser_tab_list` / `browser_tab_select` / `browser_close` | Multi-tab management |
91
+
92
+ ### AI-Native Intelligence
93
+
94
+ These tools exist because an AI is the operator — they would be useless to a human.
95
+
96
+ | Tool | What it does |
97
+ |------|-------------|
98
+ | `browser_analyze_page` | Returns structured page analysis: type (login, dashboard, form, error), available actions, forms, navigation links, data elements, and page state |
99
+ | `browser_resolve_element` | Finds elements by natural language ("the email input", "third navigation link") with confidence scores, **visibility, enabled state, bounding box, and viewport position** |
100
+ | `browser_smart_click` | Click elements described in plain English instead of fragile CSS selectors. Returns page state envelope with screenshot. |
101
+ | `browser_suggest_actions` | Examines the page and suggests what the agent should do next, with pre-filled tool parameters (returns structured JSON) |
102
+ | `browser_explore` | Autonomously crawls the site within domain boundaries, classifies every page, and returns a complete site map (returns structured JSON) |
103
+ | `browser_wait_until_stable` | Waits for true page readiness using multiple signals: network idle, DOM settled, spinners gone, images loaded |
104
+ | `browser_login` | **Composite action**: navigates to login URL, auto-detects fields, fills credentials, submits, verifies redirect, reports cookies set — all in one call |
105
+ | `browser_fill_and_submit` | **Composite action**: fills form fields by selector or label, submits, returns before/after state with screenshot |
106
+
107
+ ### Observation & Debugging
108
+
109
+ | Tool | What it does |
110
+ |------|-------------|
111
+ | `browser_screenshot` | Capture viewport or full-page screenshot (returned inline) |
112
+ | `browser_snapshot` | Get the full accessibility tree as structured text |
113
+ | `browser_evaluate` | Execute arbitrary JavaScript in page context |
114
+ | `browser_console_messages` | Read console logs, warnings, errors |
115
+ | `browser_network_requests` | Monitor all HTTP requests and responses |
116
+ | `browser_diagnose` | One-shot diagnostic bundle: console errors + failed requests + DOM context + screenshot |
117
+ | `browser_error_report` | Catalog of all uncaught JS exceptions and failed resource loads |
118
+ | `browser_snapshot_state` / `browser_diff_state` | Take a before/after snapshot and see exactly what changed on the page |
119
+ | `browser_action_history` | Full journal of every action taken: tool, args, URL before/after, new errors, duration (returns structured JSON) |
120
+ | `browser_clear_history` | Reset the action journal |
121
+
122
+ ### Storage & State Inspection
123
+
124
+ | Tool | What it does |
125
+ |------|-------------|
126
+ | `browser_get_cookies` / `browser_set_cookie` | Read and write browser cookies |
127
+ | `browser_get_localstorage` / `browser_set_localstorage` | Read and write localStorage entries |
128
+ | `browser_clear_storage` | Clear cookies, localStorage, sessionStorage, or all at once |
129
+ | `browser_clean_slate` | Nuclear option: wipe cookies, localStorage, sessionStorage, IndexedDB, and Cache API |
130
+
131
+ ### Test Automation
132
+
133
+ | Tool | What it does |
134
+ |------|-------------|
135
+ | `test_scenario_run` | Execute multi-step test scenarios defined in JSON |
136
+ | `test_scenario_status` | Check progress of a running scenario |
137
+ | `test_assert` | Run a single assertion (12 types: exists, textContains, urlEquals, isVisible, etc.) |
138
+ | `test_fill_form` | Auto-fill form fields by selector mapping |
139
+ | `test_auth_flow` | Test complete login/signup flows end-to-end |
140
+ | `test_watch_events` / `test_stop_watch` | Monitor DOM mutations, network requests, console errors, and dialogs |
141
+ | `test_accessibility_audit` | WCAG 2.1 AA compliance audit with severity-ranked violations and fix suggestions |
142
+ | `browser_performance_audit` | Core Web Vitals, page timing, resource analysis, and a performance score |
143
+ | `test_generate_assertions` | Auto-detect what should be tested on the current page |
144
+ | `test_chaos` / `test_chaos_clear` | Chaos testing: slow-3g, offline, block-api, random-delays, no-js, slow-cpu |
145
+
146
+ ### Session Recording & Visual Regression
147
+
148
+ | Tool | What it does |
149
+ |------|-------------|
150
+ | `session_start` / `session_end` / `session_list` | Record browser sessions with action timelines |
151
+ | `session_export_playwright` | Convert a recorded session into a standalone Playwright `.spec.ts` test file |
152
+ | `visual_baseline` / `visual_compare` | Pixel-level visual regression testing with diff images |
153
+
154
+ ### Request Mocking
155
+
156
+ | Tool | What it does |
157
+ |------|-------------|
158
+ | `browser_mock_route` | Intercept requests matching a URL pattern and return mock responses |
159
+ | `browser_list_mocks` / `browser_clear_mocks` | Manage active mock routes |
160
+
161
+ ### Enterprise & Reliability
162
+
163
+ | Tool | What it does |
164
+ |------|-------------|
165
+ | `browser_health_check` | Verify the browser is responsive |
166
+ | `browser_recover` | Auto-recover from crashes by relaunching and restoring the last URL |
167
+
168
+ ---
169
+
170
+ ## Test Scenarios
171
+
172
+ Define multi-step test flows in JSON and run them with `test_scenario_run`:
173
+
174
+ ```json
175
+ {
176
+ "name": "Login Flow",
177
+ "steps": [
178
+ { "name": "Navigate", "action": "navigate", "url": "http://localhost:3000/login" },
179
+ { "name": "Enter email", "action": "type", "selector": "input[type='email']", "value": "user@test.com" },
180
+ { "name": "Enter password", "action": "type", "selector": "input[type='password']", "value": "secret" },
181
+ { "name": "Submit", "action": "click", "selector": "button[type='submit']" },
182
+ { "name": "Verify redirect", "action": "assert", "type": "urlContains", "expected": "/dashboard" },
183
+ { "name": "Capture result", "action": "screenshot", "screenshotName": "post-login" }
184
+ ]
185
+ }
186
+ ```
187
+
188
+ **14 step actions**: navigate, click, type, select, hover, scroll, press, waitForSelector, waitForText, waitForNavigation, waitForNetworkIdle, assert, screenshot, evaluate, sleep
189
+
190
+ **12 assertion types**: exists, notExists, textContains, textEquals, hasAttribute, hasClass, isVisible, isEnabled, urlContains, urlEquals, countEquals, consoleNoErrors
191
+
192
+ ---
193
+
194
+ ## Configuration
195
+
196
+ Everything is configured through environment variables.
197
+
198
+ | Variable | Default | Purpose |
199
+ |----------|---------|---------|
200
+ | `BROWSER_HEADLESS` | `true` | Set `false` to watch the browser in real-time |
201
+ | `BROWSER_ENGINE` | `chromium` | Browser engine: `chromium`, `firefox`, or `webkit` |
202
+ | `BROWSER_VIEWPORT_WIDTH` | `1280` | Viewport width in pixels |
203
+ | `BROWSER_VIEWPORT_HEIGHT` | `720` | Viewport height in pixels |
204
+ | `BROWSER_TIMEOUT` | `30000` | Default operation timeout (ms) |
205
+ | `BROWSER_SESSIONS_DIR` | `.browser-sessions` | Where screenshots, sessions, and audit logs are stored |
206
+ | `BROWSER_SECURITY_PROFILE` | `local-dev` | Security profile (see below) |
207
+ | `BROWSER_CHANNEL` | — | Specific browser channel (`chrome`, `msedge`) |
208
+ | `BROWSER_PROXY_URL` | — | HTTP/HTTPS/SOCKS5 proxy for corporate environments |
209
+ | `BROWSER_CA_CERT_PATH` | — | Path to custom CA certificate |
210
+
211
+ ### Security Profiles
212
+
213
+ | Profile | URL Access | JS Execution | Tool Access | Rate Limit |
214
+ |---------|-----------|--------------|-------------|------------|
215
+ | `local-dev` | All HTTP/HTTPS | Allowed | All tools | 60/min |
216
+ | `restricted` | localhost only | Blocked | Observation only | 30/min |
217
+ | `open` | Everything | Allowed | All tools | 120/min |
218
+
219
+ The `restricted` profile enforces **read-only access** — the agent can screenshot and inspect but cannot click, type, or modify anything. Ideal for production monitoring.
220
+
221
+ ---
222
+
223
+ ## Architecture
224
+
225
+ ```mermaid
226
+ graph TD
227
+ A[Claude Code] -->|MCP stdio| B[Looking Glass]
228
+ B -->|Playwright API| C[Browser Engine]
229
+ C -->|Screenshots + DOM| B
230
+ B -->|Inline images + text| A
231
+
232
+ B --> D[Middleware Layer]
233
+ D --> E[Audit Logger]
234
+ D --> F[RBAC Policy]
235
+
236
+ B --> G[Session Recorder]
237
+ B --> H[Visual Comparator]
238
+ ```
239
+
240
+ Looking Glass sits between Claude Code and a real browser. Every tool invocation passes through a middleware layer that handles audit logging and role-based access control. Sessions are recorded to disk. Visual baselines are stored for regression comparison.
241
+
242
+ ---
243
+
244
+ ## Claude Code Integration
245
+
246
+ ### Agent: `e2e-tester`
247
+
248
+ A specialized testing agent that knows all 63 tools and follows a structured workflow. Invoke it for comprehensive testing:
249
+
250
+ ```
251
+ "Use the e2e-tester agent to verify the entire checkout flow"
252
+ ```
253
+
254
+ ### Skill: `/looking-glass-test`
255
+
256
+ Quick-fire E2E testing. Give it a URL and it handles the rest:
257
+
258
+ ```
259
+ /looking-glass-test https://myapp.com
260
+ ```
261
+
262
+ It will navigate, screenshot, discover pages, run assertions, check for JS errors, audit accessibility, and generate a pass/fail report.
263
+
264
+ ---
265
+
266
+ ## Development
267
+
268
+ ```bash
269
+ git clone <your-repo-url>
270
+ cd looking-glass
271
+ npm install
272
+ npx playwright install chromium
273
+ npm run build
274
+ npm start
275
+ ```
276
+
277
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines.
278
+
279
+ ---
280
+
281
+ ## License
282
+
283
+ [MIT](LICENSE)
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../build/index.js';