agentleFS
Miyamura80Miyamura80/MCP-Template/.agents/skills/local-sandbox/SKILL.md

local-sandbox

Skill1 starsChanged 5 months agoMITView on GitHub

Preview an MCP-UI app (mcp_server/apps/*) from fixtures in a browser with no MCP server, Gmail, OAuth, or network. Use when asked to see, screenshot, or test how an MCP App iframe renders, or to render it live in the Claude Code cloud.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this when the task is "show me how the <app> app looks", "screenshot the MCP App", "does the iframe render", or "preview it here in the …

    line 13
  2. Very specific:

    Add the app's initial payload to initialResult() - the first tool result pushed on load, which drives the first paint (an inbox curate …

    line 84
  3. Very specific:

    If an app shows a stuck "Loading..." / "Waiting..." state, it likely registers its ontoolresult handler after mount and missed the first …

    line 93
  4. Very specific:

    Do not put em dashes in any committed source.

    line 105

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Local sandbox: preview MCP-UI apps from fixtures

Render a committed MCP App bundle (mcp_server/apps/<name>/dist/mcp-app.html) in a browser driven by canned data, so you can see and click the UI without a running MCP server, Gmail account, OAuth, or a tunnel. The harness lives in mcp_server/dev_preview/ (read its README.md for design details).

Use this when the task is "show me how the <app> app looks", "screenshot the MCP App", "does the iframe render", or "preview it here in the cloud".

1. Build the preview

make preview_app APP=gmail_inbox      # -> mcp_server/dev_preview/dist/gmail_inbox-preview.html
make preview_app APP=gmail_composer

APP is any directory under mcp_server/apps/. The output is one self-contained HTML file (the app bundle is inlined), so it also renders when opened standalone. dist/mcp-app.html is committed, so this works out of the box; if you changed an app's frontend, run make build_apps first.

Tune the inline width to match a client (a narrow width triggers the app's single-column mobile layout):

make preview_app APP=gmail_inbox WIDTH=460

2. Confirm it actually rendered

make preview_smoke APP=gmail_inbox     # headless Playwright; asserts fixture content painted

A pass means the app connected, received fixtures, and painted an app-specific marker (not just "connected but blank").

3. See it in the Claude Code cloud

The generated file is what you surface. Two ways, pick by what the user wants:

  • Screenshot (static, guaranteed): drive the file with the preinstalled Chromium and send the PNG. Reliable and needs no CSP cooperation.
  • Artifact (live, interactive): publish dist/<app>-preview.html as an Artifact so the user can click around in the side panel. It is fully self-contained (no external requests), which satisfies the Artifact CSP.

Screenshot snippet (Chromium is preinstalled under /opt/pw-browsers in the sandbox; bun run it from mcp_server/dev_preview/):

import { chromium } from "playwright";
import { globSync } from "node:fs";
const exe = globSync("/opt/pw-browsers/chromium-*/chrome-linux/chrome")[0];
const app = process.env.APP || "gmail_inbox";
const b = await chromium.launch({ executablePath: exe, args: ["--no-sandbox", "--allow-file-access-from-files"] });
const p = await b.newPage({ viewport: { width: 900, height: 900 }, deviceScaleFactor: 2 });
await p.goto(`file://${process.cwd()}/dist/${app}-preview.html`, { waitUntil: "load" });
await p.waitForFunction(() => window.__READY__ === true, { timeout: 20000 }).catch(() => {});
await p.waitForTimeout(1500);
await p.screenshot({ path: `/tmp/${app}.png`, fullPage: true });
await b.close();

To interact (e.g. open a thread), find the app iframe and click a selector before screenshotting:

const frame = p.frames().find((f) => f !== p.mainFrame());
await frame.click('[data-testid="row-t-1001"]');   // gmail_inbox thread row
await p.waitForTimeout(1000);

4. Add fixtures for a new app

Edit mcp_server/dev_preview/src/fixtures.ts:

  1. Add the app's initial payload to initialResult() - the first tool result pushed on load, which drives the first paint (an inbox curate list, a composer draft, etc.). Match the shape the app's ontoolresult expects (see mcp_server/apps/<name>/src/*.tsx).
  2. Handle the app's tool names in dispatch() - each callServerTool(name) the app makes (thread opens, saves, etc.). Return ok(data); unknown names fall through to an empty result.
  3. make preview_app APP=<name> and screenshot.

If an app shows a stuck "Loading..." / "Waiting..." state, it likely registers its ontoolresult handler after mount and missed the first result; the host already re-sends over the first ~700ms, so first check the initial payload shape and the tool names in dispatch().

Gotchas

  • Needs bun and a Chromium. Both are preinstalled in the Claude Code cloud sandbox; locally, bunx playwright install chromium once.
  • The harness is a JS-only island (like mcp_server/apps/) and is intentionally out of make ci, matching make build_apps.
  • dist/ is gitignored - regenerate with make preview_app, do not commit it.
  • Do not put em dashes in any committed source; the ai-writing pre-commit hook rejects them (use " - ").

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.