mcp-browser-extension 0.9.35 → 0.9.38

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.
Files changed (58) hide show
  1. package/README.md +33 -15
  2. package/dist/shared/client-auth.d.ts +2 -0
  3. package/dist/shared/phone-pairing.d.ts +35 -0
  4. package/dist/shared/phone-pairing.js +10 -0
  5. package/dist/shared/policy.js +7 -0
  6. package/dist/shared/protocol.d.ts +13 -2
  7. package/dist/shared/protocol.js +13 -1
  8. package/dist/shared/site-risk.d.ts +31 -0
  9. package/dist/shared/site-risk.js +190 -0
  10. package/dist/src/bridge/client-identity.d.ts +11 -5
  11. package/dist/src/bridge/client-identity.js +7 -4
  12. package/dist/src/bridge/connection.js +1 -0
  13. package/dist/src/bridge/server.d.ts +1 -0
  14. package/dist/src/bridge/server.js +38 -19
  15. package/dist/src/bridge/workspace.d.ts +1 -0
  16. package/dist/src/bridge/workspace.js +11 -3
  17. package/dist/src/cli.js +61 -18
  18. package/dist/src/config.d.ts +2 -0
  19. package/dist/src/config.js +26 -1
  20. package/dist/src/executor/extension-executor.d.ts +1 -0
  21. package/dist/src/executor/extension-executor.js +10 -1
  22. package/dist/src/executor/types.d.ts +3 -1
  23. package/dist/src/mcp/helpers.js +18 -6
  24. package/dist/src/mcp/person-wait.js +2 -1
  25. package/dist/src/mcp/server.d.ts +2 -1
  26. package/dist/src/mcp/server.js +4 -4
  27. package/dist/src/mcp/tools.d.ts +2 -2
  28. package/dist/src/mcp/tools.js +46 -9
  29. package/dist/src/native-host.js +11 -1
  30. package/dist/src/remote/claude-chat.d.ts +21 -0
  31. package/dist/src/remote/claude-chat.js +209 -0
  32. package/dist/src/remote/codex-rpc.d.ts +19 -0
  33. package/dist/src/remote/codex-rpc.js +94 -0
  34. package/dist/src/remote/http.d.ts +5 -0
  35. package/dist/src/remote/http.js +99 -7
  36. package/dist/src/remote/key.d.ts +4 -0
  37. package/dist/src/remote/key.js +6 -2
  38. package/dist/src/remote/phone-chat.d.ts +57 -0
  39. package/dist/src/remote/phone-chat.js +366 -0
  40. package/dist/src/remote/phone-control.d.ts +6 -0
  41. package/dist/src/remote/phone-control.js +132 -0
  42. package/dist/src/remote/phone-pairing.d.ts +41 -0
  43. package/dist/src/remote/phone-pairing.js +180 -0
  44. package/dist/src/remote/relay.d.ts +37 -0
  45. package/dist/src/remote/relay.js +207 -0
  46. package/docs/CLIENT-APPROVAL.md +44 -9
  47. package/docs/PHONE-PAIRING.md +97 -0
  48. package/extension-dist/THIRD-PARTY-NOTICES.txt +35 -0
  49. package/extension-dist/activity-dashboard.css +4 -9
  50. package/extension-dist/background.js +725 -127
  51. package/extension-dist/brand.css +63 -0
  52. package/extension-dist/manifest.json +1 -1
  53. package/extension-dist/options.html +25 -22
  54. package/extension-dist/options.js +179 -42
  55. package/extension-dist/popup.html +33 -41
  56. package/extension-dist/popup.js +2529 -126
  57. package/extension-dist/site-protection.css +11 -0
  58. package/package.json +13 -2
