mountly-mcp 3.1.0 → 4.0.1
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/README.md +59 -29
- package/dist/bridge/iframe-entry.js +24 -16
- package/dist/bridge/index.d.ts +5 -5
- package/dist/bridge/index.js +2 -2
- package/dist/build/index.d.ts +3 -3
- package/dist/build/index.js +2 -2
- package/dist/{chunk-NLQDVNZP.js → chunk-AEVQKFXX.js} +12 -8
- package/dist/chunk-AEVQKFXX.js.map +1 -0
- package/dist/{chunk-SNWNF2XI.js → chunk-JVQZGKBL.js} +13 -13
- package/dist/chunk-JVQZGKBL.js.map +1 -0
- package/dist/chunk-KWVGW5Q7.js +582 -0
- package/dist/chunk-KWVGW5Q7.js.map +1 -0
- package/dist/{chunk-DQLQOMDM.js → chunk-M4WFJR3C.js} +2 -2
- package/dist/{chunk-DQLQOMDM.js.map → chunk-M4WFJR3C.js.map} +1 -1
- package/dist/{chunk-4WAKOYMK.js → chunk-MTJDRWGD.js} +2 -2
- package/dist/chunk-MTJDRWGD.js.map +1 -0
- package/dist/chunk-SADNMGP6.js +16 -0
- package/dist/chunk-SADNMGP6.js.map +1 -0
- package/dist/cli.js +21 -10
- package/dist/cli.js.map +1 -1
- package/dist/create.d.ts +10 -0
- package/dist/create.js +113 -0
- package/dist/create.js.map +1 -0
- package/dist/dev/host-entry.js +2 -2
- package/dist/dev/index.d.ts +1 -1
- package/dist/dev/index.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10 -2
- package/dist/json-render/{widget.d.ts → generative-view.d.ts} +9 -11
- package/dist/json-render/index.d.ts +1 -1
- package/dist/json-render/index.js +9 -8
- package/dist/json-render/index.js.map +1 -1
- package/dist/publish.d.ts +10 -0
- package/dist/react/context.d.ts +1 -1
- package/dist/react/create-view.d.ts +8 -0
- package/dist/react/hooks.d.ts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +6 -5
- package/dist/schema.d.ts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/svelte/index.d.ts +10 -16
- package/dist/svelte/index.js +7 -3
- package/dist/svelte/index.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/types.d.ts +14 -4
- package/dist/vite/index.d.ts +6 -6
- package/dist/vite/index.js +7 -7
- package/dist/vite/index.js.map +1 -1
- package/dist/vue/index.d.ts +12 -17
- package/dist/vue/index.js +10 -6
- package/dist/vue/index.js.map +1 -1
- package/package.json +11 -15
- package/templates/react/.gitignore.tmpl +4 -0
- package/templates/react/README.md.tmpl +15 -0
- package/templates/react/mcp.fixtures.json.tmpl +4 -0
- package/templates/react/package.json.tmpl +27 -0
- package/templates/react/server.mjs.tmpl +70 -0
- package/templates/react/src/view.tsx.tmpl +160 -0
- package/templates/react/tsconfig.json.tmpl +15 -0
- package/templates/react/vite.config.ts.tmpl +22 -0
- package/templates/svelte/.gitignore.tmpl +4 -0
- package/templates/svelte/README.md.tmpl +14 -0
- package/templates/svelte/mcp.fixtures.json.tmpl +4 -0
- package/templates/svelte/package.json.tmpl +26 -0
- package/templates/svelte/server.mjs.tmpl +70 -0
- package/templates/svelte/src/Dashboard.svelte.tmpl +158 -0
- package/templates/svelte/src/view.ts.tmpl +14 -0
- package/templates/svelte/tsconfig.json.tmpl +14 -0
- package/templates/svelte/vite.config.ts.tmpl +22 -0
- package/templates/vanilla/.gitignore.tmpl +4 -0
- package/templates/vanilla/README.md.tmpl +20 -0
- package/templates/vanilla/mcp.fixtures.json.tmpl +4 -0
- package/templates/vanilla/package.json.tmpl +22 -0
- package/templates/vanilla/server.mjs.tmpl +70 -0
- package/templates/vanilla/src/view.ts.tmpl +177 -0
- package/templates/vanilla/tsconfig.json.tmpl +14 -0
- package/templates/vanilla/vite.config.ts.tmpl +20 -0
- package/templates/vue/.gitignore.tmpl +4 -0
- package/templates/vue/README.md.tmpl +14 -0
- package/templates/vue/mcp.fixtures.json.tmpl +4 -0
- package/templates/vue/package.json.tmpl +26 -0
- package/templates/vue/server.mjs.tmpl +70 -0
- package/templates/vue/src/Dashboard.vue.tmpl +159 -0
- package/templates/vue/src/view.ts.tmpl +14 -0
- package/templates/vue/tsconfig.json.tmpl +15 -0
- package/templates/vue/vite.config.ts.tmpl +22 -0
- package/dist/chunk-4WAKOYMK.js.map +0 -1
- package/dist/chunk-KRAS266U.js +0 -260
- package/dist/chunk-KRAS266U.js.map +0 -1
- package/dist/chunk-NLQDVNZP.js.map +0 -1
- package/dist/chunk-SNWNF2XI.js.map +0 -1
- package/dist/react/create-widget.d.ts +0 -11
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"dev": "mountly-mcp dev --server ./server.mjs",
|
|
9
|
+
"verify": "mountly-mcp verify",
|
|
10
|
+
"verify:strict": "mountly-mcp verify --strict",
|
|
11
|
+
"typecheck": "vue-tsc --noEmit"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
15
|
+
"mountly-mcp": "^{{mcpVersion}}",
|
|
16
|
+
"mountly-vue": "^2.0.3",
|
|
17
|
+
"vue": "^3.5.41",
|
|
18
|
+
"zod": "^4.4.3"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@vitejs/plugin-vue": "^6.0.8",
|
|
22
|
+
"typescript": "^5.9.0",
|
|
23
|
+
"vite": "^8.2.1",
|
|
24
|
+
"vue-tsc": "^2.2.0"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { readMcpAppManifest } from "mountly-mcp/artifact";
|
|
3
|
+
import { registerMcpApps } from "mountly-mcp/server";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
const URI = "{{uri}}";
|
|
7
|
+
|
|
8
|
+
function sampleCards() {
|
|
9
|
+
return [
|
|
10
|
+
{ label: "Requests", value: Math.floor(1200 + Math.random() * 200) },
|
|
11
|
+
{ label: "Latency", value: `${Math.floor(30 + Math.random() * 20)} ms` },
|
|
12
|
+
{ label: "Uptime", value: "99.9%" },
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Default export for `mountly-mcp dev --server ./server.mjs`. */
|
|
17
|
+
export default async function createServer() {
|
|
18
|
+
const server = new McpServer(
|
|
19
|
+
{ name: "{{slug}}", version: "0.0.1" },
|
|
20
|
+
{ capabilities: { tools: {}, resources: {} } },
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const { artifacts } = await readMcpAppManifest("dist/mountly-mcp.manifest.json");
|
|
24
|
+
|
|
25
|
+
await registerMcpApps(server, {
|
|
26
|
+
views: artifacts.map((artifact) => ({ artifact })),
|
|
27
|
+
tools: [
|
|
28
|
+
{
|
|
29
|
+
name: "showDashboard",
|
|
30
|
+
resourceUri: URI,
|
|
31
|
+
config: {
|
|
32
|
+
description: "Show an interactive metrics dashboard",
|
|
33
|
+
inputSchema: {
|
|
34
|
+
topic: z.string().describe("Dashboard topic"),
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
handler: async ({ topic }) => ({
|
|
38
|
+
structuredContent: {
|
|
39
|
+
topic,
|
|
40
|
+
cards: [
|
|
41
|
+
{ label: "Requests", value: 1284 },
|
|
42
|
+
{ label: "Latency", value: "42 ms" },
|
|
43
|
+
{ label: "Uptime", value: "99.9%" },
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "refreshDashboard",
|
|
50
|
+
resourceUri: URI,
|
|
51
|
+
visibility: ["app"],
|
|
52
|
+
config: {
|
|
53
|
+
description: "Refresh dashboard metrics (app-only)",
|
|
54
|
+
inputSchema: {
|
|
55
|
+
reason: z.string().optional(),
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
handler: async ({ reason }) => ({
|
|
59
|
+
structuredContent: {
|
|
60
|
+
refreshedAt: new Date().toISOString(),
|
|
61
|
+
cards: sampleCards(),
|
|
62
|
+
reason: reason ?? null,
|
|
63
|
+
},
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return server;
|
|
70
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, watch } from "vue";
|
|
3
|
+
import { useMcpApp, useToolResult } from "mountly-mcp/vue";
|
|
4
|
+
|
|
5
|
+
interface DashboardCard {
|
|
6
|
+
label: string;
|
|
7
|
+
value: string | number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface DashboardData {
|
|
11
|
+
topic?: string;
|
|
12
|
+
refreshedAt?: string;
|
|
13
|
+
cards?: DashboardCard[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface DashboardResult {
|
|
17
|
+
structuredContent?: DashboardData;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const mcp = useMcpApp();
|
|
21
|
+
const result = useToolResult<DashboardResult>();
|
|
22
|
+
const data = ref<DashboardData | undefined>();
|
|
23
|
+
const busy = ref(false);
|
|
24
|
+
const status = ref("Connected.");
|
|
25
|
+
|
|
26
|
+
watch(
|
|
27
|
+
result,
|
|
28
|
+
(value) => {
|
|
29
|
+
if (value?.structuredContent) data.value = value.structuredContent;
|
|
30
|
+
},
|
|
31
|
+
{ immediate: true },
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const cards = computed(() => data.value?.cards ?? []);
|
|
35
|
+
const title = computed(() =>
|
|
36
|
+
data.value?.topic ? `${data.value.topic} Dashboard` : "Dashboard",
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
async function refresh() {
|
|
40
|
+
busy.value = true;
|
|
41
|
+
status.value = "Refreshing…";
|
|
42
|
+
try {
|
|
43
|
+
const next = (await mcp.callServerTool({
|
|
44
|
+
name: "refreshDashboard",
|
|
45
|
+
arguments: { reason: "User clicked refresh" },
|
|
46
|
+
})) as DashboardResult;
|
|
47
|
+
const content = next.structuredContent;
|
|
48
|
+
if (content) {
|
|
49
|
+
data.value = {
|
|
50
|
+
...data.value,
|
|
51
|
+
...content,
|
|
52
|
+
topic: content.topic ?? data.value?.topic,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
status.value = content?.refreshedAt
|
|
56
|
+
? `Refreshed ${new Date(content.refreshedAt).toLocaleTimeString()}`
|
|
57
|
+
: "Refreshed.";
|
|
58
|
+
} catch (error) {
|
|
59
|
+
status.value = error instanceof Error ? error.message : "Refresh failed.";
|
|
60
|
+
} finally {
|
|
61
|
+
busy.value = false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<div class="card">
|
|
68
|
+
<p class="eyebrow">MCP App · Mountly</p>
|
|
69
|
+
<h1>{{ title }}</h1>
|
|
70
|
+
<p class="subtitle">
|
|
71
|
+
Built with <code>mountly-mcp</code> — try Refresh to call an app-only tool.
|
|
72
|
+
</p>
|
|
73
|
+
<div class="grid">
|
|
74
|
+
<div v-if="cards.length === 0" v-for="i in 3" :key="i" class="metric">
|
|
75
|
+
<div class="label">—</div>
|
|
76
|
+
<div class="value">—</div>
|
|
77
|
+
</div>
|
|
78
|
+
<div v-for="c in cards" :key="c.label" class="metric">
|
|
79
|
+
<div class="label">{{ c.label }}</div>
|
|
80
|
+
<div class="value">{{ c.value }}</div>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
<div class="row">
|
|
84
|
+
<button type="button" :disabled="busy" @click="refresh">Refresh data</button>
|
|
85
|
+
<span class="status">{{ status }}</span>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
</template>
|
|
89
|
+
|
|
90
|
+
<style scoped>
|
|
91
|
+
.card {
|
|
92
|
+
border: 1px solid var(--color-border-primary, #e5e5e5);
|
|
93
|
+
border-radius: 12px;
|
|
94
|
+
padding: 20px;
|
|
95
|
+
background: var(--color-background-secondary, #fafafa);
|
|
96
|
+
}
|
|
97
|
+
.eyebrow {
|
|
98
|
+
margin: 0 0 8px;
|
|
99
|
+
color: var(--color-text-secondary, #737373);
|
|
100
|
+
font-size: 11px;
|
|
101
|
+
text-transform: uppercase;
|
|
102
|
+
letter-spacing: 0.1em;
|
|
103
|
+
}
|
|
104
|
+
h1 {
|
|
105
|
+
margin: 0 0 4px;
|
|
106
|
+
font-size: 20px;
|
|
107
|
+
font-weight: 600;
|
|
108
|
+
}
|
|
109
|
+
.subtitle {
|
|
110
|
+
color: var(--color-text-secondary, #737373);
|
|
111
|
+
font-size: 14px;
|
|
112
|
+
margin: 0 0 16px;
|
|
113
|
+
}
|
|
114
|
+
.grid {
|
|
115
|
+
display: grid;
|
|
116
|
+
grid-template-columns: repeat(3, 1fr);
|
|
117
|
+
gap: 10px;
|
|
118
|
+
margin-bottom: 16px;
|
|
119
|
+
}
|
|
120
|
+
.metric {
|
|
121
|
+
border: 1px solid var(--color-border-primary, #e5e5e5);
|
|
122
|
+
border-radius: 8px;
|
|
123
|
+
padding: 12px;
|
|
124
|
+
background: var(--color-background-primary, #ffffff);
|
|
125
|
+
}
|
|
126
|
+
.label {
|
|
127
|
+
color: var(--color-text-secondary, #737373);
|
|
128
|
+
font-size: 11px;
|
|
129
|
+
text-transform: uppercase;
|
|
130
|
+
letter-spacing: 0.05em;
|
|
131
|
+
}
|
|
132
|
+
.value {
|
|
133
|
+
margin-top: 4px;
|
|
134
|
+
font-size: 22px;
|
|
135
|
+
font-weight: 600;
|
|
136
|
+
}
|
|
137
|
+
.row {
|
|
138
|
+
display: flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
gap: 10px;
|
|
141
|
+
}
|
|
142
|
+
button {
|
|
143
|
+
border: 1px solid var(--color-border-primary, #e5e5e5);
|
|
144
|
+
border-radius: 8px;
|
|
145
|
+
padding: 8px 14px;
|
|
146
|
+
background: var(--color-background-primary, #ffffff);
|
|
147
|
+
color: inherit;
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
font-size: 13px;
|
|
150
|
+
}
|
|
151
|
+
button:disabled {
|
|
152
|
+
opacity: 0.6;
|
|
153
|
+
cursor: wait;
|
|
154
|
+
}
|
|
155
|
+
.status {
|
|
156
|
+
font-size: 12px;
|
|
157
|
+
color: var(--color-text-secondary, #737373);
|
|
158
|
+
}
|
|
159
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createMcpView } from "mountly-mcp/vue";
|
|
2
|
+
import Dashboard from "./Dashboard.vue";
|
|
3
|
+
|
|
4
|
+
const styles = `
|
|
5
|
+
:root {
|
|
6
|
+
color-scheme: light dark;
|
|
7
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
8
|
+
background: var(--color-background-primary, #ffffff);
|
|
9
|
+
color: var(--color-text-primary, #171717);
|
|
10
|
+
}
|
|
11
|
+
body { margin: 0; padding: 20px; }
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
createMcpView(Dashboard, { shadow: true, styles });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"noEmit": true,
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"jsx": "preserve"
|
|
13
|
+
},
|
|
14
|
+
"include": ["src/**/*.ts", "src/**/*.vue"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import vue from "@vitejs/plugin-vue";
|
|
3
|
+
import { mountlyMcpViews } from "mountly-mcp/vite";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [
|
|
7
|
+
vue(),
|
|
8
|
+
mountlyMcpViews({
|
|
9
|
+
apps: [
|
|
10
|
+
{
|
|
11
|
+
entry: "src/view.ts",
|
|
12
|
+
uri: "{{uri}}",
|
|
13
|
+
name: "dashboard",
|
|
14
|
+
description: "Interactive metrics dashboard",
|
|
15
|
+
displayModes: ["inline", "fullscreen"],
|
|
16
|
+
prefersBorder: true,
|
|
17
|
+
awaitToolResult: true,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
}),
|
|
21
|
+
],
|
|
22
|
+
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/build/index.ts","../src/build/emit-html.ts","../src/build/emit-meta.ts"],"sourcesContent":["import { readFile, writeFile } from \"node:fs/promises\";\nimport { fileURLToPath } from \"node:url\";\nimport { resolve } from \"node:path\";\nimport type {\n McpUiDisplayMode,\n McpUiResourceCsp,\n McpUiResourcePermissions,\n} from \"@modelcontextprotocol/ext-apps\";\nimport type { McpResourceDeclaration } from \"../types.js\";\nimport type { McpAppArtifact } from \"../artifact/index.js\";\nimport { emitHtml } from \"./emit-html.js\";\nimport { emitMeta } from \"./emit-meta.js\";\n\n/**\n * Absolute path to the iframe bridge runtime shipped with this package.\n *\n * `buildMcpResource` inlines this file's contents into the emitted HTML so\n * the widget can speak the MCP Apps postMessage protocol. Use this when you\n * need to point another build tool at the runtime, or when you want a\n * stable, version-pinned alternative to passing `bridgeRuntimePath` yourself.\n *\n * Resolves relative to the installed package, so it works identically in\n * monorepos and in projects that installed mountly-mcp from npm.\n */\nexport function getBridgeRuntimePath(): string {\n // Ask the module resolver rather than walking up from __dirname: the subpath\n // is a declared export, so this holds wherever a bundler puts this file.\n return fileURLToPath(import.meta.resolve(\"mountly-mcp/bridge/iframe-entry.js\"));\n}\n\nfunction defaultBridgeRuntimePath(): string {\n return getBridgeRuntimePath();\n}\n\nexport interface BuildSelfContainedOptions {\n entry: string;\n uri: string;\n name: string;\n output: string;\n description?: string;\n awaitToolResult?: boolean;\n displayModes?: ReadonlyArray<McpUiDisplayMode>;\n /**\n * Render progressive states from `ui/notifications/tool-input-partial`.\n * Off by default — see `RunBridgeOptions.streamToolInput`.\n */\n streamToolInput?: boolean;\n csp?: McpUiResourceCsp;\n /** Sandbox permissions requested by the view (camera/microphone/geolocation/clipboardWrite). */\n permissions?: McpUiResourcePermissions;\n /** Dedicated sandbox origin (host-dependent format). */\n domain?: string;\n /** Whether the view requests the host to show a visible border + background. */\n prefersBorder?: boolean;\n cssEntry?: string;\n bridgeRuntimePath?: string;\n}\n\nexport interface BuildCdnOptions extends BuildSelfContainedOptions {\n cdn: { jsUrl: string; cssUrl: string };\n}\n\nexport type BuildOptions = BuildSelfContainedOptions | BuildCdnOptions;\n\nexport interface BuildResult {\n htmlPath: string;\n metaPath: string;\n declaration: McpResourceDeclaration;\n artifact: McpAppArtifact;\n}\n\nexport interface BuildFromSourceOptions extends Omit<\n BuildSelfContainedOptions,\n \"entry\" | \"cssEntry\"\n> {\n /** The bundled widget JS. */\n js: string;\n /** The widget's CSS, if it has any. */\n css?: string;\n}\n\n/**\n * Same as {@link buildMcpResource}, but taking the bundle in memory instead of\n * from disk — for bundler plugins that already hold the emitted sources and\n * shouldn't have to guess when they land on the filesystem.\n */\nexport async function buildMcpResourceFromSource(\n options: BuildFromSourceOptions,\n): Promise<BuildResult> {\n const { js, css, ...rest } = options;\n return writeResource({ ...rest, mode: \"self-contained\", js, css: css ?? \"\" });\n}\n\nexport async function buildMcpResource(options: BuildOptions): Promise<BuildResult> {\n if (!(\"cdn\" in options)) {\n const js = await readFile(options.entry, \"utf8\");\n const css = options.cssEntry ? await readFile(options.cssEntry, \"utf8\") : \"\";\n return writeResource({ ...options, mode: \"self-contained\", js, css });\n }\n return writeResource({ ...options, mode: \"cdn\" });\n}\n\ntype ResourceMeta = Omit<BuildSelfContainedOptions, \"entry\" | \"cssEntry\">;\n\ntype WriteResourceOptions =\n | (ResourceMeta & { mode: \"self-contained\"; js: string; css: string })\n | (ResourceMeta & { mode: \"cdn\"; cdn: BuildCdnOptions[\"cdn\"] });\n\nasync function writeResource(options: WriteResourceOptions): Promise<BuildResult> {\n const bridgeRuntimeJs = await readFile(\n options.bridgeRuntimePath ?? defaultBridgeRuntimePath(),\n \"utf8\",\n );\n\n const declaration = emitMeta({\n uri: options.uri,\n name: options.name,\n description: options.description,\n awaitToolResult: options.awaitToolResult,\n displayModes: options.displayModes,\n csp: options.mode === \"cdn\" ? mergeCdnIntoCsp(options.csp, options.cdn) : options.csp,\n permissions: options.permissions,\n domain: options.domain,\n prefersBorder: options.prefersBorder,\n });\n\n // Same values the sidecar declares, so the view's `ui/initialize` matches it.\n const config = {\n awaitToolResult: declaration.awaitToolResult,\n displayModes: declaration.displayModes,\n streamToolInput: options.streamToolInput ?? false,\n };\n\n const html =\n options.mode === \"cdn\"\n ? emitHtml({\n mode: \"cdn\",\n uri: options.uri,\n jsUrl: options.cdn.jsUrl,\n cssUrl: options.cdn.cssUrl,\n bridgeRuntimeJs,\n config,\n })\n : emitHtml({\n mode: \"self-contained\",\n uri: options.uri,\n js: options.js,\n css: options.css,\n bridgeRuntimeJs,\n config,\n });\n\n const metaPath = `${options.output}.meta.json`;\n await writeFile(options.output, html, \"utf8\");\n await writeFile(metaPath, JSON.stringify(declaration, null, 2), \"utf8\");\n\n const htmlPath = resolve(options.output);\n return {\n htmlPath,\n metaPath: resolve(metaPath),\n declaration,\n artifact: {\n name: declaration.name,\n uri: declaration.uri,\n htmlPath,\n metaPath: resolve(metaPath),\n declaration,\n },\n };\n}\n\nfunction mergeCdnIntoCsp(\n csp: McpUiResourceCsp | undefined,\n cdn: { jsUrl: string; cssUrl: string },\n): McpUiResourceCsp {\n const jsOrigin = new URL(cdn.jsUrl).origin;\n const cssOrigin = new URL(cdn.cssUrl).origin;\n const merged: McpUiResourceCsp = { ...(csp ?? {}) };\n const existing = new Set(merged.resourceDomains ?? []);\n existing.add(jsOrigin);\n existing.add(cssOrigin);\n merged.resourceDomains = Array.from(existing);\n return merged;\n}\n\nexport { emitHtml } from \"./emit-html.js\";\nexport { emitMeta } from \"./emit-meta.js\";\n","import { MCP_APPS_PROTOCOL_VERSION } from \"../schema.js\";\nimport type { McpUiDisplayMode } from \"@modelcontextprotocol/ext-apps\";\nimport { escapeInlineScript, serializeInlineScriptValue } from \"../html.js\";\n\n/**\n * Runtime config the emitted HTML hands to the inlined bridge\n * (`bridge/iframe-entry.ts` reads these off `globalThis`). Without it the view\n * falls back to `awaitToolResult: true` / `availableDisplayModes: [\"inline\"]`,\n * regardless of what the build declared in the sidecar.\n */\nexport interface EmitHtmlConfig {\n awaitToolResult?: boolean;\n displayModes?: ReadonlyArray<McpUiDisplayMode>;\n streamToolInput?: boolean;\n}\n\nexport interface EmitHtmlSelfContainedInput {\n mode: \"self-contained\";\n uri: string;\n js: string;\n css: string;\n bridgeRuntimeJs: string;\n config?: EmitHtmlConfig;\n}\n\nexport interface EmitHtmlCdnInput {\n mode: \"cdn\";\n uri: string;\n jsUrl: string;\n cssUrl: string;\n bridgeRuntimeJs: string;\n config?: EmitHtmlConfig;\n}\n\nexport type EmitHtmlInput = EmitHtmlSelfContainedInput | EmitHtmlCdnInput;\n\nfunction escapeAttr(value: string): string {\n return value\n .replace(/&/g, \"&\")\n .replace(/\"/g, \""\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\");\n}\n\nfunction escapeStyle(value: string): string {\n return value.replace(/<\\/style/gi, \"<\\\\/style\");\n}\n\n/**\n * Classic (non-module) script so it runs at parse time — before the deferred\n * module scripts that boot the bridge.\n */\nfunction configScript(config: EmitHtmlConfig | undefined): string[] {\n if (!config) return [];\n const assignments: string[] = [];\n if (config.awaitToolResult !== undefined) {\n assignments.push(\n `globalThis.__mountlyMcpAwaitToolResult__=${serializeInlineScriptValue(config.awaitToolResult)};`,\n );\n }\n if (config.displayModes !== undefined) {\n assignments.push(\n `globalThis.__mountlyMcpAvailableDisplayModes__=${serializeInlineScriptValue(config.displayModes)};`,\n );\n }\n if (config.streamToolInput !== undefined) {\n assignments.push(\n `globalThis.__mountlyMcpStreamToolInput__=${serializeInlineScriptValue(config.streamToolInput)};`,\n );\n }\n if (assignments.length === 0) return [];\n return [`<script>${assignments.join(\"\")}</script>`];\n}\n\nexport function emitHtml(input: EmitHtmlInput): string {\n const head = [\n `<meta charset=\"utf-8\">`,\n `<meta name=\"mountly-mcp-protocol\" content=\"${MCP_APPS_PROTOCOL_VERSION}\">`,\n `<meta name=\"mountly-mcp-uri\" content=\"${escapeAttr(input.uri)}\">`,\n ];\n\n if (input.mode === \"self-contained\") {\n head.push(`<style>${escapeStyle(input.css)}</style>`);\n const body = [\n `<div id=\"mountly-mcp-root\"></div>`,\n ...configScript(input.config),\n `<script type=\"module\">${escapeInlineScript(input.js)}\\n${escapeInlineScript(input.bridgeRuntimeJs)}</script>`,\n ];\n return template(head, body);\n }\n\n head.push(`<link rel=\"stylesheet\" href=\"${escapeAttr(input.cssUrl)}\">`);\n // The widget bundle MUST load before the bridge: module scripts execute in\n // document order, and the bridge reads `__mountlyMcpWidget__` synchronously.\n const body = [\n `<div id=\"mountly-mcp-root\"></div>`,\n ...configScript(input.config),\n `<script type=\"module\" src=\"${escapeAttr(input.jsUrl)}\"></script>`,\n `<script type=\"module\">${escapeInlineScript(input.bridgeRuntimeJs)}</script>`,\n ];\n return template(head, body);\n}\n\nfunction template(head: string[], body: string[]): string {\n return `<!doctype html>\n<html data-mountly-mcp>\n<head>\n${head.join(\"\\n\")}\n</head>\n<body>\n${body.join(\"\\n\")}\n</body>\n</html>`;\n}\n","import { MCP_APPS_MIME, MCP_APPS_PROTOCOL_VERSION } from \"../schema.js\";\nimport type {\n McpUiDisplayMode,\n McpUiResourceCsp,\n McpUiResourcePermissions,\n} from \"@modelcontextprotocol/ext-apps\";\nimport type { McpResourceDeclaration } from \"../types.js\";\n\nexport interface EmitMetaInput {\n uri: string;\n name: string;\n description?: string;\n awaitToolResult?: boolean;\n displayModes?: ReadonlyArray<McpUiDisplayMode>;\n csp?: McpUiResourceCsp;\n /** Sandbox permissions requested by the view (camera/microphone/geolocation/clipboardWrite). */\n permissions?: McpUiResourcePermissions;\n /** Dedicated sandbox origin requested by the view (host-dependent format). */\n domain?: string;\n /** Whether the view requests the host to show a visible border + background. */\n prefersBorder?: boolean;\n}\n\nfunction assertUiUri(uri: string): void {\n if (!uri.startsWith(\"ui://\")) {\n throw new Error(`mountly-mcp: UI resource uri must use the 'ui://' scheme (received '${uri}')`);\n }\n}\n\nexport function emitMeta(input: EmitMetaInput): McpResourceDeclaration {\n assertUiUri(input.uri);\n\n const ui: McpResourceDeclaration[\"_meta\"][\"ui\"] = {};\n if (input.csp) ui.csp = input.csp;\n if (input.permissions) ui.permissions = input.permissions;\n if (input.domain !== undefined) ui.domain = input.domain;\n if (input.prefersBorder !== undefined) ui.prefersBorder = input.prefersBorder;\n\n const decl: McpResourceDeclaration = {\n protocolVersion: MCP_APPS_PROTOCOL_VERSION,\n uri: input.uri,\n name: input.name,\n mimeType: MCP_APPS_MIME,\n awaitToolResult: input.awaitToolResult ?? true,\n displayModes: input.displayModes ?? [\"inline\"],\n _meta: { ui },\n };\n if (input.description !== undefined) decl.description = input.description;\n return decl;\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,UAAU,iBAAiB;AACpC,SAAS,qBAAqB;AAC9B,SAAS,eAAe;;;ACkCxB,SAAS,WAAW,OAAuB;AACzC,SAAO,MACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAA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,QAAM,UAAU,QAAQ,QAAQ,MAAM,MAAM;AAC5C,QAAM,UAAU,UAAU,KAAK,UAAU,aAAa,MAAM,CAAC,GAAG,MAAM;AAEtE,QAAM,WAAW,QAAQ,QAAQ,MAAM;AACvC,SAAO;AAAA,IACL;AAAA,IACA,UAAU,QAAQ,QAAQ;AAAA,IAC1B;AAAA,IACA,UAAU;AAAA,MACR,MAAM,YAAY;AAAA,MAClB,KAAK,YAAY;AAAA,MACjB;AAAA,MACA,UAAU,QAAQ,QAAQ;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,gBACP,KACA,KACkB;AAClB,QAAM,WAAW,IAAI,IAAI,IAAI,KAAK,EAAE;AACpC,QAAM,YAAY,IAAI,IAAI,IAAI,MAAM,EAAE;AACtC,QAAM,SAA2B,EAAE,GAAI,OAAO,CAAC,EAAG;AAClD,QAAM,WAAW,IAAI,IAAI,OAAO,mBAAmB,CAAC,CAAC;AACrD,WAAS,IAAI,QAAQ;AACrB,WAAS,IAAI,SAAS;AACtB,SAAO,kBAAkB,MAAM,KAAK,QAAQ;AAC5C,SAAO;AACT;","names":["body"]}
|
package/dist/chunk-KRAS266U.js
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
escapeInlineScript,
|
|
3
|
-
serializeInlineScriptValue
|
|
4
|
-
} from "./chunk-YJA4H6IB.js";
|
|
5
|
-
|
|
6
|
-
// src/dev/index.ts
|
|
7
|
-
import { existsSync } from "fs";
|
|
8
|
-
import { readFile } from "fs/promises";
|
|
9
|
-
import { createServer } from "http";
|
|
10
|
-
import { fileURLToPath } from "url";
|
|
11
|
-
function escapeHtml(value) {
|
|
12
|
-
return value.replace(
|
|
13
|
-
/[&<>"']/g,
|
|
14
|
-
(character) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[character]
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
var runtimeCache = /* @__PURE__ */ new Map();
|
|
18
|
-
function loadRuntime(name) {
|
|
19
|
-
const cached = runtimeCache.get(name);
|
|
20
|
-
if (cached) return cached;
|
|
21
|
-
const loading = (async () => {
|
|
22
|
-
try {
|
|
23
|
-
return await readFile(
|
|
24
|
-
fileURLToPath(import.meta.resolve(`mountly-mcp/dev/${name}.js`)),
|
|
25
|
-
"utf8"
|
|
26
|
-
);
|
|
27
|
-
} catch {
|
|
28
|
-
}
|
|
29
|
-
const entry = fileURLToPath(new URL(`./${name}.ts`, import.meta.url));
|
|
30
|
-
if (!existsSync(entry)) {
|
|
31
|
-
throw new Error(
|
|
32
|
-
`mountly-mcp dev: ${name} runtime missing. Expected the packaged 'mountly-mcp/dev/${name}.js' export, or ${entry} when running from source.`
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
const { build } = await import("vite");
|
|
36
|
-
const result = await build({
|
|
37
|
-
configFile: false,
|
|
38
|
-
logLevel: "silent",
|
|
39
|
-
build: {
|
|
40
|
-
write: false,
|
|
41
|
-
target: "es2022",
|
|
42
|
-
minify: false,
|
|
43
|
-
lib: { entry, formats: ["iife"], name: "__mountlyMcpDevRuntime" }
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
const outputs = Array.isArray(result) ? result : [result];
|
|
47
|
-
const chunk = outputs.flatMap((output) => "output" in output ? output.output : []).find((item) => item.type === "chunk");
|
|
48
|
-
if (!chunk || chunk.type !== "chunk")
|
|
49
|
-
throw new Error(`mountly-mcp dev: failed to bundle ${name}`);
|
|
50
|
-
return chunk.code;
|
|
51
|
-
})();
|
|
52
|
-
runtimeCache.set(name, loading);
|
|
53
|
-
return loading;
|
|
54
|
-
}
|
|
55
|
-
function listenOnFreePort(server, port) {
|
|
56
|
-
return new Promise((resolvePort, reject) => {
|
|
57
|
-
const attempt = (candidate) => {
|
|
58
|
-
const onError = (error) => {
|
|
59
|
-
server.removeListener("listening", onListening);
|
|
60
|
-
if (error.code === "EADDRINUSE" && candidate < port + 50) attempt(candidate + 1);
|
|
61
|
-
else reject(error);
|
|
62
|
-
};
|
|
63
|
-
const onListening = () => {
|
|
64
|
-
server.removeListener("error", onError);
|
|
65
|
-
const address = server.address();
|
|
66
|
-
resolvePort(typeof address === "object" && address !== null ? address.port : candidate);
|
|
67
|
-
};
|
|
68
|
-
server.once("error", onError);
|
|
69
|
-
server.once("listening", onListening);
|
|
70
|
-
server.listen(candidate);
|
|
71
|
-
};
|
|
72
|
-
attempt(port);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
async function startDevHost(options) {
|
|
76
|
-
const { htmlPath, fixtures = {}, toolInput = {}, callTool } = options;
|
|
77
|
-
const metaPath = `${htmlPath}.meta.json`;
|
|
78
|
-
const initialMeta = JSON.parse(await readFile(metaPath, "utf8"));
|
|
79
|
-
const toolName = options.toolName ?? initialMeta.name;
|
|
80
|
-
const [hostRuntime, sandboxRuntime] = await Promise.all([
|
|
81
|
-
loadRuntime("host-entry"),
|
|
82
|
-
loadRuntime("sandbox-entry")
|
|
83
|
-
]);
|
|
84
|
-
let version = 1;
|
|
85
|
-
let hostOrigin = "";
|
|
86
|
-
const sandboxServer = createServer((_req, res) => {
|
|
87
|
-
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" });
|
|
88
|
-
res.end(sandboxProxyShell(hostOrigin, sandboxRuntime));
|
|
89
|
-
});
|
|
90
|
-
const sandboxPort = await listenOnFreePort(
|
|
91
|
-
sandboxServer,
|
|
92
|
-
options.sandboxPort ?? (options.hostPort ?? 5179) + 1
|
|
93
|
-
);
|
|
94
|
-
const sandboxOrigin = `http://localhost:${sandboxPort}`;
|
|
95
|
-
const hostServer = createServer(async (req, res) => {
|
|
96
|
-
const path = new URL(req.url ?? "/", "http://localhost").pathname;
|
|
97
|
-
const send = (status, type, body) => {
|
|
98
|
-
res.writeHead(status, { "Content-Type": type, "Cache-Control": "no-store" });
|
|
99
|
-
res.end(body);
|
|
100
|
-
};
|
|
101
|
-
try {
|
|
102
|
-
if (path === "/call" && req.method === "POST") {
|
|
103
|
-
if (!callTool) return send(400, "text/plain", "no server connected");
|
|
104
|
-
const body = await new Promise((done, fail) => {
|
|
105
|
-
let raw = "";
|
|
106
|
-
req.on("data", (chunk) => raw += chunk);
|
|
107
|
-
req.on("end", () => done(raw));
|
|
108
|
-
req.on("error", fail);
|
|
109
|
-
});
|
|
110
|
-
const { name, arguments: args } = JSON.parse(body);
|
|
111
|
-
const result = await callTool(name, args).catch((error) => ({
|
|
112
|
-
isError: true,
|
|
113
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }]
|
|
114
|
-
}));
|
|
115
|
-
return send(200, "application/json", JSON.stringify(result));
|
|
116
|
-
}
|
|
117
|
-
if (path === "/") return send(200, "text/html; charset=utf-8", hostPage());
|
|
118
|
-
if (path === "/host.js") return send(200, "text/javascript; charset=utf-8", hostRuntime);
|
|
119
|
-
if (path === "/version") return send(200, "application/json", String(version));
|
|
120
|
-
if (path === "/widget.html")
|
|
121
|
-
return send(200, "text/plain; charset=utf-8", await readFile(htmlPath, "utf8"));
|
|
122
|
-
if (path === "/widget.meta.json")
|
|
123
|
-
return send(200, "application/json", await readFile(metaPath, "utf8"));
|
|
124
|
-
send(404, "text/plain", "not found");
|
|
125
|
-
} catch (error) {
|
|
126
|
-
send(500, "text/plain", error instanceof Error ? error.message : String(error));
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
let hostPort;
|
|
130
|
-
try {
|
|
131
|
-
hostPort = await listenOnFreePort(hostServer, options.hostPort ?? 5179);
|
|
132
|
-
} catch (caught) {
|
|
133
|
-
await new Promise((done) => sandboxServer.close(() => done()));
|
|
134
|
-
throw caught;
|
|
135
|
-
}
|
|
136
|
-
hostOrigin = `http://localhost:${hostPort}`;
|
|
137
|
-
function hostPage() {
|
|
138
|
-
return devHostHtml({
|
|
139
|
-
toolName,
|
|
140
|
-
sandboxOrigin,
|
|
141
|
-
fixtures,
|
|
142
|
-
toolInput,
|
|
143
|
-
uri: initialMeta.uri,
|
|
144
|
-
hasServer: callTool !== void 0
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
hostUrl: hostOrigin,
|
|
149
|
-
sandboxUrl: sandboxOrigin,
|
|
150
|
-
reload() {
|
|
151
|
-
version += 1;
|
|
152
|
-
},
|
|
153
|
-
async close() {
|
|
154
|
-
await Promise.all([
|
|
155
|
-
new Promise((done) => hostServer.close(() => done())),
|
|
156
|
-
new Promise((done) => sandboxServer.close(() => done()))
|
|
157
|
-
]);
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
function devHostHtml(options) {
|
|
162
|
-
const { toolName, sandboxOrigin, fixtures, toolInput, uri, hasServer } = options;
|
|
163
|
-
const buttons = Object.keys(fixtures).map(
|
|
164
|
-
(name, index) => `<button class="btn" data-fixture="${escapeHtml(name)}"${index === 0 ? ' data-active="true"' : ""}>${escapeHtml(name)}</button>`
|
|
165
|
-
).join("\n");
|
|
166
|
-
return `<!doctype html>
|
|
167
|
-
<html lang="en">
|
|
168
|
-
<head>
|
|
169
|
-
<meta charset="utf-8">
|
|
170
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
171
|
-
<title>mountly-mcp dev \xB7 ${escapeHtml(toolName)}</title>
|
|
172
|
-
<style>
|
|
173
|
-
:root { color-scheme:light; --bg:#f6f7f9; --fg:#0b0c0f; --muted:#5c6675; --accent:#1d4ed8; --border:#dcdfe5; }
|
|
174
|
-
:root[data-theme="dark"] { color-scheme:dark; --bg:#0b0c0f; --fg:#e6e9ef; --muted:#9aa3b2; --accent:#7aa2ff; --border:#252a33; }
|
|
175
|
-
* { box-sizing:border-box; }
|
|
176
|
-
body { margin:0; min-height:100vh; background:var(--bg); color:var(--fg); font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif; }
|
|
177
|
-
header { padding:18px 24px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
|
|
178
|
-
header h1 { margin:0; font-size:16px; font-weight:600; }
|
|
179
|
-
header code { color:var(--muted); font-size:12px; }
|
|
180
|
-
#fixtures { display:flex; gap:8px; flex-wrap:wrap; }
|
|
181
|
-
.spacer { flex:1; }
|
|
182
|
-
.btn { appearance:none; border:1px solid var(--border); background:transparent; color:var(--fg); padding:6px 12px; border-radius:6px; font:inherit; cursor:pointer; }
|
|
183
|
-
.btn:hover { border-color:var(--accent); color:var(--accent); }
|
|
184
|
-
.btn[data-active="true"] { background:var(--accent); color:white; border-color:var(--accent); }
|
|
185
|
-
main { display:grid; grid-template-columns:minmax(420px,1fr) 360px; gap:20px; padding:24px; align-items:start; }
|
|
186
|
-
iframe { width:100%; height:460px; border:1px solid var(--border); border-radius:12px; background:white; }
|
|
187
|
-
.panel { border:1px solid var(--border); border-radius:12px; padding:16px; }
|
|
188
|
-
.panel + .panel { margin-top:12px; }
|
|
189
|
-
.panel h2 { margin:0 0 8px; font-size:13px; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); }
|
|
190
|
-
pre { margin:0; padding:10px; border-radius:8px; font:12px/1.45 ui-monospace,Menlo,Consolas,monospace; overflow:auto; max-height:200px; }
|
|
191
|
-
.log { font:11px/1.5 ui-monospace,Menlo,Consolas,monospace; color:var(--muted); white-space:pre-wrap; max-height:280px; overflow:auto; }
|
|
192
|
-
@media (max-width:880px) { main { grid-template-columns:1fr; padding:16px; } }
|
|
193
|
-
</style>
|
|
194
|
-
</head>
|
|
195
|
-
<body>
|
|
196
|
-
<header>
|
|
197
|
-
<h1>${escapeHtml(toolName)}</h1>
|
|
198
|
-
<code>${escapeHtml(uri)}</code>
|
|
199
|
-
<span class="spacer"></span>
|
|
200
|
-
<div id="fixtures">${buttons}</div>
|
|
201
|
-
<button class="btn" id="theme" type="button">Theme</button>
|
|
202
|
-
<button class="btn" id="teardown" type="button">Teardown</button>
|
|
203
|
-
</header>
|
|
204
|
-
<main>
|
|
205
|
-
<iframe id="sandbox" sandbox="allow-scripts allow-same-origin" title="mountly-mcp sandbox proxy"></iframe>
|
|
206
|
-
<div>
|
|
207
|
-
<section class="panel">
|
|
208
|
-
<h2>Last structuredContent</h2>
|
|
209
|
-
<pre id="payload">(none yet)</pre>
|
|
210
|
-
</section>
|
|
211
|
-
<section class="panel">
|
|
212
|
-
<h2>Channel log</h2>
|
|
213
|
-
<div class="log" id="log"></div>
|
|
214
|
-
</section>
|
|
215
|
-
</div>
|
|
216
|
-
</main>
|
|
217
|
-
<script>
|
|
218
|
-
globalThis.__mountlyMcpDevHost__ = ${serializeInlineScriptValue({
|
|
219
|
-
toolName,
|
|
220
|
-
sandboxOrigin,
|
|
221
|
-
fixtures,
|
|
222
|
-
toolInput,
|
|
223
|
-
uri,
|
|
224
|
-
hasServer,
|
|
225
|
-
sandboxPath: "/sandbox-proxy.html"
|
|
226
|
-
})};
|
|
227
|
-
const HAS_SERVER = ${hasServer ? "true" : "false"};
|
|
228
|
-
</script>
|
|
229
|
-
<script src="/host.js"></script>
|
|
230
|
-
</body>
|
|
231
|
-
</html>
|
|
232
|
-
`;
|
|
233
|
-
}
|
|
234
|
-
function sandboxProxyShell(hostOrigin, runtime) {
|
|
235
|
-
return `<!doctype html>
|
|
236
|
-
<html lang="en">
|
|
237
|
-
<head>
|
|
238
|
-
<meta charset="utf-8">
|
|
239
|
-
<title>mountly-mcp sandbox proxy</title>
|
|
240
|
-
<style>
|
|
241
|
-
html, body { margin: 0; padding: 0; width: 100%; height: 100%; background: transparent; }
|
|
242
|
-
#inner { width: 100%; height: 100%; border: 0; background: white; }
|
|
243
|
-
</style>
|
|
244
|
-
</head>
|
|
245
|
-
<body>
|
|
246
|
-
<script>globalThis.__mountlyMcpSandbox__ = ${serializeInlineScriptValue({ hostOrigin })};</script>
|
|
247
|
-
<script>${escapeInlineScript(runtime)}</script>
|
|
248
|
-
</body>
|
|
249
|
-
</html>
|
|
250
|
-
`;
|
|
251
|
-
}
|
|
252
|
-
async function sandboxProxyHtml(hostOrigin) {
|
|
253
|
-
return sandboxProxyShell(hostOrigin, await loadRuntime("sandbox-entry"));
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export {
|
|
257
|
-
startDevHost,
|
|
258
|
-
sandboxProxyHtml
|
|
259
|
-
};
|
|
260
|
-
//# sourceMappingURL=chunk-KRAS266U.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dev/index.ts"],"sourcesContent":["/**\n * A local MCP Apps host, so a widget 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 widget\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/widget.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 widget 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 // widget 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 === \"/widget.html\")\n return send(200, \"text/plain; charset=utf-8\", await readFile(htmlPath, \"utf8\"));\n if (path === \"/widget.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=\"btn\" data-fixture=\"${escapeHtml(name)}\"${index === 0 ? ' data-active=\"true\"' : \"\"}>${escapeHtml(name)}</button>`,\n )\n .join(\"\\n\");\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>mountly-mcp dev · ${escapeHtml(toolName)}</title>\n<style>\n :root { color-scheme:light; --bg:#f6f7f9; --fg:#0b0c0f; --muted:#5c6675; --accent:#1d4ed8; --border:#dcdfe5; }\n :root[data-theme=\"dark\"] { color-scheme:dark; --bg:#0b0c0f; --fg:#e6e9ef; --muted:#9aa3b2; --accent:#7aa2ff; --border:#252a33; }\n * { box-sizing:border-box; }\n body { margin:0; min-height:100vh; background:var(--bg); color:var(--fg); font:14px/1.5 -apple-system,BlinkMacSystemFont,\"Segoe UI\",system-ui,sans-serif; }\n header { padding:18px 24px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:12px; flex-wrap:wrap; }\n header h1 { margin:0; font-size:16px; font-weight:600; }\n header code { color:var(--muted); font-size:12px; }\n #fixtures { display:flex; gap:8px; flex-wrap:wrap; }\n .spacer { flex:1; }\n .btn { appearance:none; border:1px solid var(--border); background:transparent; color:var(--fg); padding:6px 12px; border-radius:6px; font:inherit; cursor:pointer; }\n .btn:hover { border-color:var(--accent); color:var(--accent); }\n .btn[data-active=\"true\"] { background:var(--accent); color:white; border-color:var(--accent); }\n main { display:grid; grid-template-columns:minmax(420px,1fr) 360px; gap:20px; padding:24px; align-items:start; }\n iframe { width:100%; height:460px; border:1px solid var(--border); border-radius:12px; background:white; }\n .panel { border:1px solid var(--border); border-radius:12px; padding:16px; }\n .panel + .panel { margin-top:12px; }\n .panel h2 { margin:0 0 8px; font-size:13px; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); }\n pre { margin:0; padding:10px; border-radius:8px; font:12px/1.45 ui-monospace,Menlo,Consolas,monospace; overflow:auto; max-height:200px; }\n .log { font:11px/1.5 ui-monospace,Menlo,Consolas,monospace; color:var(--muted); white-space:pre-wrap; max-height:280px; overflow:auto; }\n @media (max-width:880px) { main { grid-template-columns:1fr; padding:16px; } }\n</style>\n</head>\n<body>\n<header>\n <h1>${escapeHtml(toolName)}</h1>\n <code>${escapeHtml(uri)}</code>\n <span class=\"spacer\"></span>\n <div id=\"fixtures\">${buttons}</div>\n <button class=\"btn\" id=\"theme\" type=\"button\">Theme</button>\n <button class=\"btn\" id=\"teardown\" type=\"button\">Teardown</button>\n</header>\n<main>\n <iframe id=\"sandbox\" sandbox=\"allow-scripts allow-same-origin\" title=\"mountly-mcp sandbox proxy\"></iframe>\n <div>\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</main>\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,GAAG,SAAS;AAAA,EACvF;AACF;AAEA,IAAM,eAAe,oBAAI,IAA6B;AAWtD,SAAS,YAAY,MAAuD;AAC1E,QAAM,SAAS,aAAa,IAAI,IAAI;AACpC,MAAI,OAAQ,QAAO;AACnB,QAAM,WAAW,YAAY;AAC3B,QAAI;AACF,aAAO,MAAM;AAAA,QACX,cAAc,YAAY,QAAQ,mBAAmB,IAAI,KAAK,CAAC;AAAA,QAC/D;AAAA,MACF;AAAA,IACF,QAAQ;AAAA,IAER;AACA,UAAM,QAAQ,cAAc,IAAI,IAAI,KAAK,IAAI,OAAO,YAAY,GAAG,CAAC;AACpE,QAA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