inspector icon indicating copy to clipboard operation
inspector copied to clipboard

Offline mode: no third-party requests from the web UI

Open CloneOfAlex opened this issue 1 month ago • 2 comments

Which client?

Web

The problem

The web UI fetches fonts from fonts.googleapis.com on every load, and the ContentViewer CSP allows Google font origins. In air-gapped, regulated or privacy-sensitive environments (and in the Docker image) that is either a failure (console errors, fallback fonts) or an unwanted disclosure of the user's IP to a third party.

Solution you have in mind (optional)

Self-host the fonts in the bundle by default; optionally a --no-external-assets flag / env var that guarantees the web UI and its CSPs make no third-party requests.

Alternatives or workarounds you have tried

Blocking the domains at a proxy, which still logs errors on every load.

Already built it locally?

No response

Before you submit

  • [x] I searched existing issues and this is not a duplicate.
  • [x] This is a request for the Inspector itself, not for the MCP specification or an SDK.

CloneOfAlex avatar Oct 28 '26 23:10 CloneOfAlex

Triage: Priority Low (total 5)

  • Severity 3 — the web UI cannot run cleanly air-gapped and discloses the user IP to Google; overlaps item 1 of #2827
  • Urgency 2 — wanted eventually, nothing blocked on it
  • Bonuses: none (no milestone, assignee, epic, engagement or reporter-set priority)

Board: #28, Status Incoming (awaiting maintainer review — no milestone yet).

cliffhall avatar Oct 29 '26 03:10 cliffhall

Since #2856 (merged 2026-10-29, the day after this issue was filed), the web UI's own fonts are self-hosted, so the first half of this issue is done on v2/main. One third-party allowance is left: the CSP that HtmlFrame injects into previewed HTML resources (PREVIEW_HTML_CSP in clients/web/src/components/elements/ContentViewer/contentViewerUtils.ts) still allows https://fonts.googleapis.com in style-src and https://fonts.gstatic.com in font-src. A server-supplied HTML resource that links Google Fonts still makes the browser contact Google.

I prototyped the fix locally on v2/main @ 4fe3d9cc. Here is the prompt, so you can reproduce it through your own workflow:

Issue #2832. The web UI fonts are already self-hosted (#2856). In
clients/web/src/components/elements/ContentViewer/contentViewerUtils.ts,
remove https://fonts.googleapis.com from style-src and
https://fonts.gstatic.com from font-src in PREVIEW_HTML_CSP, leaving
"style-src 'unsafe-inline'" and "font-src data:". Update the JSDoc to say
the policy allows no network origin and that a linked web font falls back
to the document's own font-family stack. Add a test in
contentViewerUtils.test.ts asserting the policy contains no "http:",
"https:", "*" or "//" source.

Before / after, measured in Chromium (Playwright) against the prod build, with a server-style HTML document that links a Google font and loads the same way HtmlFrame does (blob URL, sandbox="", injected CSP <meta>):

Requests to Google Outcome
Current CSP 3 fonts.googleapis.com CSS and two fonts.gstatic.com woff2 files, each HTTP 200
Prototype CSP 0 reach the network Both blocked by the CSP before any network traffic (Playwright failure reason csp), 2 CSP violations logged

The web UI itself (home screen, prod build) made 10 requests, all to 127.0.0.1. Fredoka (300–700) and Roboto Mono (100–700) load from the bundle with font-display: swap.

Behavior change: an HTML resource that links a Google font now renders in the next family in its own font-family stack. A font inlined as data: still works.

On the --no-external-assets flag: with this change, I found no third-party request left that the Inspector makes on its own. The only remaining external loads are origins an MCP App declares in its own _meta.ui.csp, which the MCP Apps sandbox honors by design. A flag would only matter if you want an override that clamps server-declared app domains, which would break those apps. My suggestion is to close this issue without a flag, unless you want that override.

helloigig avatar Nov 03 '26 02:11 helloigig