@@ -0,0 +1,63 @@
1
+ /* Website palette (mcp-browser-extension.com), shared by the popup and Settings.
2
+ Light matches the docs light theme; dark matches the docs/product dark theme.
3
+ Status colors (ok/warn/bad) are extension-only: the website has no equivalents. */
4
+ :root {
5
+ color-scheme: light dark;
6
+ accent-color: var(--accent);
7
+ --bg: #f7f8fc;
8
+ --panel: #edf0f7;
9
+ --card: #ffffff;
10
+ --fg: #161b2c;
11
+ --muted: #606a80;
12
+ --line: #dce1ec;
13
+ --ok: #16a34a;
14
+ --ok-text: #15803d;
15
+ --ok-soft: #dcfce7;
16
+ --warn: #c2410c;
17
+ --warn-soft: #fff1e6;
18
+ --bad: #dc2626;
19
+ --bad-text: #b91c1c;
20
+ --bad-line: #fca5a5;
21
+ --bad-soft: #fef2f2;
22
+ /* Slightly darker than the website's 0.58 so white button text keeps 4.5:1. */
23
+ --accent: oklch(0.56 0.19 255);
24
+ --accent-foreground: oklch(0.99 0 0);
25
+ --accent-2: var(--accent);
26
+ --ring: oklch(0.56 0.19 255 / 35%);
27
+ --button-primary-bg: var(--accent);
28
+ --button-primary-fg: var(--accent-foreground);
29
+ --button-primary-line: transparent;
30
+ --button-primary-hover: color-mix(in oklch, var(--accent) 88%, var(--fg));
31
+ --shadow: 0 1px 2px rgba(22, 27, 44, 0.06), 0 4px 14px rgba(22, 27, 44, 0.06);
32
+ /* Settings reads these names through activity-dashboard.css. */
33
+ --site-primary: var(--accent);
34
+ --site-primary-foreground: var(--accent-foreground);
35
+ --site-ring: var(--accent);
36
+ }
37
+ @media (prefers-color-scheme: dark) {
38
+ :root {
39
+ --bg: #07090d;
40
+ --panel: #131d2b;
41
+ --card: #101722;
42
+ --fg: #f5f7fc;
43
+ --muted: #a3adbd;
44
+ --line: #ffffff1c;
45
+ --ok: #34d399;
46
+ --ok-text: #34d399;
47
+ --ok-soft: rgba(52, 211, 153, 0.12);
48
+ --warn: #fb923c;
49
+ --warn-soft: rgba(251, 146, 60, 0.1);
50
+ --bad-text: #fca5a5;
51
+ --bad-line: #7f1d1d;
52
+ --bad-soft: #450a0a;
53
+ --accent: #a7c7ff;
54
+ --accent-foreground: #101722;
55
+ --ring: #a7c7ff73;
56
+ /* The website's outlined navy action button ("Add to Chrome"). */
57
+ --button-primary-bg: #1a2c48;
58
+ --button-primary-fg: #e6efff;
59
+ --button-primary-line: #789ed180;
60
+ --button-primary-hover: #243c60;
61
+ --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 6px 20px rgba(0, 0, 0, 0.35);
62
+ }
63
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "MCP Browser Extension – AI agent in your logged-in Chrome",
4
- "version": "0.9.35",
4
+ "version": "0.9.38",
5
5
  "description": "Lets your AI agent use the Chrome you are signed into, through a local MCP server. Deny-all by default.",
6
6
  "homepage_url": "https://mcp-browser-extension.com",
7
7
  "minimum_chrome_version": "116",
@@ -3,41 +3,42 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <title>MCP Browser Extension — Settings</title>
6
+ <link rel="stylesheet" href="brand.css" />
6
7
  <link rel="stylesheet" href="activity-dashboard.css" />
7
8
  <style>
8
- :root {
9
- --site-primary: oklch(0.58 0.19 255);
10
- --site-primary-foreground: oklch(0.99 0 0);
11
- --site-ring: oklch(0.58 0.19 255);
12
- }
13
- body { font: 14px/1.5 system-ui, sans-serif; max-width: 32rem; margin: 2rem auto; padding: 0 1rem; }
9
+ html { background: var(--bg); }
10
+ body { font: 14px/1.5 system-ui, sans-serif; max-width: 32rem; margin: 2rem auto; padding: 0 1rem; color: var(--fg); background: var(--bg); }
11
+ a { color: var(--accent); }
14
12
  h1 { font-size: 1.2rem; }
15
13
  label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; }
14
+ input, select { color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 0.4rem; }
16
15
  input { width: 100%; padding: 0.5rem; box-sizing: border-box; font: inherit; }
