@maxhealth.tech/prefab 0.3.5 → 0.3.6
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/CHANGELOG.md +39 -0
- package/dist/actions/mcp.js.map +1 -1
- package/dist/app.d.ts +2 -11
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +5 -11
- package/dist/app.js.map +1 -1
- package/dist/auto/comparison.d.ts.map +1 -1
- package/dist/auto/comparison.js +3 -3
- package/dist/auto/comparison.js.map +1 -1
- package/dist/auto/form.d.ts +2 -2
- package/dist/auto/form.js +2 -2
- package/dist/auto/index.d.ts.map +1 -1
- package/dist/auto/index.js +2 -1
- package/dist/auto/index.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/stringify.d.ts +23 -0
- package/dist/core/stringify.d.ts.map +1 -0
- package/dist/core/stringify.js +48 -0
- package/dist/core/stringify.js.map +1 -0
- package/dist/core/version.d.ts +24 -0
- package/dist/core/version.d.ts.map +1 -0
- package/dist/core/version.js +24 -0
- package/dist/core/version.js.map +1 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/display.d.ts +7 -160
- package/dist/mcp/display.d.ts.map +1 -1
- package/dist/mcp/display.js +9 -170
- package/dist/mcp/display.js.map +1 -1
- package/dist/mcp/index.d.ts +9 -3
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +4 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/resource.d.ts +250 -0
- package/dist/mcp/resource.d.ts.map +1 -0
- package/dist/mcp/resource.js +282 -0
- package/dist/mcp/resource.js.map +1 -0
- package/dist/mcp/result.d.ts +42 -0
- package/dist/mcp/result.d.ts.map +1 -0
- package/dist/mcp/result.js +45 -0
- package/dist/mcp/result.js.map +1 -0
- package/dist/mcp/theme-bridge.d.ts +59 -0
- package/dist/mcp/theme-bridge.d.ts.map +1 -0
- package/dist/mcp/theme-bridge.js +106 -0
- package/dist/mcp/theme-bridge.js.map +1 -0
- package/dist/mcp/types.d.ts +49 -5
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/prefab.css +21 -7
- package/dist/renderer/actions.d.ts.map +1 -1
- package/dist/renderer/actions.js +3 -2
- package/dist/renderer/actions.js.map +1 -1
- package/dist/renderer/app.js.map +1 -1
- package/dist/renderer/bridge.d.ts.map +1 -1
- package/dist/renderer/bridge.js +2 -1
- package/dist/renderer/bridge.js.map +1 -1
- package/dist/renderer/components/chart-helpers.d.ts.map +1 -1
- package/dist/renderer/components/chart-helpers.js +3 -2
- package/dist/renderer/components/chart-helpers.js.map +1 -1
- package/dist/renderer/components/chart-tooltip.d.ts.map +1 -1
- package/dist/renderer/components/chart-tooltip.js +3 -2
- package/dist/renderer/components/chart-tooltip.js.map +1 -1
- package/dist/renderer/components/charts.d.ts.map +1 -1
- package/dist/renderer/components/charts.js +4 -3
- package/dist/renderer/components/charts.js.map +1 -1
- package/dist/renderer/components/data.d.ts.map +1 -1
- package/dist/renderer/components/data.js +3 -2
- package/dist/renderer/components/data.js.map +1 -1
- package/dist/renderer/components/form.d.ts.map +1 -1
- package/dist/renderer/components/form.js +12 -11
- package/dist/renderer/components/form.js.map +1 -1
- package/dist/renderer/components/media.js +7 -1
- package/dist/renderer/components/media.js.map +1 -1
- package/dist/renderer/engine.d.ts.map +1 -1
- package/dist/renderer/engine.js +3 -2
- package/dist/renderer/engine.js.map +1 -1
- package/dist/renderer/index.js +34 -8
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/rx.d.ts.map +1 -1
- package/dist/renderer/rx.js +4 -3
- package/dist/renderer/rx.js.map +1 -1
- package/dist/renderer.auto.min.js +10 -10
- package/dist/renderer.min.js +10 -10
- package/dist/rx/collection.d.ts.map +1 -1
- package/dist/rx/collection.js +3 -2
- package/dist/rx/collection.js.map +1 -1
- package/dist/rx/rx.js.map +1 -1
- package/package.json +10 -9
package/dist/mcp/display.d.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { type Component } from '../core/component.js';
|
|
20
20
|
import { PrefabApp } from '../app.js';
|
|
21
|
-
import type { Theme, LayoutHints, ColorMode } from '../app.js';
|
|
21
|
+
import type { Theme, LayoutHints, ColorMode, PrefabWireFormat } from '../app.js';
|
|
22
22
|
import type { Action, ActionJSON } from '../actions/types.js';
|
|
23
23
|
import type { PipeFn } from '../rx/pipes.js';
|
|
24
24
|
import type { McpToolResult } from './types.js';
|
|
@@ -56,20 +56,20 @@ export interface DisplayOptions {
|
|
|
56
56
|
*
|
|
57
57
|
* @returns MCP tool result with the prefab wire format JSON as text content.
|
|
58
58
|
*/
|
|
59
|
-
export declare function display(viewOrApp: Component | PrefabApp, options?: DisplayOptions): McpToolResult
|
|
59
|
+
export declare function display(viewOrApp: Component | PrefabApp, options?: DisplayOptions): McpToolResult<PrefabWireFormat>;
|
|
60
60
|
import type { AutoFormField, AutoFormOptions } from '../auto/form.js';
|
|
61
61
|
export interface DisplayFormOptions extends AutoFormOptions, DisplayOptions {
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Return a form UI as an MCP tool result.
|
|
65
65
|
*
|
|
66
|
-
*
|
|
66
|
+
* Submitting the form calls the specified MCP tool (via CallTool).
|
|
67
67
|
* Field definitions map to Input components; the submit action
|
|
68
68
|
* invokes `submitTool` with all field values.
|
|
69
69
|
*
|
|
70
70
|
* @returns MCP tool result with form prefab UI.
|
|
71
71
|
*/
|
|
72
|
-
export declare function display_form(fields: AutoFormField[], submitTool: string, options?: DisplayFormOptions): McpToolResult
|
|
72
|
+
export declare function display_form(fields: AutoFormField[], submitTool: string, options?: DisplayFormOptions): McpToolResult<PrefabWireFormat>;
|
|
73
73
|
export interface StateUpdate {
|
|
74
74
|
/** State key-value pairs to merge into the existing UI state. */
|
|
75
75
|
state: Record<string, unknown>;
|
|
@@ -95,7 +95,7 @@ export interface DisplayUpdateOptions {
|
|
|
95
95
|
*
|
|
96
96
|
* @returns MCP tool result with a $prefab update payload.
|
|
97
97
|
*/
|
|
98
|
-
export declare function display_update(state: Record<string, unknown>, options?: DisplayUpdateOptions): McpToolResult
|
|
98
|
+
export declare function display_update(state: Record<string, unknown>, options?: DisplayUpdateOptions): McpToolResult<PrefabUpdateWire>;
|
|
99
99
|
export interface DisplayErrorOptions {
|
|
100
100
|
/** Error detail / stack trace to show in a code block. */
|
|
101
101
|
detail?: string;
|
|
@@ -112,7 +112,7 @@ export interface DisplayErrorOptions {
|
|
|
112
112
|
*
|
|
113
113
|
* @returns MCP tool result with error UI and isError flag.
|
|
114
114
|
*/
|
|
115
|
-
export declare function display_error(title: string, message: string, options?: DisplayErrorOptions): McpToolResult
|
|
115
|
+
export declare function display_error(title: string, message: string, options?: DisplayErrorOptions): McpToolResult<PrefabWireFormat>;
|
|
116
116
|
export interface DisplaySuccessOptions {
|
|
117
117
|
/** Additional detail text below the message. */
|
|
118
118
|
detail?: string;
|
|
@@ -126,162 +126,9 @@ export interface DisplaySuccessOptions {
|
|
|
126
126
|
*
|
|
127
127
|
* @returns MCP tool result with success UI.
|
|
128
128
|
*/
|
|
129
|
-
export declare function display_success(title: string, message: string, options?: DisplaySuccessOptions): McpToolResult
|
|
129
|
+
export declare function display_success(title: string, message: string, options?: DisplaySuccessOptions): McpToolResult<PrefabWireFormat>;
|
|
130
130
|
export declare const displayForm: typeof display_form;
|
|
131
131
|
export declare const displayUpdate: typeof display_update;
|
|
132
132
|
export declare const displayError: typeof display_error;
|
|
133
133
|
export declare const displaySuccess: typeof display_success;
|
|
134
|
-
/** CSP configuration for MCP Apps resources. */
|
|
135
|
-
export interface McpAppCsp {
|
|
136
|
-
/** Origins allowed for scripts, styles, images, fonts, media. */
|
|
137
|
-
resourceDomains?: string[];
|
|
138
|
-
/** Origins allowed for fetch/XHR/WebSocket. */
|
|
139
|
-
connectDomains?: string[];
|
|
140
|
-
/** Origins allowed for nested iframes. */
|
|
141
|
-
frameDomains?: string[];
|
|
142
|
-
/** Additional allowed base URIs. */
|
|
143
|
-
baseUriDomains?: string[];
|
|
144
|
-
}
|
|
145
|
-
/** Permission Policy requests for MCP Apps resources. */
|
|
146
|
-
export interface McpAppPermissions {
|
|
147
|
-
/** Request camera access (video capture, QR scanning). */
|
|
148
|
-
camera?: boolean;
|
|
149
|
-
/** Request microphone access (audio recording, voice input). */
|
|
150
|
-
microphone?: boolean;
|
|
151
|
-
/** Request geolocation access (location-aware apps, maps). */
|
|
152
|
-
geolocation?: boolean;
|
|
153
|
-
/** Request clipboard write access (copy-to-clipboard). */
|
|
154
|
-
clipboardWrite?: boolean;
|
|
155
|
-
}
|
|
156
|
-
export interface ResourceMetaOptions {
|
|
157
|
-
/** CSP domains configuration. */
|
|
158
|
-
csp?: McpAppCsp;
|
|
159
|
-
/** Permission Policy requests (camera, mic, etc.). */
|
|
160
|
-
permissions?: McpAppPermissions;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Generate the `_meta` object for MCP Apps `ui://` resource registration.
|
|
164
|
-
*
|
|
165
|
-
* Includes CSP and Permission Policy configuration per the MCP Apps spec.
|
|
166
|
-
* Use on both the resource listing AND the content item (VS Code reads
|
|
167
|
-
* only the content item; other hosts may read either).
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* ```ts
|
|
171
|
-
* const meta = resourceMeta({
|
|
172
|
-
* csp: { resourceDomains: ['https://cdn.jsdelivr.net'] },
|
|
173
|
-
* permissions: { camera: true },
|
|
174
|
-
* })
|
|
175
|
-
*
|
|
176
|
-
* mcp.resource('viewer', 'ui://my/viewer', {
|
|
177
|
-
* mimeType: 'text/html;profile=mcp-app',
|
|
178
|
-
* _meta: meta,
|
|
179
|
-
* }, async (uri) => ({
|
|
180
|
-
* contents: [{ uri: uri.toString(), mimeType: 'text/html;profile=mcp-app', text: html, _meta: meta }],
|
|
181
|
-
* }))
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
|
-
/** Spec-compliant permissions shape: each granted permission is `{}`. */
|
|
185
|
-
interface McpAppPermissionsWire {
|
|
186
|
-
camera?: Record<string, never>;
|
|
187
|
-
microphone?: Record<string, never>;
|
|
188
|
-
geolocation?: Record<string, never>;
|
|
189
|
-
clipboardWrite?: Record<string, never>;
|
|
190
|
-
}
|
|
191
|
-
export declare function resourceMeta(options?: ResourceMetaOptions): {
|
|
192
|
-
ui: {
|
|
193
|
-
csp?: McpAppCsp;
|
|
194
|
-
permissions?: McpAppPermissionsWire;
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
/** Default CSP meta for prefab apps using jsDelivr CDN. */
|
|
198
|
-
export declare const PREFAB_CDN_META: {
|
|
199
|
-
ui: {
|
|
200
|
-
csp?: McpAppCsp;
|
|
201
|
-
permissions?: McpAppPermissionsWire;
|
|
202
|
-
};
|
|
203
|
-
};
|
|
204
|
-
/** Default URI for the prefab viewer resource. */
|
|
205
|
-
export declare const PREFAB_RESOURCE_URI = "ui://prefab/viewer";
|
|
206
|
-
export interface RendererHtmlOptions {
|
|
207
|
-
/** Page title. @default 'Prefab' */
|
|
208
|
-
title?: string;
|
|
209
|
-
/** Additional `<script>` URLs to load after the renderer. */
|
|
210
|
-
scripts?: string[];
|
|
211
|
-
/** Additional `<link rel="stylesheet">` URLs. */
|
|
212
|
-
stylesheets?: string[];
|
|
213
|
-
/** Override CDN base URL (no trailing slash). @default jsdelivr CDN */
|
|
214
|
-
cdnBase?: string;
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Generate the HTML page for a prefab MCP Apps viewer resource.
|
|
218
|
-
*
|
|
219
|
-
* Returns the minimal HTML that loads `prefab.css` and `renderer.auto.min.js`
|
|
220
|
-
* from the CDN, plus any additional scripts/stylesheets you specify.
|
|
221
|
-
*
|
|
222
|
-
* @example
|
|
223
|
-
* ```ts
|
|
224
|
-
* import { rendererHtml } from '@maxhealth.tech/prefab/mcp'
|
|
225
|
-
* const html = rendererHtml()
|
|
226
|
-
* // or with extra scripts:
|
|
227
|
-
* const html = rendererHtml({ scripts: ['https://cdn.example.com/plugin.js'] })
|
|
228
|
-
* ```
|
|
229
|
-
*/
|
|
230
|
-
export declare function rendererHtml(options?: RendererHtmlOptions): string;
|
|
231
|
-
export interface ViewerResourceOptions {
|
|
232
|
-
/** Resource URI. @default PREFAB_RESOURCE_URI */
|
|
233
|
-
uri?: string;
|
|
234
|
-
/** Resource title. @default 'Prefab Viewer' */
|
|
235
|
-
title?: string;
|
|
236
|
-
/** CSP configuration. @default { resourceDomains: ['https://cdn.jsdelivr.net'] } */
|
|
237
|
-
csp?: McpAppCsp;
|
|
238
|
-
/** Permission Policy requests. */
|
|
239
|
-
permissions?: McpAppPermissions;
|
|
240
|
-
/** Additional `<script>` URLs to load after the renderer. */
|
|
241
|
-
scripts?: string[];
|
|
242
|
-
/** Additional `<link rel="stylesheet">` URLs. */
|
|
243
|
-
stylesheets?: string[];
|
|
244
|
-
/** Override CDN base URL (no trailing slash). */
|
|
245
|
-
cdnBase?: string;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* MCP server interface expected by registerViewerResource.
|
|
249
|
-
* Compatible with @modelcontextprotocol/sdk McpServer and fastmcp Server.
|
|
250
|
-
*/
|
|
251
|
-
interface McpServerLike {
|
|
252
|
-
resource(name: string, uri: string, options: {
|
|
253
|
-
title?: string;
|
|
254
|
-
mimeType: string;
|
|
255
|
-
description?: string;
|
|
256
|
-
_meta?: Record<string, unknown>;
|
|
257
|
-
}, handler: (uri: URL) => Promise<{
|
|
258
|
-
contents: {
|
|
259
|
-
uri: string;
|
|
260
|
-
mimeType: string;
|
|
261
|
-
text: string;
|
|
262
|
-
_meta?: Record<string, unknown>;
|
|
263
|
-
}[];
|
|
264
|
-
}>): void;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Register the prefab viewer as a `ui://` resource on an MCP server.
|
|
268
|
-
*
|
|
269
|
-
* Handles MIME type, CSP on both listing and content item, and HTML generation.
|
|
270
|
-
* Eliminates the three most common registration mistakes in one call.
|
|
271
|
-
*
|
|
272
|
-
* @example
|
|
273
|
-
* ```ts
|
|
274
|
-
* import { registerViewerResource, PREFAB_RESOURCE_URI } from '@maxhealth.tech/prefab/mcp'
|
|
275
|
-
*
|
|
276
|
-
* registerViewerResource(server)
|
|
277
|
-
*
|
|
278
|
-
* server.tool('browse', schema, async (args) => ({
|
|
279
|
-
* content: [{ type: 'text', text: JSON.stringify(data) }],
|
|
280
|
-
* structuredContent: data,
|
|
281
|
-
* _meta: { ui: { resourceUri: PREFAB_RESOURCE_URI } },
|
|
282
|
-
* }))
|
|
283
|
-
* ```
|
|
284
|
-
*/
|
|
285
|
-
export declare function registerViewerResource(server: McpServerLike, options?: ViewerResourceOptions): void;
|
|
286
|
-
export {};
|
|
287
134
|
//# sourceMappingURL=display.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/mcp/display.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/mcp/display.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAoB,MAAM,WAAW,CAAA;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAChF,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE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O,CAAC,EAAE,qBAAqB,GAC9B,aAAa,CAAC,gBAAgB,CAAC,CAuBjC;AAID,eAAO,MAAM,WAAW,qBAAe,CAAA;AACvC,eAAO,MAAM,aAAa,uBAAiB,CAAA;AAC3C,eAAO,MAAM,YAAY,sBAAgB,CAAA;AACzC,eAAO,MAAM,cAAc,wBAAkB,CAAA"}
|
package/dist/mcp/display.js
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
import {} from '../core/component.js';
|
|
20
|
-
import { PrefabApp,
|
|
20
|
+
import { PrefabApp, PROTOCOL_VERSION } from '../app.js';
|
|
21
|
+
import { toolResult } from './result.js';
|
|
21
22
|
// ── display() ────────────────────────────────────────────────────────────────
|
|
22
23
|
/** Concatenate two optional arrays, returning undefined when both are empty/absent. */
|
|
23
24
|
function concatArrays(a, b) {
|
|
@@ -84,18 +85,14 @@ export function display(viewOrApp, options) {
|
|
|
84
85
|
pipes: options?.pipes,
|
|
85
86
|
});
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
content: [{ type: 'text', text: JSON.stringify(wire) }],
|
|
90
|
-
structuredContent: wire,
|
|
91
|
-
};
|
|
88
|
+
return toolResult(app.toJSON());
|
|
92
89
|
}
|
|
93
90
|
// ── display_form() ───────────────────────────────────────────────────────────
|
|
94
91
|
import { autoForm } from '../auto/form.js';
|
|
95
92
|
/**
|
|
96
93
|
* Return a form UI as an MCP tool result.
|
|
97
94
|
*
|
|
98
|
-
*
|
|
95
|
+
* Submitting the form calls the specified MCP tool (via CallTool).
|
|
99
96
|
* Field definitions map to Input components; the submit action
|
|
100
97
|
* invokes `submitTool` with all field values.
|
|
101
98
|
*
|
|
@@ -118,11 +115,7 @@ export function display_form(fields, submitTool, options) {
|
|
|
118
115
|
mode: options?.mode,
|
|
119
116
|
pipes: options?.pipes,
|
|
120
117
|
});
|
|
121
|
-
|
|
122
|
-
return {
|
|
123
|
-
content: [{ type: 'text', text: JSON.stringify(wire) }],
|
|
124
|
-
structuredContent: wire,
|
|
125
|
-
};
|
|
118
|
+
return toolResult(app.toJSON());
|
|
126
119
|
}
|
|
127
120
|
/**
|
|
128
121
|
* Return a partial state update for an existing prefab UI.
|
|
@@ -139,14 +132,10 @@ export function display_update(state, options) {
|
|
|
139
132
|
const acts = Array.isArray(options.actions) ? options.actions : [options.actions];
|
|
140
133
|
update.actions = acts.map(a => a.toJSON());
|
|
141
134
|
}
|
|
142
|
-
|
|
135
|
+
return toolResult({
|
|
143
136
|
$prefab: { version: PROTOCOL_VERSION },
|
|
144
137
|
update,
|
|
145
|
-
};
|
|
146
|
-
return {
|
|
147
|
-
content: [{ type: 'text', text: JSON.stringify(payload) }],
|
|
148
|
-
structuredContent: payload,
|
|
149
|
-
};
|
|
138
|
+
});
|
|
150
139
|
}
|
|
151
140
|
// ── display_error() ──────────────────────────────────────────────────────────
|
|
152
141
|
import { Column } from '../components/layout/index.js';
|
|
@@ -181,12 +170,7 @@ export function display_error(title, message, options) {
|
|
|
181
170
|
view,
|
|
182
171
|
theme: options?.theme,
|
|
183
172
|
});
|
|
184
|
-
|
|
185
|
-
return {
|
|
186
|
-
content: [{ type: 'text', text: JSON.stringify(wire) }],
|
|
187
|
-
structuredContent: wire,
|
|
188
|
-
isError: true,
|
|
189
|
-
};
|
|
173
|
+
return toolResult(app.toJSON(), { isError: true });
|
|
190
174
|
}
|
|
191
175
|
/**
|
|
192
176
|
* Return a standardized success view as an MCP tool result.
|
|
@@ -212,156 +196,11 @@ export function display_success(title, message, options) {
|
|
|
212
196
|
view,
|
|
213
197
|
theme: options?.theme,
|
|
214
198
|
});
|
|
215
|
-
|
|
216
|
-
return {
|
|
217
|
-
content: [{ type: 'text', text: JSON.stringify(wire) }],
|
|
218
|
-
structuredContent: wire,
|
|
219
|
-
};
|
|
199
|
+
return toolResult(app.toJSON());
|
|
220
200
|
}
|
|
221
201
|
// ── camelCase aliases (TS convention) ────────────────────────────────────────
|
|
222
202
|
export const displayForm = display_form;
|
|
223
203
|
export const displayUpdate = display_update;
|
|
224
204
|
export const displayError = display_error;
|
|
225
205
|
export const displaySuccess = display_success;
|
|
226
|
-
export function resourceMeta(options) {
|
|
227
|
-
const ui = {};
|
|
228
|
-
if (options?.csp) {
|
|
229
|
-
ui.csp = {
|
|
230
|
-
resourceDomains: options.csp.resourceDomains ?? [],
|
|
231
|
-
connectDomains: options.csp.connectDomains ?? [],
|
|
232
|
-
frameDomains: options.csp.frameDomains ?? [],
|
|
233
|
-
baseUriDomains: options.csp.baseUriDomains ?? [],
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
if (options?.permissions) {
|
|
237
|
-
ui.permissions = {};
|
|
238
|
-
if (options.permissions.camera)
|
|
239
|
-
ui.permissions.camera = {};
|
|
240
|
-
if (options.permissions.microphone)
|
|
241
|
-
ui.permissions.microphone = {};
|
|
242
|
-
if (options.permissions.geolocation)
|
|
243
|
-
ui.permissions.geolocation = {};
|
|
244
|
-
if (options.permissions.clipboardWrite)
|
|
245
|
-
ui.permissions.clipboardWrite = {};
|
|
246
|
-
}
|
|
247
|
-
return { ui };
|
|
248
|
-
}
|
|
249
|
-
/** Default CSP meta for prefab apps using jsDelivr CDN. */
|
|
250
|
-
export const PREFAB_CDN_META = resourceMeta({
|
|
251
|
-
csp: { resourceDomains: ['https://cdn.jsdelivr.net'] },
|
|
252
|
-
});
|
|
253
|
-
// ── rendererHtml() — generate the viewer HTML page ──────────────────────────
|
|
254
|
-
/** Default URI for the prefab viewer resource. */
|
|
255
|
-
export const PREFAB_RESOURCE_URI = 'ui://prefab/viewer';
|
|
256
|
-
/** MIME type required by MCP Apps hosts. */
|
|
257
|
-
const MCP_APP_MIME = 'text/html;profile=mcp-app';
|
|
258
|
-
/** CDN base for the @maxhealth.tech/prefab package (exact version, never stale). */
|
|
259
|
-
function cdnBase() {
|
|
260
|
-
return `https://cdn.jsdelivr.net/npm/@maxhealth.tech/prefab@${VERSION}/dist`;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Generate the HTML page for a prefab MCP Apps viewer resource.
|
|
264
|
-
*
|
|
265
|
-
* Returns the minimal HTML that loads `prefab.css` and `renderer.auto.min.js`
|
|
266
|
-
* from the CDN, plus any additional scripts/stylesheets you specify.
|
|
267
|
-
*
|
|
268
|
-
* @example
|
|
269
|
-
* ```ts
|
|
270
|
-
* import { rendererHtml } from '@maxhealth.tech/prefab/mcp'
|
|
271
|
-
* const html = rendererHtml()
|
|
272
|
-
* // or with extra scripts:
|
|
273
|
-
* const html = rendererHtml({ scripts: ['https://cdn.example.com/plugin.js'] })
|
|
274
|
-
* ```
|
|
275
|
-
*/
|
|
276
|
-
export function rendererHtml(options) {
|
|
277
|
-
const title = options?.title ?? 'Prefab';
|
|
278
|
-
const base = options?.cdnBase ?? cdnBase();
|
|
279
|
-
const extraStyles = (options?.stylesheets ?? [])
|
|
280
|
-
.map(url => ` <link rel="stylesheet" crossorigin href="${escapeAttr(url)}">`)
|
|
281
|
-
.join('\n');
|
|
282
|
-
const extraScripts = (options?.scripts ?? [])
|
|
283
|
-
.map(url => ` <script crossorigin src="${escapeAttr(url)}"></script>`)
|
|
284
|
-
.join('\n');
|
|
285
|
-
return `<!doctype html>
|
|
286
|
-
<html lang="en">
|
|
287
|
-
<head>
|
|
288
|
-
<meta charset="UTF-8">
|
|
289
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
290
|
-
<title>${escapeHtml(title)}</title>
|
|
291
|
-
<link rel="stylesheet" crossorigin href="${base}/prefab.css">
|
|
292
|
-
${extraStyles}</head>
|
|
293
|
-
<body>
|
|
294
|
-
<div id="root"></div>
|
|
295
|
-
<script crossorigin src="${base}/renderer.auto.min.js"></script>
|
|
296
|
-
${extraScripts}</body>
|
|
297
|
-
</html>`;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Register the prefab viewer as a `ui://` resource on an MCP server.
|
|
301
|
-
*
|
|
302
|
-
* Handles MIME type, CSP on both listing and content item, and HTML generation.
|
|
303
|
-
* Eliminates the three most common registration mistakes in one call.
|
|
304
|
-
*
|
|
305
|
-
* @example
|
|
306
|
-
* ```ts
|
|
307
|
-
* import { registerViewerResource, PREFAB_RESOURCE_URI } from '@maxhealth.tech/prefab/mcp'
|
|
308
|
-
*
|
|
309
|
-
* registerViewerResource(server)
|
|
310
|
-
*
|
|
311
|
-
* server.tool('browse', schema, async (args) => ({
|
|
312
|
-
* content: [{ type: 'text', text: JSON.stringify(data) }],
|
|
313
|
-
* structuredContent: data,
|
|
314
|
-
* _meta: { ui: { resourceUri: PREFAB_RESOURCE_URI } },
|
|
315
|
-
* }))
|
|
316
|
-
* ```
|
|
317
|
-
*/
|
|
318
|
-
export function registerViewerResource(server, options) {
|
|
319
|
-
const uri = options?.uri ?? PREFAB_RESOURCE_URI;
|
|
320
|
-
const title = options?.title ?? 'Prefab Viewer';
|
|
321
|
-
// Merge CSP: always include jsdelivr for the default renderer
|
|
322
|
-
const csp = options?.csp
|
|
323
|
-
? {
|
|
324
|
-
resourceDomains: [...new Set([...(options.csp.resourceDomains ?? []), 'https://cdn.jsdelivr.net'])],
|
|
325
|
-
connectDomains: options.csp.connectDomains ?? [],
|
|
326
|
-
frameDomains: options.csp.frameDomains ?? [],
|
|
327
|
-
baseUriDomains: options.csp.baseUriDomains ?? [],
|
|
328
|
-
}
|
|
329
|
-
: { resourceDomains: ['https://cdn.jsdelivr.net'] };
|
|
330
|
-
// Add script origins to CSP resourceDomains
|
|
331
|
-
if (options?.scripts && options.scripts.length > 0) {
|
|
332
|
-
const scriptOrigins = options.scripts
|
|
333
|
-
.map(url => { try {
|
|
334
|
-
return new URL(url).origin;
|
|
335
|
-
}
|
|
336
|
-
catch {
|
|
337
|
-
return null;
|
|
338
|
-
} })
|
|
339
|
-
.filter((o) => o !== null);
|
|
340
|
-
csp.resourceDomains = [...new Set([...(csp.resourceDomains ?? []), ...scriptOrigins])];
|
|
341
|
-
}
|
|
342
|
-
const meta = resourceMeta({ csp, permissions: options?.permissions });
|
|
343
|
-
const html = rendererHtml({
|
|
344
|
-
title,
|
|
345
|
-
scripts: options?.scripts,
|
|
346
|
-
stylesheets: options?.stylesheets,
|
|
347
|
-
cdnBase: options?.cdnBase,
|
|
348
|
-
});
|
|
349
|
-
// Extract name from URI: 'ui://prefab/viewer' -> 'prefab-viewer'
|
|
350
|
-
const name = uri.replace(/^ui:\/\//, '').replace(/\//g, '-');
|
|
351
|
-
server.resource(name, uri, { title, mimeType: MCP_APP_MIME, _meta: meta }, (resourceUri) => Promise.resolve({
|
|
352
|
-
contents: [{
|
|
353
|
-
uri: resourceUri.toString(),
|
|
354
|
-
mimeType: MCP_APP_MIME,
|
|
355
|
-
text: html,
|
|
356
|
-
_meta: meta,
|
|
357
|
-
}],
|
|
358
|
-
}));
|
|
359
|
-
}
|
|
360
|
-
// ── HTML escaping helpers ────────────────────────────────────────────────────
|
|
361
|
-
function escapeHtml(s) {
|
|
362
|
-
return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
363
|
-
}
|
|
364
|
-
function escapeAttr(s) {
|
|
365
|
-
return s.replace(/&/g, '&').replace(/"/g, '"');
|
|
366
|
-
}
|
|
367
206
|
//# sourceMappingURL=display.js.map
|
package/dist/mcp/display.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.js","sourceRoot":"","sources":["../../src/mcp/display.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAkB,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"display.js","sourceRoot":"","sources":["../../src/mcp/display.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAkB,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAKvD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AAW,GAAG,YAAY,CAAA;AACvC,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAA;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAA;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAA"}
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MCP display helpers — return prefab UIs as MCP tool results.
|
|
3
3
|
*/
|
|
4
|
-
export { display, display_form, display_update, display_error, display_success, displayForm, displayUpdate, displayError, displaySuccess
|
|
5
|
-
export type { DisplayOptions, DisplayFormOptions, DisplayUpdateOptions, DisplayErrorOptions, DisplaySuccessOptions, StateUpdate, PrefabUpdateWire,
|
|
6
|
-
export
|
|
4
|
+
export { display, display_form, display_update, display_error, display_success, displayForm, displayUpdate, displayError, displaySuccess } from './display.js';
|
|
5
|
+
export type { DisplayOptions, DisplayFormOptions, DisplayUpdateOptions, DisplayErrorOptions, DisplaySuccessOptions, StateUpdate, PrefabUpdateWire, } from './display.js';
|
|
6
|
+
export { toolResult } from './result.js';
|
|
7
|
+
export type { ToolResultOptions } from './result.js';
|
|
8
|
+
export { themeBridgeCss, VSCODE_BRIDGE } from './theme-bridge.js';
|
|
9
|
+
export type { ThemeBridge, VsCodeTokenSource } from './theme-bridge.js';
|
|
10
|
+
export { resourceMeta, registerViewerResource, rendererHtml, PREFAB_CDN_META, PREFAB_RESOURCE_URI, MCP_APP_MIME, APPS_EXTENSION, DEFAULT_VIEWER_CACHE, } from './resource.js';
|
|
11
|
+
export type { McpAppCsp, McpAppPermissions, ResourceMetaOptions, RendererHtmlOptions, ViewerResourceOptions, McpServerLike, ResourceConfig, ResourceReadHandler, } from './resource.js';
|
|
12
|
+
export type { McpToolResult, McpContent, McpTextContent, McpImageContent, McpResourceContent, McpTextResourceContents, McpBlobResourceContents, McpCacheScope, McpCacheHint, McpResourceReadResult } from './types.js';
|
|
7
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/mcp/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC9J,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,gBAAgB,GACjB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAEvE,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,oBAAoB,GACrB,MAAM,eAAe,CAAA;AACtB,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,mBAAmB,GACpB,MAAM,eAAe,CAAA;AAEtB,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,aAAa,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MCP display helpers — return prefab UIs as MCP tool results.
|
|
3
3
|
*/
|
|
4
|
-
export { display, display_form, display_update, display_error, display_success, displayForm, displayUpdate, displayError, displaySuccess
|
|
4
|
+
export { display, display_form, display_update, display_error, display_success, displayForm, displayUpdate, displayError, displaySuccess } from './display.js';
|
|
5
|
+
export { toolResult } from './result.js';
|
|
6
|
+
export { themeBridgeCss, VSCODE_BRIDGE } from './theme-bridge.js';
|
|
7
|
+
export { resourceMeta, registerViewerResource, rendererHtml, PREFAB_CDN_META, PREFAB_RESOURCE_URI, MCP_APP_MIME, APPS_EXTENSION, DEFAULT_VIEWER_CACHE, } from './resource.js';
|
|
5
8
|
//# sourceMappingURL=index.js.map
|
package/dist/mcp/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAW9J,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAGjE,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,oBAAoB,GACrB,MAAM,eAAe,CAAA"}
|