mountly-mcp 4.0.2 → 4.2.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/GLOSSARY.md +37 -0
- package/README.md +103 -190
- package/dist/add-DAFMA4F3.js +263 -0
- package/dist/add-DAFMA4F3.js.map +1 -0
- package/dist/add.d.ts +13 -0
- package/dist/chunk-EOWAWZH2.js +34 -0
- package/dist/chunk-EOWAWZH2.js.map +1 -0
- package/dist/{chunk-KWVGW5Q7.js → chunk-GN2IQYV3.js} +1 -1
- package/dist/chunk-GN2IQYV3.js.map +1 -0
- package/dist/{chunk-UECZA34Q.js → chunk-OWAXBNZA.js} +10 -5
- package/dist/chunk-OWAXBNZA.js.map +1 -0
- package/dist/cli.js +97 -25
- package/dist/cli.js.map +1 -1
- package/dist/compose/index.d.ts +48 -0
- package/dist/compose/index.js +141 -0
- package/dist/compose/index.js.map +1 -0
- package/dist/connect-server-P2UZ62YC.js +7 -0
- package/dist/create.js +43 -15
- package/dist/create.js.map +1 -1
- package/dist/dev/host-entry.js +7 -0
- package/dist/dev/index.js +2 -2
- package/dist/doctor-B54H6CRN.js +122 -0
- package/dist/doctor-B54H6CRN.js.map +1 -0
- package/dist/doctor.d.ts +16 -0
- package/dist/errors-4ERW7HZB.js +11 -0
- package/dist/errors-4ERW7HZB.js.map +1 -0
- package/dist/errors.d.ts +25 -0
- package/dist/json-render/index.js +4 -4
- package/package.json +17 -5
- package/templates/react/README.md.tmpl +83 -6
- package/templates/react/package.json.tmpl +2 -0
- package/templates/react/serve-stdio.mjs.tmpl +9 -0
- package/templates/react/server.mjs.tmpl +6 -1
- package/templates/react/src/view.tsx.tmpl +1 -1
- package/templates/svelte/README.md.tmpl +27 -4
- package/templates/svelte/package.json.tmpl +2 -0
- package/templates/svelte/serve-stdio.mjs.tmpl +5 -0
- package/templates/svelte/server.mjs.tmpl +6 -1
- package/templates/svelte/src/Dashboard.svelte.tmpl +1 -1
- package/templates/vanilla/README.md.tmpl +27 -11
- package/templates/vanilla/package.json.tmpl +2 -0
- package/templates/vanilla/serve-stdio.mjs.tmpl +5 -0
- package/templates/vanilla/server.mjs.tmpl +6 -1
- package/templates/vanilla/src/view.ts.tmpl +1 -1
- package/templates/vue/README.md.tmpl +27 -4
- package/templates/vue/package.json.tmpl +2 -0
- package/templates/vue/serve-stdio.mjs.tmpl +5 -0
- package/templates/vue/server.mjs.tmpl +6 -1
- package/templates/vue/src/Dashboard.vue.tmpl +1 -1
- package/dist/chunk-KWVGW5Q7.js.map +0 -1
- package/dist/chunk-UECZA34Q.js.map +0 -1
- package/dist/connect-server-7L4HGKKL.js +0 -7
- /package/dist/{connect-server-7L4HGKKL.js.map → connect-server-P2UZ62YC.js.map} +0 -0
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
# {{name}}
|
|
2
2
|
|
|
3
|
-
MCP App scaffolded with `mountly-mcp create
|
|
3
|
+
MCP App scaffolded with `mountly-mcp create` (vanilla: no framework).
|
|
4
|
+
|
|
5
|
+
## Runbook
|
|
4
6
|
|
|
5
7
|
```bash
|
|
6
8
|
pnpm install
|
|
7
|
-
pnpm dev
|
|
8
|
-
pnpm verify
|
|
9
|
+
pnpm dev
|
|
10
|
+
pnpm verify
|
|
11
|
+
pnpm verify:render
|
|
9
12
|
```
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
| File | Role |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| `src/view.ts` | `publishMcpView`: `mount` / `update` / `unmount` |
|
|
17
|
+
| `server.mjs` | `registerMcpApps` factory |
|
|
18
|
+
| `mcp.fixtures.json` | Tool args for `dev --server` |
|
|
19
|
+
|
|
20
|
+
## Open in a real host
|
|
21
|
+
|
|
22
|
+
`serve-stdio.mjs` is included. Register that command in Claude Desktop / VS Code / ChatGPT.
|
|
14
23
|
|
|
15
|
-
|
|
16
|
-
`publishMcpView` takes the object directly. The bridge drives it exactly as it
|
|
17
|
-
drives a React, Vue or Svelte View. Add a framework later by swapping
|
|
18
|
-
`publishMcpView(...)` for that framework's `createMcpView(Component)`.
|
|
24
|
+
## CI
|
|
19
25
|
|
|
20
|
-
|
|
26
|
+
```bash
|
|
27
|
+
pnpm exec mountly-mcp build
|
|
28
|
+
pnpm exec playwright install chromium
|
|
29
|
+
pnpm exec mountly-mcp verify --strict --render
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Add another View
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm exec mountly-mcp add settings --framework vanilla
|
|
36
|
+
```
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
"dev": "mountly-mcp dev --server ./server.mjs",
|
|
9
9
|
"verify": "mountly-mcp verify",
|
|
10
10
|
"verify:strict": "mountly-mcp verify --strict",
|
|
11
|
+
"verify:render": "mountly-mcp verify --strict --render",
|
|
12
|
+
"doctor": "mountly-mcp doctor",
|
|
11
13
|
"typecheck": "tsc --noEmit"
|
|
12
14
|
},
|
|
13
15
|
"dependencies": {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
1
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
3
|
import { readMcpAppManifest } from "mountly-mcp/artifact";
|
|
3
4
|
import { registerMcpApps } from "mountly-mcp/server";
|
|
@@ -5,6 +6,10 @@ import { z } from "zod";
|
|
|
5
6
|
|
|
6
7
|
const URI = "{{uri}}";
|
|
7
8
|
|
|
9
|
+
// Resolved from this file, not the cwd: an MCP host spawns the process with a
|
|
10
|
+
// working directory of its own choosing.
|
|
11
|
+
const MANIFEST = fileURLToPath(new URL("./dist/mountly-mcp.manifest.json", import.meta.url));
|
|
12
|
+
|
|
8
13
|
function sampleCards() {
|
|
9
14
|
return [
|
|
10
15
|
{ label: "Requests", value: Math.floor(1200 + Math.random() * 200) },
|
|
@@ -20,7 +25,7 @@ export default async function createServer() {
|
|
|
20
25
|
{ capabilities: { tools: {}, resources: {} } },
|
|
21
26
|
);
|
|
22
27
|
|
|
23
|
-
const { artifacts } = await readMcpAppManifest(
|
|
28
|
+
const { artifacts } = await readMcpAppManifest(MANIFEST);
|
|
24
29
|
|
|
25
30
|
await registerMcpApps(server, {
|
|
26
31
|
views: artifacts.map((artifact) => ({ artifact })),
|
|
@@ -2,7 +2,7 @@ import { publishMcpView, type McpViewProps } from "mountly-mcp";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* No framework, no adapter. A View is just `mount` / `update` / `unmount`, so
|
|
5
|
-
* `publishMcpView` takes this object directly
|
|
5
|
+
* `publishMcpView` takes this object directly. The bridge drives it exactly
|
|
6
6
|
* as it drives a React, Vue or Svelte View.
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -1,14 +1,37 @@
|
|
|
1
1
|
# {{name}}
|
|
2
2
|
|
|
3
|
-
MCP App scaffolded with `mountly-mcp create
|
|
3
|
+
MCP App scaffolded with `mountly-mcp create` (Vue).
|
|
4
|
+
|
|
5
|
+
## Runbook
|
|
4
6
|
|
|
5
7
|
```bash
|
|
6
8
|
pnpm install
|
|
7
9
|
pnpm dev
|
|
8
10
|
pnpm verify
|
|
11
|
+
pnpm verify:render
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
| File | Role |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| `src/view.ts` | `createMcpView` entry |
|
|
17
|
+
| `src/Dashboard.vue` | View UI: `useToolResult` |
|
|
18
|
+
| `server.mjs` | `registerMcpApps` factory |
|
|
19
|
+
| `mcp.fixtures.json` | Tool args for `dev --server` |
|
|
20
|
+
|
|
21
|
+
## Open in a real host
|
|
22
|
+
|
|
23
|
+
`serve-stdio.mjs` is included. Point Claude Desktop / VS Code at `node` + absolute path to that file (see the React scaffold README for JSON shapes). ChatGPT: use your connector against the same process.
|
|
24
|
+
|
|
25
|
+
## CI
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm exec mountly-mcp build
|
|
29
|
+
pnpm exec playwright install chromium
|
|
30
|
+
pnpm exec mountly-mcp verify --strict --render
|
|
9
31
|
```
|
|
10
32
|
|
|
11
|
-
|
|
12
|
-
- Server: `server.mjs` (`registerMcpApps`)
|
|
33
|
+
## Add another View
|
|
13
34
|
|
|
14
|
-
|
|
35
|
+
```bash
|
|
36
|
+
pnpm exec mountly-mcp add settings --framework vue
|
|
37
|
+
```
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
"dev": "mountly-mcp dev --server ./server.mjs",
|
|
9
9
|
"verify": "mountly-mcp verify",
|
|
10
10
|
"verify:strict": "mountly-mcp verify --strict",
|
|
11
|
+
"verify:render": "mountly-mcp verify --strict --render",
|
|
12
|
+
"doctor": "mountly-mcp doctor",
|
|
11
13
|
"typecheck": "vue-tsc --noEmit"
|
|
12
14
|
},
|
|
13
15
|
"dependencies": {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
1
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
3
|
import { readMcpAppManifest } from "mountly-mcp/artifact";
|
|
3
4
|
import { registerMcpApps } from "mountly-mcp/server";
|
|
@@ -5,6 +6,10 @@ import { z } from "zod";
|
|
|
5
6
|
|
|
6
7
|
const URI = "{{uri}}";
|
|
7
8
|
|
|
9
|
+
// Resolved from this file, not the cwd: an MCP host spawns the process with a
|
|
10
|
+
// working directory of its own choosing.
|
|
11
|
+
const MANIFEST = fileURLToPath(new URL("./dist/mountly-mcp.manifest.json", import.meta.url));
|
|
12
|
+
|
|
8
13
|
function sampleCards() {
|
|
9
14
|
return [
|
|
10
15
|
{ label: "Requests", value: Math.floor(1200 + Math.random() * 200) },
|
|
@@ -20,7 +25,7 @@ export default async function createServer() {
|
|
|
20
25
|
{ capabilities: { tools: {}, resources: {} } },
|
|
21
26
|
);
|
|
22
27
|
|
|
23
|
-
const { artifacts } = await readMcpAppManifest(
|
|
28
|
+
const { artifacts } = await readMcpAppManifest(MANIFEST);
|
|
24
29
|
|
|
25
30
|
await registerMcpApps(server, {
|
|
26
31
|
views: artifacts.map((artifact) => ({ artifact })),
|
|
@@ -68,7 +68,7 @@ async function refresh() {
|
|
|
68
68
|
<p class="eyebrow">MCP App · Mountly</p>
|
|
69
69
|
<h1>{{ title }}</h1>
|
|
70
70
|
<p class="subtitle">
|
|
71
|
-
Built with <code>mountly-mcp</code
|
|
71
|
+
Built with <code>mountly-mcp</code>. Try Refresh to call an app-only tool.
|
|
72
72
|
</p>
|
|
73
73
|
<div class="grid">
|
|
74
74
|
<div v-if="cards.length === 0" v-for="i in 3" :key="i" class="metric">
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dev/index.ts"],"sourcesContent":["/**\n * A local MCP Apps host, so a View can be developed without installing a\n * real host and restarting it on every change.\n *\n * It is a genuine host, not a preview shim: two origins as the spec requires\n * (§8.4), a sandbox proxy that injects the sidecar's CSP and permissions, the\n * full `ui/initialize` handshake, and tool-input/tool-result delivery. A View\n * that works here works in Claude, and one that reaches for `eval` fails here\n * for the same reason it would fail there.\n *\n * ```ts\n * const host = await startDevHost({ htmlPath: \"dist/view.html\", fixtures });\n * console.log(host.hostUrl);\n * ```\n */\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { createServer, type Server } from \"node:http\";\nimport { fileURLToPath } from \"node:url\";\nimport type { McpResourceDeclaration } from \"../types.js\";\nimport { escapeInlineScript, serializeInlineScriptValue } from \"../html.js\";\n\nexport interface DevHostOptions {\n /** Built View HTML. Its `.meta.json` sidecar is read alongside. */\n htmlPath: string;\n /**\n * Named samples, each becoming a button in the host chrome.\n *\n * Without `callTool` the value is delivered straight through as\n * `structuredContent`. With `callTool` it is the tool's *arguments*, and\n * what the view receives is whatever the real tool returns.\n */\n fixtures?: Record<string, unknown>;\n /**\n * Run a real tool. Supplied when the developer points `dev` at their server,\n * and used both for the fixture buttons and for `tools/call` requests the\n * view makes itself — so app-only tools behave as they will in production.\n */\n callTool?: (name: string, args: unknown) => Promise<unknown>;\n /** Arguments delivered as `ui/notifications/tool-input`. */\n toolInput?: Record<string, unknown>;\n /** Shown in the host chrome. Defaults to the sidecar's resource name. */\n toolName?: string;\n /** Defaults to 5179, incrementing until a free port is found. */\n hostPort?: number;\n /** Defaults to `hostPort + 1`, incrementing until a free port is found. */\n sandboxPort?: number;\n}\n\nexport interface DevHost {\n hostUrl: string;\n sandboxUrl: string;\n /** Tell connected browsers to reload — call after a rebuild. */\n reload(): void;\n close(): Promise<void>;\n}\n\nfunction escapeHtml(value: string): string {\n return value.replace(\n /[&<>\"']/g,\n (character) =>\n ({ \"&\": \"&\", \"<\": \"<\", \">\": \">\", '\"': \""\", \"'\": \"'\" })[character]!,\n );\n}\n\nconst runtimeCache = new Map<string, Promise<string>>();\n\n/**\n * Load one of the browser-side runtimes (`host-entry`, `sandbox-entry`) as a\n * string to inline into a page.\n *\n * Installed, the built IIFE is a declared package export, so ask the module\n * resolver for it. Walking from `import.meta.url` breaks the moment a bundler\n * hoists this module into a shared chunk at a different depth — which is what\n * tsup does, leaving it looking in dist/ while the file sits in dist/dev/.\n */\nfunction loadRuntime(name: \"host-entry\" | \"sandbox-entry\"): Promise<string> {\n const cached = runtimeCache.get(name);\n if (cached) return cached;\n const loading = (async () => {\n try {\n return await readFile(\n fileURLToPath(import.meta.resolve(`mountly-mcp/dev/${name}.js`)),\n \"utf8\",\n );\n } catch {\n // Running from source in this repo, where nothing is built yet.\n }\n const entry = fileURLToPath(new URL(`./${name}.ts`, import.meta.url));\n if (!existsSync(entry)) {\n throw new Error(\n `mountly-mcp dev: ${name} runtime missing. Expected the packaged 'mountly-mcp/dev/${name}.js' export, or ${entry} when running from source.`,\n );\n }\n const { build } = await import(\"vite\");\n const result = await build({\n configFile: false,\n logLevel: \"silent\",\n build: {\n write: false,\n target: \"es2022\",\n minify: false,\n lib: { entry, formats: [\"iife\"], name: \"__mountlyMcpDevRuntime\" },\n },\n });\n const outputs = Array.isArray(result) ? result : [result];\n const chunk = outputs\n .flatMap((output) => (\"output\" in output ? output.output : []))\n .find((item) => item.type === \"chunk\");\n if (!chunk || chunk.type !== \"chunk\")\n throw new Error(`mountly-mcp dev: failed to bundle ${name}`);\n return chunk.code;\n })();\n runtimeCache.set(name, loading);\n return loading;\n}\n\nfunction listenOnFreePort(server: Server, port: number): Promise<number> {\n return new Promise((resolvePort, reject) => {\n const attempt = (candidate: number): void => {\n // Listeners are paired and torn down together: `listen()`'s callback form\n // leaves a stale one attached across retries, which then resolves with\n // the port that was already taken.\n const onError = (error: NodeJS.ErrnoException): void => {\n server.removeListener(\"listening\", onListening);\n // ponytail: linear probe, fine for a dev tool on a developer's laptop.\n if (error.code === \"EADDRINUSE\" && candidate < port + 50) attempt(candidate + 1);\n else reject(error);\n };\n const onListening = (): void => {\n server.removeListener(\"error\", onError);\n const address = server.address();\n resolvePort(typeof address === \"object\" && address !== null ? address.port : candidate);\n };\n server.once(\"error\", onError);\n server.once(\"listening\", onListening);\n server.listen(candidate);\n };\n attempt(port);\n });\n}\n\nexport async function startDevHost(options: DevHostOptions): Promise<DevHost> {\n const { htmlPath, fixtures = {}, toolInput = {}, callTool } = options;\n\n const metaPath = `${htmlPath}.meta.json`;\n const initialMeta = JSON.parse(await readFile(metaPath, \"utf8\")) as McpResourceDeclaration;\n const toolName = options.toolName ?? initialMeta.name;\n const [hostRuntime, sandboxRuntime] = await Promise.all([\n loadRuntime(\"host-entry\"),\n loadRuntime(\"sandbox-entry\"),\n ]);\n\n // Bumped on reload(); the browser polls it and reloads when it changes. The\n // View HTML is read per request rather than baked into the page, so a\n // rebuild is picked up with no server restart.\n let version = 1;\n\n // The two servers reference each other's origin, and each only needs the\n // other's once a request arrives — so the sandbox reads this after the host\n // has bound its port.\n let hostOrigin = \"\";\n\n const sandboxServer = createServer((_req, res) => {\n res.writeHead(200, { \"Content-Type\": \"text/html; charset=utf-8\", \"Cache-Control\": \"no-store\" });\n res.end(sandboxProxyShell(hostOrigin, sandboxRuntime));\n });\n const sandboxPort = await listenOnFreePort(\n sandboxServer,\n options.sandboxPort ?? (options.hostPort ?? 5179) + 1,\n );\n const sandboxOrigin = `http://localhost:${sandboxPort}`;\n\n const hostServer = createServer(async (req, res) => {\n const path = new URL(req.url ?? \"/\", \"http://localhost\").pathname;\n const send = (status: number, type: string, body: string | Buffer): void => {\n res.writeHead(status, { \"Content-Type\": type, \"Cache-Control\": \"no-store\" });\n res.end(body);\n };\n try {\n if (path === \"/call\" && req.method === \"POST\") {\n if (!callTool) return send(400, \"text/plain\", \"no server connected\");\n const body = await new Promise<string>((done, fail) => {\n let raw = \"\";\n req.on(\"data\", (chunk) => (raw += chunk));\n req.on(\"end\", () => done(raw));\n req.on(\"error\", fail);\n });\n const { name, arguments: args } = JSON.parse(body) as { name: string; arguments?: unknown };\n // Tool failures are the view's problem to render, not the dev server's\n // to crash on, so they come back as a normal result.\n const result = await callTool(name, args).catch((error: unknown) => ({\n isError: true,\n content: [{ type: \"text\", text: error instanceof Error ? error.message : String(error) }],\n }));\n return send(200, \"application/json\", JSON.stringify(result));\n }\n if (path === \"/\") return send(200, \"text/html; charset=utf-8\", hostPage());\n if (path === \"/host.js\") return send(200, \"text/javascript; charset=utf-8\", hostRuntime);\n if (path === \"/version\") return send(200, \"application/json\", String(version));\n if (path === \"/view.html\")\n return send(200, \"text/plain; charset=utf-8\", await readFile(htmlPath, \"utf8\"));\n if (path === \"/view.meta.json\")\n return send(200, \"application/json\", await readFile(metaPath, \"utf8\"));\n send(404, \"text/plain\", \"not found\");\n } catch (error) {\n // A rebuild in flight can briefly leave the file missing; say so rather\n // than crashing the dev server.\n send(500, \"text/plain\", error instanceof Error ? error.message : String(error));\n }\n });\n let hostPort: number;\n try {\n hostPort = await listenOnFreePort(hostServer, options.hostPort ?? 5179);\n } catch (caught) {\n await new Promise<void>((done) => sandboxServer.close(() => done()));\n throw caught;\n }\n hostOrigin = `http://localhost:${hostPort}`;\n\n function hostPage(): string {\n return devHostHtml({\n toolName,\n sandboxOrigin,\n fixtures,\n toolInput,\n uri: initialMeta.uri,\n hasServer: callTool !== undefined,\n });\n }\n\n return {\n hostUrl: hostOrigin,\n sandboxUrl: sandboxOrigin,\n reload() {\n version += 1;\n },\n async close() {\n await Promise.all([\n new Promise<void>((done) => hostServer.close(() => done())),\n new Promise<void>((done) => sandboxServer.close(() => done())),\n ]);\n },\n };\n}\n\ninterface HostPageOptions {\n toolName: string;\n sandboxOrigin: string;\n fixtures: Record<string, unknown>;\n toolInput: Record<string, unknown>;\n uri: string;\n hasServer: boolean;\n}\n\nfunction devHostHtml(options: HostPageOptions): string {\n const { toolName, sandboxOrigin, fixtures, toolInput, uri, hasServer } = options;\n const buttons = Object.keys(fixtures)\n .map(\n (name, index) =>\n `<button class=\"chip\" type=\"button\" data-fixture=\"${escapeHtml(name)}\"${index === 0 ? ' data-active=\"true\"' : \"\"}>${escapeHtml(name)}</button>`,\n )\n .join(\"\\n\");\n const firstFixture = Object.keys(fixtures)[0] ?? \"sample\";\n\n return `<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n<title>${escapeHtml(toolName)} · Mountly MCP</title>\n<style>\n :root {\n color-scheme: light;\n --bg: #f5f5f5;\n --bg-chat: #efefef;\n --fg: #171717;\n --muted: #737373;\n --accent: #0f766e;\n --accent-soft: #ccfbf1;\n --border: #e5e5e5;\n --surface: #ffffff;\n --user-bg: #171717;\n --user-fg: #fafafa;\n --assistant-fg: #171717;\n --composer: #ffffff;\n --shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 8px 24px rgb(0 0 0 / 6%);\n }\n :root[data-theme=\"dark\"] {\n color-scheme: dark;\n --bg: #0a0a0a;\n --bg-chat: #111111;\n --fg: #f5f5f5;\n --muted: #a3a3a3;\n --accent: #2dd4bf;\n --accent-soft: #134e4a;\n --border: #262626;\n --surface: #171717;\n --user-bg: #e5e5e5;\n --user-fg: #0a0a0a;\n --assistant-fg: #f5f5f5;\n --composer: #171717;\n --shadow: 0 1px 2px rgb(0 0 0 / 35%), 0 12px 32px rgb(0 0 0 / 35%);\n }\n * { box-sizing: border-box; }\n html, body { height: 100%; }\n body {\n margin: 0;\n background: var(--bg);\n color: var(--fg);\n font: 15px/1.5 \"Segoe UI\", \"Helvetica Neue\", system-ui, sans-serif;\n }\n .app {\n display: grid;\n grid-template-rows: auto 1fr auto;\n min-height: 100%;\n max-width: 880px;\n margin: 0 auto;\n }\n .topbar {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 12px 18px;\n border-bottom: 1px solid var(--border);\n background: color-mix(in srgb, var(--surface) 92%, transparent);\n backdrop-filter: blur(10px);\n position: sticky;\n top: 0;\n z-index: 3;\n }\n .model {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n min-width: 0;\n }\n .avatar {\n width: 28px;\n height: 28px;\n border-radius: 8px;\n background:\n linear-gradient(135deg, var(--accent-soft), transparent 60%),\n var(--surface);\n border: 1px solid var(--border);\n flex: 0 0 auto;\n }\n .model h1 {\n margin: 0;\n font-size: 14px;\n font-weight: 600;\n letter-spacing: -0.01em;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .model .sub {\n color: var(--muted);\n font-size: 12px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .spacer { flex: 1; }\n .icon-btn {\n appearance: none;\n border: 1px solid var(--border);\n background: var(--surface);\n color: var(--fg);\n width: 34px;\n height: 34px;\n border-radius: 10px;\n font: inherit;\n cursor: pointer;\n }\n .icon-btn:hover { border-color: var(--accent); color: var(--accent); }\n .chat {\n background:\n radial-gradient(900px 420px at 50% -8%, var(--accent-soft), transparent 55%),\n var(--bg-chat);\n padding: 28px 18px 18px;\n display: flex;\n flex-direction: column;\n gap: 22px;\n overflow: auto;\n }\n .turn {\n display: grid;\n grid-template-columns: 32px 1fr;\n gap: 12px;\n align-items: start;\n max-width: 720px;\n width: 100%;\n }\n .turn.user {\n margin-left: auto;\n grid-template-columns: 1fr 32px;\n }\n .turn.user .who { order: 2; }\n .turn.user .body { order: 1; text-align: right; }\n .who {\n width: 32px;\n height: 32px;\n border-radius: 999px;\n display: grid;\n place-items: center;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.04em;\n border: 1px solid var(--border);\n background: var(--surface);\n color: var(--muted);\n }\n .turn.user .who {\n background: var(--user-bg);\n color: var(--user-fg);\n border-color: transparent;\n }\n .bubble {\n display: inline-block;\n text-align: left;\n background: var(--surface);\n border: 1px solid var(--border);\n border-radius: 18px;\n padding: 12px 14px;\n box-shadow: var(--shadow);\n color: var(--assistant-fg);\n }\n .turn.user .bubble {\n background: var(--user-bg);\n color: var(--user-fg);\n border-color: transparent;\n }\n .bubble p { margin: 0; }\n .artifact {\n margin-top: 10px;\n border: 1px solid var(--border);\n border-radius: 16px;\n overflow: hidden;\n background: var(--surface);\n box-shadow: var(--shadow);\n text-align: left;\n }\n .artifact-bar {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 10px 12px;\n border-bottom: 1px solid var(--border);\n background: color-mix(in srgb, var(--bg-chat) 55%, var(--surface));\n color: var(--muted);\n font-size: 12px;\n }\n .artifact-bar .dot {\n width: 7px;\n height: 7px;\n border-radius: 50%;\n background: var(--accent);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);\n }\n iframe {\n display: block;\n width: 100%;\n height: 420px;\n border: 0;\n background: #fff;\n }\n .composer {\n border-top: 1px solid var(--border);\n background: color-mix(in srgb, var(--composer) 94%, transparent);\n backdrop-filter: blur(10px);\n padding: 12px 18px 16px;\n position: sticky;\n bottom: 0;\n }\n .composer-box {\n border: 1px solid var(--border);\n background: var(--surface);\n border-radius: 18px;\n padding: 10px 12px 12px;\n box-shadow: var(--shadow);\n }\n .composer-hint {\n color: var(--muted);\n font-size: 13px;\n margin: 0 0 10px;\n }\n .samples {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n align-items: center;\n }\n .samples .label {\n color: var(--muted);\n font-size: 12px;\n margin-right: 2px;\n }\n #fixtures { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }\n .chip {\n appearance: none;\n border: 1px solid var(--border);\n background: color-mix(in srgb, var(--bg-chat) 40%, var(--surface));\n color: var(--fg);\n padding: 7px 12px;\n border-radius: 999px;\n font: inherit;\n font-size: 13px;\n cursor: pointer;\n }\n .chip:hover { border-color: var(--accent); color: var(--accent); }\n .chip[data-active=\"true\"] {\n background: var(--accent);\n color: #fff;\n border-color: var(--accent);\n }\n :root[data-theme=\"dark\"] .chip[data-active=\"true\"] { color: #042f2e; }\n details.debug {\n margin-top: 10px;\n border: 1px dashed var(--border);\n border-radius: 14px;\n background: transparent;\n overflow: hidden;\n }\n details.debug > summary {\n cursor: pointer;\n list-style: none;\n padding: 10px 12px;\n font-size: 11px;\n font-weight: 600;\n letter-spacing: 0.08em;\n text-transform: uppercase;\n color: var(--muted);\n }\n details.debug > summary::-webkit-details-marker { display: none; }\n .debug-body {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 0;\n border-top: 1px solid var(--border);\n }\n .panel { padding: 12px; min-width: 0; }\n .panel + .panel { border-left: 1px solid var(--border); }\n .panel h2 {\n margin: 0 0 8px;\n font-size: 11px;\n text-transform: uppercase;\n letter-spacing: 0.08em;\n color: var(--muted);\n }\n pre {\n margin: 0;\n padding: 10px;\n border-radius: 8px;\n background: color-mix(in srgb, var(--bg-chat) 80%, transparent);\n font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace;\n overflow: auto;\n max-height: 180px;\n }\n .log {\n font: 11px/1.5 ui-monospace, Menlo, Consolas, monospace;\n color: var(--muted);\n white-space: pre-wrap;\n max-height: 180px;\n overflow: auto;\n }\n @media (max-width: 720px) {\n .debug-body { grid-template-columns: 1fr; }\n .panel + .panel { border-left: 0; border-top: 1px solid var(--border); }\n .turn, .turn.user { grid-template-columns: 28px 1fr; }\n .turn.user .who { order: 0; }\n .turn.user .body { order: 0; text-align: left; }\n }\n</style>\n</head>\n<body>\n<div class=\"app\">\n <header class=\"topbar\">\n <div class=\"model\">\n <div class=\"avatar\" aria-hidden=\"true\"></div>\n <div>\n <h1>Mountly · ${escapeHtml(toolName)}</h1>\n <div class=\"sub\">${escapeHtml(uri)}</div>\n </div>\n </div>\n <span class=\"spacer\"></span>\n <button class=\"icon-btn\" id=\"theme\" type=\"button\" title=\"Toggle theme\" aria-label=\"Toggle theme\">◐</button>\n <button class=\"icon-btn\" id=\"teardown\" type=\"button\" title=\"Teardown\" aria-label=\"Teardown\">×</button>\n </header>\n\n <main class=\"chat\">\n <div class=\"turn user\">\n <div class=\"who\" aria-hidden=\"true\">You</div>\n <div class=\"body\">\n <div class=\"bubble\">\n <p>Call <strong>${escapeHtml(toolName)}</strong> with sample “${escapeHtml(firstFixture)}”.</p>\n </div>\n </div>\n </div>\n\n <div class=\"turn assistant\">\n <div class=\"who\" aria-hidden=\"true\">AI</div>\n <div class=\"body\">\n <div class=\"bubble\">\n <p>Here’s the interactive result from that tool.</p>\n <div class=\"artifact\">\n <div class=\"artifact-bar\"><span class=\"dot\" aria-hidden=\"true\"></span> MCP App · inline</div>\n <iframe id=\"sandbox\" sandbox=\"allow-scripts allow-same-origin\" title=\"mountly-mcp sandbox proxy\"></iframe>\n </div>\n </div>\n </div>\n </div>\n </main>\n\n <footer class=\"composer\">\n <div class=\"composer-box\">\n <p class=\"composer-hint\">Ask another sample — same as switching fixtures in a real host.</p>\n <div class=\"samples\">\n <span class=\"label\">Samples</span>\n <div id=\"fixtures\">${buttons || '<span class=\"label\">No fixtures — add mcp.fixtures.json</span>'}</div>\n </div>\n <details class=\"debug\">\n <summary>Protocol debug</summary>\n <div class=\"debug-body\">\n <section class=\"panel\">\n <h2>Last structuredContent</h2>\n <pre id=\"payload\">(none yet)</pre>\n </section>\n <section class=\"panel\">\n <h2>Channel log</h2>\n <div class=\"log\" id=\"log\"></div>\n </section>\n </div>\n </details>\n </div>\n </footer>\n</div>\n<script>\nglobalThis.__mountlyMcpDevHost__ = ${serializeInlineScriptValue({\n toolName,\n sandboxOrigin,\n fixtures,\n toolInput,\n uri,\n hasServer,\n sandboxPath: \"/sandbox-proxy.html\",\n })};\nconst HAS_SERVER = ${hasServer ? \"true\" : \"false\"};\n</script>\n<script src=\"/host.js\"></script>\n</body>\n</html>\n`;\n}\n/**\n * The proxy document: a shell around the compiled sandbox runtime.\n *\n * Kept separate from {@link sandboxProxyHtml} so the dev server can load the\n * runtime once at startup and still stamp in the host origin per request,\n * which it only learns after binding a port.\n */\nfunction sandboxProxyShell(hostOrigin: string, runtime: string): string {\n return `<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>mountly-mcp sandbox proxy</title>\n<style>\n html, body { margin: 0; padding: 0; width: 100%; height: 100%; background: transparent; }\n #inner { width: 100%; height: 100%; border: 0; background: white; }\n</style>\n</head>\n<body>\n<script>globalThis.__mountlyMcpSandbox__ = ${serializeInlineScriptValue({ hostOrigin })};</script>\n<script>${escapeInlineScript(runtime)}</script>\n</body>\n</html>\n`;\n}\n\n/**\n * The MCP Apps sandbox proxy document (spec §8.4), ready to serve from an\n * origin distinct from the host page.\n *\n * Exported because this is the security boundary — it builds the CSP from the\n * sidecar and decides what the view may execute and reach. Anything standing\n * up a host, including the example harnesses in this repo, should serve this\n * rather than keep a copy that drifts from it.\n */\nexport async function sandboxProxyHtml(hostOrigin: string): Promise<string> {\n return sandboxProxyShell(hostOrigin, await loadRuntime(\"sandbox-entry\"));\n}\n\nexport { connectMcpServer, type ConnectedMcpServer } from \"./connect-server.js\";\n"],"mappings":";;;;;;AAeA,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,oBAAiC;AAC1C,SAAS,qBAAqB;AAuC9B,SAAS,WAAW,OAAuB;AACzC,SAAO,MAAM;AAAA,IACX;AAAA,IACA,CAAC,eACE,EAAE,KAAK,SAAS,KAAK,QAAQ,KAAK,QAAQ,KAAK,UAAU,KAAK,QAAQ,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AAC,CAAC;AAAA,qBACiB,YAAY,SAAS,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAMjD;AAQA,SAAS,kBAAkB,YAAoB,SAAyB;AACtE,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6CAWoC,2BAA2B,EAAE,WAAW,CAAC,CAAC;AAAA,UAC7E,mBAAmB,OAAO,CAAC;AAAA;AAAA;AAAA;AAIrC;AAWA,eAAsB,iBAAiB,YAAqC;AAC1E,SAAO,kBAAkB,YAAY,MAAM,YAAY,eAAe,CAAC;AACzE;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dev/connect-server.ts"],"sourcesContent":["import type { McpUiToolMeta } from \"@modelcontextprotocol/ext-apps\";\n\nexport interface ConnectedMcpServer {\n callTool: (name: string, args: unknown) => Promise<unknown>;\n /** The model-visible tool bound to `uri` — the one a host would call. */\n toolFor(uri: string): Promise<string | undefined>;\n close(): Promise<void>;\n}\n\n/**\n * Connect a server module in-process for a development session.\n *\n * The module default-exports either the server or a function returning it: a\n * `RunningMcpAppServer` from `createMcpAppServer`, or a raw `McpServer`.\n */\nexport async function connectMcpServer(path: string): Promise<ConnectedMcpServer> {\n const { pathToFileURL } = await import(\"node:url\");\n const { resolve } = await import(\"node:path\");\n const mod = (await import(pathToFileURL(resolve(path)).href)) as { default?: unknown };\n if (mod.default === undefined) {\n throw new Error(\n `mountly-mcp: ${path} has no default export. Export your server (or a function returning it) as default.`,\n );\n }\n const value = typeof mod.default === \"function\" ? await mod.default() : mod.default;\n\n let client: import(\"@modelcontextprotocol/sdk/client/index.js\").Client;\n if (\n value !== null &&\n typeof value === \"object\" &&\n \"connectInProcess\" in value &&\n typeof value.connectInProcess === \"function\"\n ) {\n const running = value as { connectInProcess(): Promise<{ client: typeof client }> };\n ({ client } = await running.connectInProcess());\n } else if (\n value !== null &&\n typeof value === \"object\" &&\n \"connect\" in value &&\n typeof value.connect === \"function\"\n ) {\n const [{ Client }, { InMemoryTransport }, { EXTENSION_ID, RESOURCE_MIME_TYPE }] =\n await Promise.all([\n import(\"@modelcontextprotocol/sdk/client/index.js\"),\n import(\"@modelcontextprotocol/sdk/inMemory.js\"),\n import(\"@modelcontextprotocol/ext-apps/server\"),\n ]);\n const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();\n await (value as { connect(transport: unknown): Promise<void> }).connect(serverTransport);\n client = new Client({ name: \"mountly-mcp-dev\", version: \"0.0.1\" }, {\n capabilities: { extensions: { [EXTENSION_ID]: { mimeTypes: [RESOURCE_MIME_TYPE] } } },\n } as never);\n await client.connect(clientTransport);\n } else {\n throw new TypeError(\n `mountly-mcp: ${path} must default-export an MCP server, RunningMcpAppServer, or a function returning one`,\n );\n }\n\n return {\n callTool: (name, args) =>\n client.callTool({ name, arguments: (args ?? {}) as Record<string, unknown> }),\n async toolFor(uri) {\n const { tools } = await client.listTools();\n const uiMeta = (tool: { _meta?: unknown }): McpUiToolMeta | undefined =>\n (tool._meta as { ui?: McpUiToolMeta } | undefined)?.ui;\n const bound = tools.filter((tool) => uiMeta(tool)?.resourceUri === uri);\n const visible = bound.find((tool) => {\n const visibility = uiMeta(tool)?.visibility;\n return visibility === undefined || visibility.includes(\"model\");\n });\n return (visible ?? bound[0])?.name;\n },\n close: () => client.close(),\n };\n}\n"],"mappings":";AAeA,eAAsB,iBAAiB,MAA2C;AAChF,QAAM,EAAE,cAAc,IAAI,MAAM,OAAO,KAAU;AACjD,QAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,MAAW;AAC5C,QAAM,MAAO,MAAM,OAAO,cAAc,QAAQ,IAAI,CAAC,EAAE;AACvD,MAAI,IAAI,YAAY,QAAW;AAC7B,UAAM,IAAI;AAAA,MACR,gBAAgB,IAAI;AAAA,IACtB;AAAA,EACF;AACA,QAAM,QAAQ,OAAO,IAAI,YAAY,aAAa,MAAM,IAAI,QAAQ,IAAI,IAAI;AAE5E,MAAI;A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