17
- button { margin-top: 1rem; padding: 0.5rem 1rem; font: inherit; cursor: pointer; }
18
- .status { margin-top: 1rem; padding: 0.5rem 0.75rem; border-radius: 0.4rem; background: color-mix(in oklch, var(--site-primary) 7%, white); border: 1px solid color-mix(in oklch, var(--site-primary) 25%, white); }
19
- code { background: #f3f3f3; padding: 0 0.25rem; }
20
- .hint { color: #555; font-size: 0.9rem; }
16
+ button { margin-top: 1rem; padding: 0.5rem 1rem; font: inherit; cursor: pointer; color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 0.5rem; }
17
+ button:hover { background: var(--panel); }
18
+ :is(input, select, button):focus-visible { outline: 2px solid var(--site-ring); outline-offset: 2px; }
19
+ .status { margin-top: 1rem; padding: 0.5rem 0.75rem; border-radius: 0.4rem; background: color-mix(in oklch, var(--site-primary) 7%, var(--card)); border: 1px solid color-mix(in oklch, var(--site-primary) 25%, var(--card)); }
20
+ code { background: var(--panel); padding: 0 0.25rem; border-radius: 0.25rem; }
21
+ .hint { color: var(--muted); font-size: 0.9rem; }
21
22
  label.check { display: flex; gap: 0.5rem; align-items: center; font-weight: 600; margin-top: 1rem; }
22
23
  label.check input { width: auto; }
23
24
  h2 { font-size: 1.05rem; margin-top: 2rem; }
24
25
  ul.sites { list-style: none; padding: 0; margin: 0.5rem 0; }
25
- ul.sites li { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0; border-bottom: 1px solid #eee; }
26
+ ul.sites li { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
26
27
  ul.sites li span { flex: 1; overflow-wrap: anywhere; }
27
28
  ul.sites li button { margin: 0; padding: 0.25rem 0.75rem; }
28
- ul.sites li .tag { flex: none; color: #555; font-size: 0.85rem; }
29
- .blocked li { background: #fff7ed; padding-left: 0.5rem; }
29
+ ul.sites li .tag { flex: none; color: var(--muted); font-size: 0.85rem; }
30
+ .blocked li { background: var(--warn-soft); padding-left: 0.5rem; }
30
31
  .row { display: flex; gap: 0.5rem; }
31
32
  .row button { margin-top: 0; }
32
- .quick { margin: 1rem 0 1.25rem; padding: 1rem; border-radius: 0.6rem; background: color-mix(in oklch, var(--site-primary) 7%, white); border: 1px solid color-mix(in oklch, var(--site-primary) 25%, white); }
33
- .quick button.primary { margin-top: 0; width: 100%; padding: 0.7rem; font-weight: 600; color: var(--site-primary-foreground); border: 0; border-radius: 0.5rem; background: var(--site-primary); transition: background-color 150ms, box-shadow 150ms; }
34
- .quick button.primary:hover { background: color-mix(in oklch, var(--site-primary) 88%, #0f172a); }
33
+ .quick { margin: 1rem 0 1.25rem; padding: 1rem; border-radius: 0.6rem; background: color-mix(in oklch, var(--site-primary) 7%, var(--card)); border: 1px solid color-mix(in oklch, var(--site-primary) 25%, var(--card)); }
34
+ .quick button.primary { margin-top: 0; width: 100%; padding: 0.7rem; font-weight: 600; color: var(--button-primary-fg); border: 1px solid var(--button-primary-line); border-radius: 0.5rem; background: var(--button-primary-bg); transition: background-color 150ms, box-shadow 150ms; }
35
+ .quick button.primary:hover { background: var(--button-primary-hover); }
35
36
  .quick button.primary:focus-visible { outline: 2px solid var(--site-ring); outline-offset: 2px; }
36
- #save { color: var(--site-primary-foreground); background: var(--site-primary); border: 0; border-radius: 0.5rem; }
37
- #save:hover { background: color-mix(in oklch, var(--site-primary) 88%, #0f172a); }
37
+ #save { color: var(--button-primary-fg); background: var(--button-primary-bg); border: 1px solid var(--button-primary-line); border-radius: 0.5rem; }
38
+ #save:hover { background: var(--button-primary-hover); }
38
39
  #save:focus-visible { outline: 2px solid var(--site-ring); outline-offset: 2px; }
39
40
  .quick .hint { margin: 0.5rem 0 0; }
40
- .quick .hint.error { color: #b45309; }
41
+ .quick .hint.error { color: var(--warn); }
41
42
  select { width: 100%; padding: 0.5rem; font: inherit; }
42
43
  .grid { display: grid; grid-template-columns: 1fr 7rem; gap: 0 0.5rem; }
43
44
  #client-connections li { align-items: start; flex-wrap: wrap; gap: 0.75rem; }
@@ -45,7 +46,7 @@
45
46
  #client-connections button { margin: 0.25rem 0.25rem 0 0; }
46
47
  .client-info { flex: 1; min-width: 0; display: grid; justify-items: start; gap: 4px; overflow-wrap: anywhere; }
47
48
  .client-status { font-size: 0.9rem; }
48
- .client-details { flex-basis: 100%; min-width: 0; color: #555; font-size: 0.85rem; overflow-wrap: anywhere; }
49
+ .client-details { flex-basis: 100%; min-width: 0; color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
49
50
  .client-details summary { width: fit-content; padding: 2px 0; cursor: pointer; }
50
51
  .client-details summary:focus-visible { outline: 2px solid var(--site-ring); outline-offset: 3px; border-radius: 2px; }
51
52
  .client-details p { margin: 4px 0; }
@@ -53,8 +54,8 @@
53
54
  #extra-permissions-list li { display: block; padding: 0.75rem 0; }
54
55
  #extra-permissions-list p { margin: 0.35rem 0; }
55
56
  #extra-permissions-list button { margin-top: 0.25rem; }
56
- .proxy-on { background: #ecfdf5; }
57
- .proxy-err { background: #fff7ed; }
57
+ .proxy-on { background: var(--ok-soft); }
58
+ .proxy-err { background: var(--warn-soft); }
58
59
  </style>
59
60
  </head>
60
61
  <body>
@@ -79,6 +80,8 @@
79
80
  <p class="hint" id="client-note" role="status" aria-live="polite"></p>
80
81
  </section>
81
82
 
83
+ <link rel="stylesheet" href="site-protection.css" />
84
+ <section id="site-protection"></section>
82
85
  <section id="blocked-wrap" hidden>
83
86
  <h2>Website access</h2>
84
87
  <p class="hint">Allow lets approved apps read and act here, including sending, deleting and buying. Accept Chrome’s prompt if shown.</p>
@@ -8,6 +8,7 @@
8
8
 
9
9
  // shared/protocol.ts
10
10
  var DEFAULT_WS_PORT = 38017;
11
+ var MAX_BRIDGE_FRAME_BYTES = 4 * 1024 * 1024;
11
12
 
12
13
  // shared/activity.ts
13
14
  var ACCESS_STOPPED_KEY = "accessStopped";
@@ -20,7 +21,7 @@
20
21
  if (key && entry.method === "tab_new" && entry.outcome === "done") opens.set(key, entry);
21
22
  const opened = key && entry.method === "tab_close" && entry.outcome === "done" ? opens.get(key) : void 0;
22
23
  if (opened) {
23
- const index = rows.findIndex((row) => row.id === opened.id);
24
+ const index = rows.findIndex((row2) => row2.id === opened.id);
24
25
  if (index !== -1) rows.splice(index, 1);
25
26
  rows.push({ ...entry, host: entry.host || opened.host, opened });
26
27
  opens.delete(key);
@@ -108,20 +109,20 @@
108
109
  else list4.insertBefore(element, cursor);
109
110
  next.set(id, { signature: version, element });
110
111
  }
111
- const keep = new Set([...next.values()].map((row) => row.element));
112
+ const keep = new Set([...next.values()].map((row2) => row2.element));
112
113
  for (const child of Array.from(list4.children)) if (!keep.has(child)) child.remove();
113
114
  list4.scrollTop = scrollTop;
114
115
  lists.set(list4, next);
115
116
  }
116
- async function busyButton(button2, operation) {
117
- if (button2.disabled) return;
118
- button2.disabled = true;
119
- button2.setAttribute("aria-busy", "true");
117
+ async function busyButton(button3, operation) {
118
+ if (button3.disabled) return;
119
+ button3.disabled = true;
120
+ button3.setAttribute("aria-busy", "true");
120
121
  try {
121
122
  await operation();
122
123
  } finally {
123
- button2.disabled = false;
124
- button2.removeAttribute("aria-busy");
124
+ button3.disabled = false;
125
+ button3.removeAttribute("aria-busy");
125
126
  }
126
127
  }
127
128
 
@@ -143,11 +144,11 @@
143
144
  return `Access allowed \xB7 ${remaining} left`;
144
145
  }
145
146
  function action(label, id, allow) {
146
- const button2 = document.createElement("button");
147
- button2.textContent = label;
148
- button2.addEventListener("click", async (event) => {
147
+ const button3 = document.createElement("button");
148
+ button3.textContent = label;
149
+ button3.addEventListener("click", async (event) => {
149
150
  if (!event.isTrusted) return;
150
- button2.disabled = true;
151
+ button3.disabled = true;
151
152
  try {
152
153
  const result = await chrome.runtime.sendMessage({ type: "client_decision", id, allow });
153
154
  note.textContent = result?.ok ? "" : result?.error ?? "Could not save the decision.";
@@ -156,11 +157,11 @@
156
157
  note.textContent = "Could not reach the extension. Reopen this page and try again.";
157
158
  note.dataset.error = "true";
158
159
  } finally {
159
- button2.disabled = false;
160
+ button3.disabled = false;
160
161
  }
161
162
  await render();
162
163
  });
163
- return button2;
164
+ return button3;
164
165
  }
165
166
  var renderGeneration = 0;
166
167
  async function render() {
@@ -169,7 +170,7 @@
169
170
  if (generation !== renderGeneration) return;
170
171
  const saved = state[CLIENT_STORAGE_KEY];
171
172
  const stopped = state[ACCESS_STOPPED_KEY] !== void 0 && state[ACCESS_STOPPED_KEY] !== false;
172
- const clients = Array.isArray(saved) ? saved : [];
173
+ const clients = Array.isArray(saved) ? saved.filter((c) => c.kind !== "phone") : [];
173
174
  const now = Date.now();
174
175
  const pending2 = (client) => client.state === "pending" && client.expiresAt > now;
175
176
  const waiting = clients.filter(pending2).length;
@@ -231,21 +232,21 @@
231
232
  approve.className = "primary";
232
233
  controls.append(approve, action("Deny", client.id, false));
233
234
  } else if (client.state === "approved" && !expired) controls.append(action("Remove access", client.id, false));
234
- if (stopped) controls.querySelectorAll("button").forEach((button2) => {
235
- button2.disabled = true;
235
+ if (stopped) controls.querySelectorAll("button").forEach((button3) => {
236
+ button3.disabled = true;
236
237
  });
237
238
  li.append(info, controls, details);
238
239
  return li;
239
240
  }
240
241
  );
241
242
  const byId = new Map(clients.map((client) => [client.id, client]));
242
- for (const row of Array.from(list.querySelectorAll("[data-client-id]"))) {
243
- const client = byId.get(row.dataset.clientId);
244
- const status = row.querySelector(".client-status");
243
+ for (const row2 of Array.from(list.querySelectorAll("[data-client-id]"))) {
244
+ const client = byId.get(row2.dataset.clientId);
245
+ const status = row2.querySelector(".client-status");
245
246
  if (client && status) {
246
247
  const label = accessStatus(client, now);
247
248
  if (status.textContent !== label) status.textContent = label;
248
- const requested = row.querySelector(".client-requested");
249
+ const requested = row2.querySelector(".client-requested");
249
250
  const requestTime = `Requested: ${new Date(client.requestedAt).toLocaleString()}`;
250
251
  if (requested && requested.textContent !== requestTime) requested.textContent = requestTime;
251
252
  }
@@ -261,6 +262,138 @@
261
262
  void render();
262
263
  setInterval(() => void render(), 3e4);
263
264
 
265
+ // shared/site-risk.ts
266
+ var SITE_CHECKS_KEY = "localSiteChecksV1";
267
+ var SITE_CHECKS_PENDING_KEY = "localSiteWarnings";
268
+ var SITE_CHECKS_APPROVALS_KEY = "localSiteWarningApprovals";
269
+ var SITE_CHECKS_BLOCKED_KEY = "localBlockedSites";
270
+ var AUTOMATIC_SITE_ORIGINS = ["http://*/*", "https://*/*"];
271
+
272
+ // extension/src/site-protection-ui.ts
273
+ var root = document.getElementById("site-protection");
274
+ if (root) {
275
+ let button3 = function(label, message) {
276
+ const element = document.createElement("button");
277
+ element.textContent = label;
278
+ element.addEventListener("click", (event) => {
279
+ if (event.isTrusted) void busyButton(element, () => send(message));
280
+ });
281
+ return element;
282
+ }, row2 = function(label, controls, reasons = []) {
283
+ const item = document.createElement("li");
284
+ item.className = "site-warning";
285
+ const name = document.createElement("strong");
286
+ name.textContent = label;
287
+ item.append(name);
288
+ for (const reason of reasons) {
289
+ const line = document.createElement("p");
290
+ line.className = "note hint";
291
+ line.textContent = reason;
292
+ item.append(line);
293
+ }
294
+ const actions = document.createElement("div");
295
+ actions.className = "site-warning-actions";
296
+ actions.append(...controls);
297
+ item.append(actions);
298
+ return item;
299
+ };
300
+ button = button3, row = row2;
301
+ root.innerHTML = `
302
+ <h2>Suspicious-site checks</h2>
303
+ <p class="note hint">Normal sites work automatically. Suspicious sites need Allow.</p>
304
+ <p class="note hint" id="site-checks-state" role="status"></p>
305
+ <button id="site-checks-toggle" class="primary">Allow website access</button>
306
+ <button id="site-checks-manual" hidden>Use per-site approval</button>
307
+ <p class="note hint" id="site-checks-scope">Approved apps can read, send, delete and buy on websites.</p>
308
+ <details class="note hint"><summary>About checks</summary><p>Checks stay local and can miss threats. Page scripts run before checks.</p></details>
309
+ <p class="note hint" id="site-checks-error" role="status" aria-live="polite"></p>
310
+ <div id="site-warnings-section" hidden><h3>Waiting for Allow</h3><ul id="site-warnings" class="sites access-list"></ul></div>
311
+ <div id="site-exceptions-section" hidden><h3>Allowed warnings</h3><p class="note hint">New reasons ask again.</p><ul id="site-exceptions" class="sites access-list"></ul></div>
312
+ <div id="site-blocks-section" hidden><h3>Blocked websites</h3><ul id="site-blocks" class="sites access-list"></ul></div>
313
+ <div id="site-block-controls" hidden><button id="site-block-current">Block this website</button><div class="site-block-entry"><input id="site-block-host" aria-label="Website to block" placeholder="example.com"><button id="site-block-add">Block</button></div></div>`;
314
+ const el = (id) => document.getElementById(id);
315
+ let revision = 0;
316
+ let active = false;
317
+ async function send(message) {
318
+ el("site-checks-error").textContent = "";
319
+ try {
320
+ const response = await chrome.runtime.sendMessage(message);
321
+ if (!response?.ok) throw new Error(response?.error ?? "Could not save website access.");
322
+ } catch (error) {
323
+ el("site-checks-error").textContent = error instanceof Error ? error.message : "Could not save website access.";
324
+ }
325
+ await render4();
326
+ }
327
+ async function render4() {
328
+ const mine = ++revision;
329
+ const saved = await chrome.storage.local.get([
330
+ SITE_CHECKS_KEY,
331
+ SITE_CHECKS_PENDING_KEY,
332
+ SITE_CHECKS_APPROVALS_KEY,
333
+ SITE_CHECKS_BLOCKED_KEY,
334
+ "siteChecksSupported",
335
+ "connState",
336
+ ACCESS_STOPPED_KEY
337
+ ]);
338
+ const granted = await chrome.permissions.contains({ origins: AUTOMATIC_SITE_ORIGINS });
339
+ if (mine !== revision) return;
340
+ const connected = saved.connState === "connected" && !saved[ACCESS_STOPPED_KEY];
341
+ const supported = saved.siteChecksSupported === true;
342
+ const configured = saved[SITE_CHECKS_KEY] !== false;
343
+ active = configured && granted && supported;
344
+ const toggle = el("site-checks-toggle");
345
+ if (!toggle.disabled) toggle.textContent = active ? "Turn off" : configured ? "Allow website access" : "Turn on";
346
+ toggle.hidden = !connected || !supported;
347
+ el("site-checks-state").textContent = !connected ? "Connect your app to continue." : !supported ? "Unavailable with this server. Update it or check its settings." : active ? "On." : configured ? "On. Chrome permission needed." : "Off.";
348
+ el("site-checks-manual").hidden = !connected || !configured || active;
349
+ el("site-checks-scope").hidden = active || !supported;
350
+ const requests = Array.isArray(saved[SITE_CHECKS_PENDING_KEY]) ? saved[SITE_CHECKS_PENDING_KEY] : [];
351
+ renderList(el("site-warnings"), requests, (r) => r.origin, (r) => JSON.stringify(r.warnings), (request) => row2(request.origin, [
352
+ button3("Allow", { type: "site_warning_allow", origin: request.origin, reasons: request.warnings.map((w) => w.id) }),
353
+ button3("Block", { type: "site_block", host: request.host, block: true })
354
+ ], request.warnings.map((w) => w.reason)));
355
+ el("site-warnings-section").hidden = !active || !connected || !requests.length;
356
+ const approvals = Object.keys(saved[SITE_CHECKS_APPROVALS_KEY] ?? {});
357
+ renderList(el("site-exceptions"), approvals, (s) => s, (s) => s, (origin) => row2(origin, [
358
+ button3("Remove", { type: "site_warning_revoke", origin })
359
+ ]));
360
+ el("site-exceptions-section").hidden = !active || !connected || !approvals.length;
361
+ const blocked = Array.isArray(saved[SITE_CHECKS_BLOCKED_KEY]) ? saved[SITE_CHECKS_BLOCKED_KEY] : [];
362
+ renderList(el("site-blocks"), blocked, (s) => s, (s) => s, (host) => row2(host, [
363
+ button3("Restore", { type: "site_block", host, block: false })
364
+ ]));
365
+ el("site-blocks-section").hidden = !active || !connected || !blocked.length;
366
+ el("site-block-controls").hidden = !active || !connected;
367
+ }
368
+ el("site-checks-toggle").addEventListener("click", (event) => {
369
+ if (event.isTrusted) void busyButton(el("site-checks-toggle"), () => send({ type: "site_checks_mode", allow: !active })).finally(() => void render4());
370
+ });
371
+ el("site-checks-manual").addEventListener("click", (event) => {
372
+ if (event.isTrusted) void busyButton(el("site-checks-manual"), () => send({ type: "site_checks_mode", allow: false }));
373
+ });
374
+ el("site-block-current").addEventListener("click", (event) => {
375
+ if (!event.isTrusted) return;
376
+ void busyButton(el("site-block-current"), async () => {
377
+ const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
378
+ if (tab?.url && /^https?:\/\//.test(tab.url)) await send({ type: "site_block", host: new URL(tab.url).hostname, block: true });
379
+ else el("site-checks-error").textContent = "Open a website or enter its address below.";
380
+ });
381
+ });
382
+ el("site-block-add").addEventListener("click", (event) => {
383
+ if (!event.isTrusted) return;
384
+ const host = el("site-block-host").value.trim();
385
+ if (host) void busyButton(el("site-block-add"), () => send({ type: "site_block", host, block: true }));
386
+ });
387
+ chrome.storage.onChanged.addListener((_changes, area) => {
388
+ if (area === "local") void render4();
389
+ });
390
+ chrome.permissions.onAdded.addListener(() => void render4());
391
+ chrome.permissions.onRemoved.addListener(() => void render4());
392
+ void render4();
393
+ }
394
+ var button;
395
+ var row;
396
+
264
397
  // extension/src/activity-dashboard.ts
265
398
  var stop = document.getElementById("access-stop");
266
399
  var resume = document.getElementById("access-resume");
@@ -346,10 +479,10 @@
346
479
  }
347
480
  }
348
481
  function control(id, type, note3) {
349
- const button2 = document.getElementById(id);
350
- button2.addEventListener("click", async (event) => {
482
+ const button3 = document.getElementById(id);
483
+ button3.addEventListener("click", async (event) => {
351
484
  if (!event.isTrusted) return;
352
- button2.disabled = true;
485
+ button3.disabled = true;
353
486
  try {
354
487
  const result = await chrome.runtime.sendMessage({ type });
355
488
  note3.dataset.error = String(!result?.ok);
@@ -358,7 +491,7 @@
358
491
  note3.dataset.error = "true";
359
492
  note3.textContent = "Could not reach the extension. Reopen this page and try again.";
360
493
  } finally {
361
- button2.disabled = false;
494
+ button3.disabled = false;
362
495
  }
363
496
  if (type !== "activity_clear") await renderAccess();
364
497
  else if (note3.dataset.error !== "true") await renderHistory();
@@ -423,21 +556,21 @@
423
556
  if (generation !== rendering) return;
424
557
  renderList(list3, features, ({ feature }) => feature, ({ granted }) => String(granted), ({ feature, granted }) => {
425
558
  const { label, explanation } = OPTIONAL_FEATURES[feature];
426
- const row = document.createElement("li");
427
- row.className = "client-row";
428
- row.dataset.feature = feature;
559
+ const row2 = document.createElement("li");
560
+ row2.className = "client-row";
561
+ row2.dataset.feature = feature;
429
562
  const title = document.createElement("strong");
430
563
  title.textContent = label;
431
564
  const description = document.createElement("p");
432
565
  description.className = "note hint";
433
566
  description.textContent = explanation;
434
- const button2 = document.createElement("button");
435
- button2.className = granted ? "ghost" : "primary";
436
- button2.textContent = granted ? `Remove ${label.toLowerCase()}` : `Allow ${label.toLowerCase()}`;
437
- button2.addEventListener("click", async (event) => {
567
+ const button3 = document.createElement("button");
568
+ button3.className = granted ? "ghost" : "primary";
569
+ button3.textContent = granted ? `Remove ${label.toLowerCase()}` : `Allow ${label.toLowerCase()}`;
570
+ button3.addEventListener("click", async (event) => {
438
571
  if (!event.isTrusted) return;
439
572
  try {
440
- await busyButton(button2, async () => {
573
+ await busyButton(button3, async () => {
441
574
  const result = await chrome.runtime.sendMessage({ type: "feature_access", feature, allow: !granted });
442
575
  note2.textContent = result?.ok ? "" : result?.error ?? "Could not change this permission. Please try again.";
443
576
  });
@@ -446,8 +579,8 @@
446
579
  }
447
580
  await render2();
448
581
  });
449
- row.append(title, description, button2);
450
- return row;
582
+ row2.append(title, description, button3);
583
+ return row2;
451
584
  });
452
585
  section.hidden = features.length === 0;
453
586
  }
@@ -611,7 +744,7 @@
611
744
  await renderSites();
612
745
  sitesNoteEl.textContent = res.ok ? "" : res.error ?? "Could not change website access. Please try again.";
613
746
  }
614
- function button(label, onClick) {
747
+ function button2(label, onClick) {
615
748
  const b = document.createElement("button");
616
749
  b.textContent = label;
617
750
  b.addEventListener("click", (event) => {
@@ -637,13 +770,16 @@
637
770
  var sitesGeneration = 0;
638
771
  async function renderSites() {
639
772
  const generation = ++sitesGeneration;
640
- const { allowedSites, grantedSites, blockedSites, dismissedSites, connState } = await chrome.storage.local.get([
773
+ const { allowedSites, grantedSites, blockedSites, dismissedSites, connState, siteChecksSupported, [SITE_CHECKS_KEY]: selected } = await chrome.storage.local.get([
774
+ SITE_CHECKS_KEY,
775
+ "siteChecksSupported",
641
776
  "allowedSites",
642
777
  "grantedSites",
643
778
  "blockedSites",
644
779
  "dismissedSites",
645
780
  "connState"
646
781
  ]);
782
+ const automatic = selected !== false && siteChecksSupported === true;
647
783
  const allowed = Array.isArray(allowedSites) ? allowedSites.map(normalizeDomainPattern).filter(Boolean) : [];
648
784
  const granted = Array.isArray(grantedSites) ? grantedSites : null;
649
785
  const permitted = await permittedSites(allowed);
@@ -657,17 +793,18 @@
657
793
  (host) => host,
658
794
  (host) => siteRow(host, [
659
795
  tag("needs permission"),
660
- button("Allow", () => grant(host, true)),
661
- button("Dismiss", () => chrome.runtime.sendMessage({ type: "dismiss_blocked", host }))
796
+ button2("Allow", () => grant(host, true)),
797
+ button2("Dismiss", () => chrome.runtime.sendMessage({ type: "dismiss_blocked", host }))
662
798
  ])
663
799
  );
664
- blockedWrapEl.hidden = blocked.length === 0 || connState !== "connected";
800
+ blockedWrapEl.hidden = !!automatic || blocked.length === 0 || connState !== "connected";
801
+ document.getElementById("sites-section").hidden = !!automatic;
665
802
  renderList(
666
803
  allowedEl,
667
804
  permitted,
668
805
  (host) => host,
669
806
  (host) => JSON.stringify([host, granted?.includes(host)]),
670
- (host) => siteRow(host, [...granted?.includes(host) ? [] : [tag("set by server flags")], button("Remove", () => grant(host, false))])
807
+ (host) => siteRow(host, [...granted?.includes(host) ? [] : [tag("set by server flags")], button2("Remove", () => grant(host, false))])
671
808
  );
672
809
  if (connState !== "connected") {
673
810
  sitesNoteEl.textContent = "Connect to the MCP Browser Extension server to see and change the allowed sites.";
@@ -702,7 +839,7 @@
702
839
  }
703
840
  if (area === "local" && changes.connState) render3(String(changes.connState.newValue));
704
841
  if (area === "local" && changes.pairedProfile) renderPairedAs(changes.pairedProfile.newValue);
705
- if (area === "local" && (changes.allowedSites || changes.grantedSites || changes.blockedSites || changes.dismissedSites || changes.connState)) {
842
+ if (area === "local" && (changes[SITE_CHECKS_KEY] || changes.siteChecksSupported || changes.allowedSites || changes.grantedSites || changes.blockedSites || changes.dismissedSites || changes.connState)) {
706
843
  void renderSites();
707
844
  }
708
845
  });
@@ -3,47 +3,9 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <title>MCP Browser Extension</title>
6
+ <link rel="stylesheet" href="brand.css" />
6
7
  <link rel="stylesheet" href="activity-dashboard.css" />
7
8
  <style>
8
- :root {
9
- --bg: #ffffff;
10
- --panel: #f6f7f9;
11
- --card: #ffffff;
12
- --fg: #0f172a;
13
- --muted: #64748b;
14
- --line: #e6e8ec;
15
- --ok: #16a34a;
16
- --ok-text: #15803d;
17
- --ok-soft: #dcfce7;
18
- --warn: #c2410c;
19
- --warn-soft: #fff1e6;
20
- --bad: #dc2626;
21
- --accent: oklch(0.56 0.19 255);
22
- --accent-foreground: oklch(0.99 0 0);
23
- --accent-2: var(--accent);
24
- --ring: oklch(0.56 0.19 255 / 35%);
25
- --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.06);
26
- }
27
- @media (prefers-color-scheme: dark) {
28
- :root {
29
- --bg: #0b0d12;
30
- --panel: #11141b;
31
- --card: #161a23;
32
- --fg: #e8ebf2;
33
- --muted: #8b93a7;
34
- --line: #232836;
35
- --ok: #34d399;
36
- --ok-text: #34d399;
37
- --ok-soft: rgba(52, 211, 153, 0.12);
38
- --warn: #fb923c;
39
- --warn-soft: rgba(251, 146, 60, 0.1);
40
- --accent: oklch(0.7 0.16 255);
41
- --accent-foreground: oklch(0.12 0.02 255);
42
- --accent-2: var(--accent);
43
- --ring: oklch(0.7 0.16 255 / 45%);
44
- --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 6px 20px rgba(0, 0, 0, 0.35);
45
- }
46
- }
47
9
  * { box-sizing: border-box; }
48
10
  html { width: 360px; min-width: 360px; scrollbar-width: none; }
49
11
  html::-webkit-scrollbar { display: none; }
@@ -135,8 +97,8 @@
135
97
  button { min-height: 32px; font: inherit; font-size: 12px; font-weight: 500; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; transition: background 0.15s, border-color 0.15s; }
136
98
  button:hover { border-color: color-mix(in srgb, var(--fg) 25%, var(--line)); }
137
99
  button:active { background: var(--panel); }
138
- button.primary { border-color: transparent; color: var(--accent-foreground); background: var(--accent); }
139
- button.primary:hover { background: color-mix(in oklch, var(--accent) 88%, var(--fg)); }
100
+ button.primary { border-color: var(--button-primary-line); color: var(--button-primary-fg); background: var(--button-primary-bg); }
101
+ button.primary:hover { background: var(--button-primary-hover); }
140
102
  button.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 8px; }
141
103
  button.ghost:hover { color: var(--fg); background: var(--panel); }
142
104
  button:disabled { cursor: wait; opacity: 0.6; }
@@ -163,6 +125,18 @@
163
125
  }
164
126
 
165
127
  [hidden] { display: none !important; }
128
+ .phone-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
129
+ .phone-heading h2 { margin: 0; }
130
+ #phone-dialog { width: 336px; max-height: 520px; margin: auto; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--fg); box-shadow: var(--shadow); }
131
+ #phone-dialog::backdrop { background: rgb(0 0 0 / 55%); }
132
+ #phone-dialog button { min-height: 44px; }
133
+ #phone-qr { display: block; width: 264px; height: 264px; max-width: 100%; margin: 16px auto 8px; background: #fff; border-radius: 8px; }
134
+ #phone-expiry { text-align: center; font-variant-numeric: tabular-nums; }
135
+ #phone-error { color: var(--warn); }
136
+ #phone-devices li { border-top: 1px solid var(--line); padding: 12px 0; overflow-wrap: anywhere; }
137
+ #phone-devices strong { display: block; }
138
+ .phone-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
139
+ .phone-code { font-size: 20px; font-weight: 600; letter-spacing: 3px; font-variant-numeric: tabular-nums; }
166
140
  </style>
167
141
  </head>
168
142
  <body data-view="popup">
@@ -189,6 +163,11 @@
189
163
  <p class="note" id="access-note" role="status"></p>
190
164
  </section>
191
165
 
166
+ <section class="card" id="phone-section" aria-label="Phone access">
167
+ <div class="phone-heading"><h2>Phone access</h2><button id="phone-open">Pair phone</button></div>
168
+ <p class="note">Connect your phone by scanning a QR code.</p>
169
+ </section>
170
+
192
171
  <section class="card" id="clients-section">
193
172
  <h2>App connections <span class="count" id="client-count"></span></h2>
194
173
  <p class="note" id="client-help" hidden>Approve only an app you opened. Match the key shown in your app.</p>
@@ -200,6 +179,8 @@
200
179
  </details>
201
180
  </section>
202
181
 
182
+ <link rel="stylesheet" href="site-protection.css" />
183
+ <section class="card" id="site-protection"></section>
203
184
  <section class="card blocked" id="blocked-section" hidden>
204
185
  <h2>Website access <span class="count" id="blocked-count"></span></h2>
205
186
  <p class="note">Allow lets approved apps read and act here, including sending, deleting and buying. Accept Chrome’s prompt if shown.</p>
@@ -263,6 +244,17 @@
263
244
  </span>
264
245
  <button class="footer-link" id="settings">Settings <span aria-hidden="true">→</span></button>
265
246
  </footer>
247
+ <dialog id="phone-dialog" aria-labelledby="phone-title" aria-describedby="phone-description">
248
+ <div class="phone-heading"><h2 id="phone-title">Pair your phone</h2><button id="phone-close" aria-label="Close phone pairing">Close</button></div>
249
+ <p class="note" id="phone-description">Scan with the MCP Browser Extension mobile app, then approve the phone here.</p>
250
+ <p class="note" id="phone-status" role="status" aria-live="polite"></p>
251
+ <p class="note" id="phone-error" role="alert" hidden></p>
252
+ <canvas id="phone-qr" role="img" aria-label="Temporary phone pairing QR code" hidden></canvas>
253
+ <p class="note" id="phone-expiry" hidden></p>
254
+ <div class="phone-actions"><button class="primary" id="phone-generate">Generate QR code</button><button id="phone-cancel" hidden>Cancel pairing</button></div>
255
+ <ul id="phone-devices" aria-label="Paired phones and pairing requests"></ul>
256
+ <p class="note">Phones can use only websites you allow in this browser. Access lasts 30 days. Keep your computer awake and Chrome open.</p>
257
+ </dialog>
266
258
  <script src="popup.js"></script>
267
259
  </body>
268
260
  </html>