@modelcontextprotocol/server-basic-preact 1.3.2 → 1.4.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/dist/index.js +180 -108
- package/dist/mcp-app.html +25 -25
- package/dist/server.js +286 -88
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -4585,6 +4585,7 @@ var require_limitLength = __commonJS((exports) => {
|
|
|
4585
4585
|
var require_pattern = __commonJS((exports) => {
|
|
4586
4586
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4587
4587
|
var code_1 = require_code2();
|
|
4588
|
+
var util_1 = require_util();
|
|
4588
4589
|
var codegen_1 = require_codegen();
|
|
4589
4590
|
var error48 = {
|
|
4590
4591
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
|
|
@@ -4597,10 +4598,18 @@ var require_pattern = __commonJS((exports) => {
|
|
|
4597
4598
|
$data: true,
|
|
4598
4599
|
error: error48,
|
|
4599
4600
|
code(cxt) {
|
|
4600
|
-
const { data, $data, schema, schemaCode, it } = cxt;
|
|
4601
|
+
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
4601
4602
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
4602
|
-
|
|
4603
|
-
|
|
4603
|
+
if ($data) {
|
|
4604
|
+
const { regExp } = it.opts.code;
|
|
4605
|
+
const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
|
|
4606
|
+
const valid = gen.let("valid");
|
|
4607
|
+
gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
|
|
4608
|
+
cxt.fail$data((0, codegen_1._)`!${valid}`);
|
|
4609
|
+
} else {
|
|
4610
|
+
const regExp = (0, code_1.usePattern)(cxt, schema);
|
|
4611
|
+
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
|
|
4612
|
+
}
|
|
4604
4613
|
}
|
|
4605
4614
|
};
|
|
4606
4615
|
exports.default = def;
|
|
@@ -24044,7 +24053,7 @@ var AssertObjectSchema = custom((v) => v !== null && (typeof v === "object" || t
|
|
|
24044
24053
|
var ProgressTokenSchema = union([string2(), number2().int()]);
|
|
24045
24054
|
var CursorSchema = string2();
|
|
24046
24055
|
var TaskCreationParamsSchema = looseObject({
|
|
24047
|
-
ttl:
|
|
24056
|
+
ttl: number2().optional(),
|
|
24048
24057
|
pollInterval: number2().optional()
|
|
24049
24058
|
});
|
|
24050
24059
|
var TaskMetadataSchema = object2({
|
|
@@ -24198,7 +24207,8 @@ var ClientCapabilitiesSchema = object2({
|
|
|
24198
24207
|
roots: object2({
|
|
24199
24208
|
listChanged: boolean2().optional()
|
|
24200
24209
|
}).optional(),
|
|
24201
|
-
tasks: ClientTasksCapabilitySchema.optional()
|
|
24210
|
+
tasks: ClientTasksCapabilitySchema.optional(),
|
|
24211
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
24202
24212
|
});
|
|
24203
24213
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
24204
24214
|
protocolVersion: string2(),
|
|
@@ -24223,7 +24233,8 @@ var ServerCapabilitiesSchema = object2({
|
|
|
24223
24233
|
tools: object2({
|
|
24224
24234
|
listChanged: boolean2().optional()
|
|
24225
24235
|
}).optional(),
|
|
24226
|
-
tasks: ServerTasksCapabilitySchema.optional()
|
|
24236
|
+
tasks: ServerTasksCapabilitySchema.optional(),
|
|
24237
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
24227
24238
|
});
|
|
24228
24239
|
var InitializeResultSchema = ResultSchema.extend({
|
|
24229
24240
|
protocolVersion: string2(),
|
|
@@ -24338,6 +24349,7 @@ var ResourceSchema = object2({
|
|
|
24338
24349
|
uri: string2(),
|
|
24339
24350
|
description: optional(string2()),
|
|
24340
24351
|
mimeType: optional(string2()),
|
|
24352
|
+
size: optional(number2()),
|
|
24341
24353
|
annotations: AnnotationsSchema.optional(),
|
|
24342
24354
|
_meta: optional(looseObject({}))
|
|
24343
24355
|
});
|
|
@@ -26329,6 +26341,9 @@ class Protocol {
|
|
|
26329
26341
|
}
|
|
26330
26342
|
}
|
|
26331
26343
|
async connect(transport) {
|
|
26344
|
+
if (this._transport) {
|
|
26345
|
+
throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");
|
|
26346
|
+
}
|
|
26332
26347
|
this._transport = transport;
|
|
26333
26348
|
const _onclose = this.transport?.onclose;
|
|
26334
26349
|
this._transport.onclose = () => {
|
|
@@ -26361,6 +26376,14 @@ class Protocol {
|
|
|
26361
26376
|
this._progressHandlers.clear();
|
|
26362
26377
|
this._taskProgressTokens.clear();
|
|
26363
26378
|
this._pendingDebouncedNotifications.clear();
|
|
26379
|
+
for (const info of this._timeoutInfo.values()) {
|
|
26380
|
+
clearTimeout(info.timeoutId);
|
|
26381
|
+
}
|
|
26382
|
+
this._timeoutInfo.clear();
|
|
26383
|
+
for (const controller of this._requestHandlerAbortControllers.values()) {
|
|
26384
|
+
controller.abort();
|
|
26385
|
+
}
|
|
26386
|
+
this._requestHandlerAbortControllers.clear();
|
|
26364
26387
|
const error48 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
26365
26388
|
this._transport = undefined;
|
|
26366
26389
|
this.onclose?.();
|
|
@@ -26411,6 +26434,8 @@ class Protocol {
|
|
|
26411
26434
|
sessionId: capturedTransport?.sessionId,
|
|
26412
26435
|
_meta: request.params?._meta,
|
|
26413
26436
|
sendNotification: async (notification) => {
|
|
26437
|
+
if (abortController.signal.aborted)
|
|
26438
|
+
return;
|
|
26414
26439
|
const notificationOptions = { relatedRequestId: request.id };
|
|
26415
26440
|
if (relatedTaskId) {
|
|
26416
26441
|
notificationOptions.relatedTask = { taskId: relatedTaskId };
|
|
@@ -26418,6 +26443,9 @@ class Protocol {
|
|
|
26418
26443
|
await this.notification(notification, notificationOptions);
|
|
26419
26444
|
},
|
|
26420
26445
|
sendRequest: async (r, resultSchema, options) => {
|
|
26446
|
+
if (abortController.signal.aborted) {
|
|
26447
|
+
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
26448
|
+
}
|
|
26421
26449
|
const requestOptions = { ...options, relatedRequestId: request.id };
|
|
26422
26450
|
if (relatedTaskId && !requestOptions.relatedTask) {
|
|
26423
26451
|
requestOptions.relatedTask = { taskId: relatedTaskId };
|
|
@@ -26482,7 +26510,9 @@ class Protocol {
|
|
|
26482
26510
|
await capturedTransport?.send(errorResponse);
|
|
26483
26511
|
}
|
|
26484
26512
|
}).catch((error48) => this._onerror(new Error(`Failed to send response: ${error48}`))).finally(() => {
|
|
26485
|
-
this._requestHandlerAbortControllers.
|
|
26513
|
+
if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
|
|
26514
|
+
this._requestHandlerAbortControllers.delete(request.id);
|
|
26515
|
+
}
|
|
26486
26516
|
});
|
|
26487
26517
|
}
|
|
26488
26518
|
_onprogress(notification) {
|
|
@@ -27031,6 +27061,62 @@ class ExperimentalServerTasks {
|
|
|
27031
27061
|
requestStream(request, resultSchema, options) {
|
|
27032
27062
|
return this._server.requestStream(request, resultSchema, options);
|
|
27033
27063
|
}
|
|
27064
|
+
createMessageStream(params, options) {
|
|
27065
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
27066
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
27067
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
27068
|
+
}
|
|
27069
|
+
if (params.messages.length > 0) {
|
|
27070
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
27071
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
27072
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
27073
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : undefined;
|
|
27074
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
27075
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
27076
|
+
if (hasToolResults) {
|
|
27077
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
27078
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
27079
|
+
}
|
|
27080
|
+
if (!hasPreviousToolUse) {
|
|
27081
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
27082
|
+
}
|
|
27083
|
+
}
|
|
27084
|
+
if (hasPreviousToolUse) {
|
|
27085
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
27086
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
27087
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
27088
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
27089
|
+
}
|
|
27090
|
+
}
|
|
27091
|
+
}
|
|
27092
|
+
return this.requestStream({
|
|
27093
|
+
method: "sampling/createMessage",
|
|
27094
|
+
params
|
|
27095
|
+
}, CreateMessageResultSchema, options);
|
|
27096
|
+
}
|
|
27097
|
+
elicitInputStream(params, options) {
|
|
27098
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
27099
|
+
const mode = params.mode ?? "form";
|
|
27100
|
+
switch (mode) {
|
|
27101
|
+
case "url": {
|
|
27102
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
27103
|
+
throw new Error("Client does not support url elicitation.");
|
|
27104
|
+
}
|
|
27105
|
+
break;
|
|
27106
|
+
}
|
|
27107
|
+
case "form": {
|
|
27108
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
27109
|
+
throw new Error("Client does not support form elicitation.");
|
|
27110
|
+
}
|
|
27111
|
+
break;
|
|
27112
|
+
}
|
|
27113
|
+
}
|
|
27114
|
+
const normalizedParams = mode === "form" && params.mode === undefined ? { ...params, mode: "form" } : params;
|
|
27115
|
+
return this.requestStream({
|
|
27116
|
+
method: "elicitation/create",
|
|
27117
|
+
params: normalizedParams
|
|
27118
|
+
}, ElicitResultSchema, options);
|
|
27119
|
+
}
|
|
27034
27120
|
async getTask(taskId, options) {
|
|
27035
27121
|
return this._server.getTask({ taskId }, options);
|
|
27036
27122
|
}
|
|
@@ -28084,6 +28170,9 @@ class McpServer {
|
|
|
28084
28170
|
annotations = rest.shift();
|
|
28085
28171
|
}
|
|
28086
28172
|
} else if (typeof firstArg === "object" && firstArg !== null) {
|
|
28173
|
+
if (Object.values(firstArg).some((v) => typeof v === "object" && v !== null)) {
|
|
28174
|
+
throw new Error(`Tool ${name} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);
|
|
28175
|
+
}
|
|
28087
28176
|
annotations = rest.shift();
|
|
28088
28177
|
}
|
|
28089
28178
|
}
|
|
@@ -28176,6 +28265,9 @@ function getZodSchemaObject(schema) {
|
|
|
28176
28265
|
if (isZodRawShapeCompat(schema)) {
|
|
28177
28266
|
return objectFromShape(schema);
|
|
28178
28267
|
}
|
|
28268
|
+
if (!isZodSchemaInstance(schema)) {
|
|
28269
|
+
throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");
|
|
28270
|
+
}
|
|
28179
28271
|
return schema;
|
|
28180
28272
|
}
|
|
28181
28273
|
function promptArgumentsFromSchema(schema) {
|
|
@@ -28225,10 +28317,74 @@ import fs from "node:fs/promises";
|
|
|
28225
28317
|
import path from "node:path";
|
|
28226
28318
|
|
|
28227
28319
|
// ../../node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.js
|
|
28228
|
-
|
|
28229
|
-
|
|
28320
|
+
class j extends Protocol {
|
|
28321
|
+
_registeredMethods = new Set;
|
|
28322
|
+
_eventSlots = new Map;
|
|
28323
|
+
onEventDispatch(Z, $) {}
|
|
28324
|
+
_ensureEventSlot(Z) {
|
|
28325
|
+
let $ = this._eventSlots.get(Z);
|
|
28326
|
+
if (!$) {
|
|
28327
|
+
let J = this.eventSchemas[Z];
|
|
28328
|
+
if (!J)
|
|
28329
|
+
throw Error(`Unknown event: ${String(Z)}`);
|
|
28330
|
+
$ = { listeners: [] }, this._eventSlots.set(Z, $);
|
|
28331
|
+
let X = J.shape.method.value;
|
|
28332
|
+
this._registeredMethods.add(X);
|
|
28333
|
+
let V = $;
|
|
28334
|
+
super.setNotificationHandler(J, (D) => {
|
|
28335
|
+
let G = D.params;
|
|
28336
|
+
this.onEventDispatch(Z, G), V.onHandler?.(G);
|
|
28337
|
+
for (let L of [...V.listeners])
|
|
28338
|
+
L(G);
|
|
28339
|
+
});
|
|
28340
|
+
}
|
|
28341
|
+
return $;
|
|
28342
|
+
}
|
|
28343
|
+
setEventHandler(Z, $) {
|
|
28344
|
+
let J = this._ensureEventSlot(Z);
|
|
28345
|
+
if (J.onHandler && $)
|
|
28346
|
+
console.warn(`[MCP Apps] on${String(Z)} handler replaced. Use addEventListener("${String(Z)}", …) to add multiple listeners without replacing.`);
|
|
28347
|
+
J.onHandler = $;
|
|
28348
|
+
}
|
|
28349
|
+
getEventHandler(Z) {
|
|
28350
|
+
return this._eventSlots.get(Z)?.onHandler;
|
|
28351
|
+
}
|
|
28352
|
+
addEventListener(Z, $) {
|
|
28353
|
+
this._ensureEventSlot(Z).listeners.push($);
|
|
28354
|
+
}
|
|
28355
|
+
removeEventListener(Z, $) {
|
|
28356
|
+
let J = this._eventSlots.get(Z);
|
|
28357
|
+
if (!J)
|
|
28358
|
+
return;
|
|
28359
|
+
let X = J.listeners.indexOf($);
|
|
28360
|
+
if (X !== -1)
|
|
28361
|
+
J.listeners.splice(X, 1);
|
|
28362
|
+
}
|
|
28363
|
+
setRequestHandler = (Z, $) => {
|
|
28364
|
+
this._assertMethodNotRegistered(Z, "setRequestHandler"), super.setRequestHandler(Z, $);
|
|
28365
|
+
};
|
|
28366
|
+
setNotificationHandler = (Z, $) => {
|
|
28367
|
+
this._assertMethodNotRegistered(Z, "setNotificationHandler"), super.setNotificationHandler(Z, $);
|
|
28368
|
+
};
|
|
28369
|
+
warnIfRequestHandlerReplaced(Z, $, J) {
|
|
28370
|
+
if ($ && J)
|
|
28371
|
+
console.warn(`[MCP Apps] ${Z} handler replaced. Previous handler will no longer be called.`);
|
|
28372
|
+
}
|
|
28373
|
+
replaceRequestHandler = (Z, $) => {
|
|
28374
|
+
let J = Z.shape.method.value;
|
|
28375
|
+
this._registeredMethods.add(J), super.setRequestHandler(Z, $);
|
|
28376
|
+
};
|
|
28377
|
+
_assertMethodNotRegistered(Z, $) {
|
|
28378
|
+
let J = Z.shape.method.value;
|
|
28379
|
+
if (this._registeredMethods.has(J))
|
|
28380
|
+
throw Error(`Handler for "${J}" already registered (via ${$}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);
|
|
28381
|
+
this._registeredMethods.add(J);
|
|
28382
|
+
}
|
|
28383
|
+
}
|
|
28384
|
+
var F = "2026-01-26";
|
|
28385
|
+
var z2 = "ui/notifications/tool-input-partial";
|
|
28230
28386
|
|
|
28231
|
-
class
|
|
28387
|
+
class B {
|
|
28232
28388
|
eventTarget;
|
|
28233
28389
|
eventSource;
|
|
28234
28390
|
messageListener;
|
|
@@ -28253,7 +28409,7 @@ class j {
|
|
|
28253
28409
|
window.addEventListener("message", this.messageListener);
|
|
28254
28410
|
}
|
|
28255
28411
|
async send(Z, $) {
|
|
28256
|
-
if (Z.method !==
|
|
28412
|
+
if (Z.method !== z2)
|
|
28257
28413
|
console.debug("Sending message", Z);
|
|
28258
28414
|
this.eventTarget.postMessage(Z, "*");
|
|
28259
28415
|
}
|
|
@@ -28266,10 +28422,10 @@ class j {
|
|
|
28266
28422
|
sessionId;
|
|
28267
28423
|
setProtocolVersion;
|
|
28268
28424
|
}
|
|
28269
|
-
var
|
|
28270
|
-
var
|
|
28271
|
-
var
|
|
28272
|
-
var
|
|
28425
|
+
var S = exports_external.union([exports_external.literal("light"), exports_external.literal("dark")]).describe("Color theme preference for the host environment.");
|
|
28426
|
+
var W = exports_external.union([exports_external.literal("inline"), exports_external.literal("fullscreen"), exports_external.literal("pip")]).describe("Display mode for UI presentation.");
|
|
28427
|
+
var i = exports_external.union([exports_external.literal("--color-background-primary"), exports_external.literal("--color-background-secondary"), exports_external.literal("--color-background-tertiary"), exports_external.literal("--color-background-inverse"), exports_external.literal("--color-background-ghost"), exports_external.literal("--color-background-info"), exports_external.literal("--color-background-danger"), exports_external.literal("--color-background-success"), exports_external.literal("--color-background-warning"), exports_external.literal("--color-background-disabled"), exports_external.literal("--color-text-primary"), exports_external.literal("--color-text-secondary"), exports_external.literal("--color-text-tertiary"), exports_external.literal("--color-text-inverse"), exports_external.literal("--color-text-ghost"), exports_external.literal("--color-text-info"), exports_external.literal("--color-text-danger"), exports_external.literal("--color-text-success"), exports_external.literal("--color-text-warning"), exports_external.literal("--color-text-disabled"), exports_external.literal("--color-border-primary"), exports_external.literal("--color-border-secondary"), exports_external.literal("--color-border-tertiary"), exports_external.literal("--color-border-inverse"), exports_external.literal("--color-border-ghost"), exports_external.literal("--color-border-info"), exports_external.literal("--color-border-danger"), exports_external.literal("--color-border-success"), exports_external.literal("--color-border-warning"), exports_external.literal("--color-border-disabled"), exports_external.literal("--color-ring-primary"), exports_external.literal("--color-ring-secondary"), exports_external.literal("--color-ring-inverse"), exports_external.literal("--color-ring-info"), exports_external.literal("--color-ring-danger"), exports_external.literal("--color-ring-success"), exports_external.literal("--color-ring-warning"), exports_external.literal("--font-sans"), exports_external.literal("--font-mono"), exports_external.literal("--font-weight-normal"), exports_external.literal("--font-weight-medium"), exports_external.literal("--font-weight-semibold"), exports_external.literal("--font-weight-bold"), exports_external.literal("--font-text-xs-size"), exports_external.literal("--font-text-sm-size"), exports_external.literal("--font-text-md-size"), exports_external.literal("--font-text-lg-size"), exports_external.literal("--font-heading-xs-size"), exports_external.literal("--font-heading-sm-size"), exports_external.literal("--font-heading-md-size"), exports_external.literal("--font-heading-lg-size"), exports_external.literal("--font-heading-xl-size"), exports_external.literal("--font-heading-2xl-size"), exports_external.literal("--font-heading-3xl-size"), exports_external.literal("--font-text-xs-line-height"), exports_external.literal("--font-text-sm-line-height"), exports_external.literal("--font-text-md-line-height"), exports_external.literal("--font-text-lg-line-height"), exports_external.literal("--font-heading-xs-line-height"), exports_external.literal("--font-heading-sm-line-height"), exports_external.literal("--font-heading-md-line-height"), exports_external.literal("--font-heading-lg-line-height"), exports_external.literal("--font-heading-xl-line-height"), exports_external.literal("--font-heading-2xl-line-height"), exports_external.literal("--font-heading-3xl-line-height"), exports_external.literal("--border-radius-xs"), exports_external.literal("--border-radius-sm"), exports_external.literal("--border-radius-md"), exports_external.literal("--border-radius-lg"), exports_external.literal("--border-radius-xl"), exports_external.literal("--border-radius-full"), exports_external.literal("--border-width-regular"), exports_external.literal("--shadow-hairline"), exports_external.literal("--shadow-sm"), exports_external.literal("--shadow-md"), exports_external.literal("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming.");
|
|
28428
|
+
var n = exports_external.record(i.describe(`Style variables for theming MCP apps.
|
|
28273
28429
|
|
|
28274
28430
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
28275
28431
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
@@ -28288,30 +28444,30 @@ Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
|
28288
28444
|
|
|
28289
28445
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
28290
28446
|
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);
|
|
28291
|
-
var
|
|
28292
|
-
var
|
|
28293
|
-
var
|
|
28294
|
-
var
|
|
28295
|
-
var
|
|
28296
|
-
var
|
|
28447
|
+
var o = exports_external.object({ method: exports_external.literal("ui/open-link"), params: exports_external.object({ url: exports_external.string().describe("URL to open in the host's browser") }) });
|
|
28448
|
+
var O = exports_external.object({ isError: exports_external.boolean().optional().describe("True if the host failed to open the URL (e.g., due to security policy).") }).passthrough();
|
|
28449
|
+
var I = exports_external.object({ isError: exports_external.boolean().optional().describe("True if the download failed (e.g., user cancelled or host denied).") }).passthrough();
|
|
28450
|
+
var w = exports_external.object({ isError: exports_external.boolean().optional().describe("True if the host rejected or failed to deliver the message.") }).passthrough();
|
|
28451
|
+
var a = exports_external.object({ method: exports_external.literal("ui/notifications/sandbox-proxy-ready"), params: exports_external.object({}) });
|
|
28452
|
+
var K = exports_external.object({ connectDomains: exports_external.array(exports_external.string()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
28297
28453
|
|
|
28298
28454
|
- Maps to CSP \`connect-src\` directive
|
|
28299
28455
|
- Empty or omitted → no network connections (secure default)`), resourceDomains: exports_external.array(exports_external.string()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"), frameDomains: exports_external.array(exports_external.string()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"), baseUriDomains: exports_external.array(exports_external.string()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)") });
|
|
28300
|
-
var
|
|
28301
|
-
var
|
|
28302
|
-
var
|
|
28303
|
-
var
|
|
28304
|
-
var
|
|
28456
|
+
var N = exports_external.object({ camera: exports_external.object({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."), microphone: exports_external.object({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."), geolocation: exports_external.object({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."), clipboardWrite: exports_external.object({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.") });
|
|
28457
|
+
var s = exports_external.object({ method: exports_external.literal("ui/notifications/size-changed"), params: exports_external.object({ width: exports_external.number().optional().describe("New width in pixels."), height: exports_external.number().optional().describe("New height in pixels.") }) });
|
|
28458
|
+
var A = exports_external.object({ method: exports_external.literal("ui/notifications/tool-input"), params: exports_external.object({ arguments: exports_external.record(exports_external.string(), exports_external.unknown().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.") }) });
|
|
28459
|
+
var P = exports_external.object({ method: exports_external.literal("ui/notifications/tool-input-partial"), params: exports_external.object({ arguments: exports_external.record(exports_external.string(), exports_external.unknown().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).") }) });
|
|
28460
|
+
var H = exports_external.object({ method: exports_external.literal("ui/notifications/tool-cancelled"), params: exports_external.object({ reason: exports_external.string().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").') }) });
|
|
28305
28461
|
var b = exports_external.object({ fonts: exports_external.string().optional() });
|
|
28306
|
-
var
|
|
28307
|
-
var
|
|
28308
|
-
var
|
|
28309
|
-
var
|
|
28310
|
-
var
|
|
28311
|
-
var
|
|
28312
|
-
var
|
|
28313
|
-
var
|
|
28314
|
-
var
|
|
28462
|
+
var C = exports_external.object({ variables: n.optional().describe("CSS variables for theming the app."), css: b.optional().describe("CSS blocks that apps can inject.") });
|
|
28463
|
+
var _ = exports_external.object({ method: exports_external.literal("ui/resource-teardown"), params: exports_external.object({}) });
|
|
28464
|
+
var t = exports_external.record(exports_external.string(), exports_external.unknown());
|
|
28465
|
+
var q = exports_external.object({ text: exports_external.object({}).optional().describe("Host supports text content blocks."), image: exports_external.object({}).optional().describe("Host supports image content blocks."), audio: exports_external.object({}).optional().describe("Host supports audio content blocks."), resource: exports_external.object({}).optional().describe("Host supports resource content blocks."), resourceLink: exports_external.object({}).optional().describe("Host supports resource link content blocks."), structuredContent: exports_external.object({}).optional().describe("Host supports structured content.") });
|
|
28466
|
+
var e = exports_external.object({ method: exports_external.literal("ui/notifications/request-teardown"), params: exports_external.object({}).optional() });
|
|
28467
|
+
var y = exports_external.object({ experimental: exports_external.object({}).optional().describe("Experimental features (structure TBD)."), openLinks: exports_external.object({}).optional().describe("Host supports opening external URLs."), downloadFile: exports_external.object({}).optional().describe("Host supports file downloads via ui/download-file."), serverTools: exports_external.object({ listChanged: exports_external.boolean().optional().describe("Host supports tools/list_changed notifications.") }).optional().describe("Host can proxy tool calls to the MCP server."), serverResources: exports_external.object({ listChanged: exports_external.boolean().optional().describe("Host supports resources/list_changed notifications.") }).optional().describe("Host can proxy resource reads to the MCP server."), logging: exports_external.object({}).optional().describe("Host accepts log messages."), sandbox: exports_external.object({ permissions: N.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."), csp: K.optional().describe("CSP domains approved by the host.") }).optional().describe("Sandbox configuration applied by the host."), updateModelContext: q.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."), message: q.optional().describe("Host supports receiving content messages (ui/message) from the view.") });
|
|
28468
|
+
var v = exports_external.object({ experimental: exports_external.object({}).optional().describe("Experimental features (structure TBD)."), tools: exports_external.object({ listChanged: exports_external.boolean().optional().describe("App supports tools/list_changed notifications.") }).optional().describe("App exposes MCP-style tools that the host can call."), availableDisplayModes: exports_external.array(W).optional().describe("Display modes the app supports.") });
|
|
28469
|
+
var QQ = exports_external.object({ method: exports_external.literal("ui/notifications/initialized"), params: exports_external.object({}).optional() });
|
|
28470
|
+
var ZQ = exports_external.object({ csp: K.optional().describe("Content Security Policy configuration for UI resources."), permissions: N.optional().describe("Sandbox permissions requested by the UI resource."), domain: exports_external.string().optional().describe(`Dedicated origin for view sandbox.
|
|
28315
28471
|
|
|
28316
28472
|
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
28317
28473
|
|
|
@@ -28326,33 +28482,38 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
28326
28482
|
- \`true\`: request visible border + background
|
|
28327
28483
|
- \`false\`: request no visible border + background
|
|
28328
28484
|
- omitted: host decides border`) });
|
|
28329
|
-
var
|
|
28330
|
-
var
|
|
28331
|
-
var
|
|
28332
|
-
var
|
|
28485
|
+
var $Q = exports_external.object({ method: exports_external.literal("ui/request-display-mode"), params: exports_external.object({ mode: W.describe("The display mode being requested.") }) });
|
|
28486
|
+
var T = exports_external.object({ mode: W.describe("The display mode that was actually set. May differ from requested if not supported.") }).passthrough();
|
|
28487
|
+
var f = exports_external.union([exports_external.literal("model"), exports_external.literal("app")]).describe("Tool visibility scope - who can access the tool.");
|
|
28488
|
+
var JQ = exports_external.object({ resourceUri: exports_external.string().optional(), visibility: exports_external.array(f).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
28333
28489
|
- "model": Tool visible to and callable by the agent
|
|
28334
28490
|
- "app": Tool callable by the app from this server only`) });
|
|
28335
|
-
var
|
|
28336
|
-
var
|
|
28337
|
-
var
|
|
28338
|
-
var
|
|
28339
|
-
var
|
|
28340
|
-
var E = exports_external.object({ toolInfo: exports_external.object({ id: RequestIdSchema.optional().describe("JSON-RPC id of the tools/call request."), tool: ToolSchema.describe("Tool definition including name, inputSchema, etc.") }).optional().describe("Metadata of the tool call that instantiated this App."), theme:
|
|
28491
|
+
var UQ = exports_external.object({ mimeTypes: exports_external.array(exports_external.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.') });
|
|
28492
|
+
var XQ = exports_external.object({ method: exports_external.literal("ui/download-file"), params: exports_external.object({ contents: exports_external.array(exports_external.union([EmbeddedResourceSchema, ResourceLinkSchema])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.") }) });
|
|
28493
|
+
var VQ = exports_external.object({ method: exports_external.literal("ui/message"), params: exports_external.object({ role: exports_external.literal("user").describe('Message role, currently only "user" is supported.'), content: exports_external.array(ContentBlockSchema).describe("Message content blocks (text, image, etc.).") }) });
|
|
28494
|
+
var DQ = exports_external.object({ method: exports_external.literal("ui/notifications/sandbox-resource-ready"), params: exports_external.object({ html: exports_external.string().describe("HTML content to load into the inner iframe."), sandbox: exports_external.string().optional().describe("Optional override for the inner iframe's sandbox attribute."), csp: K.optional().describe("CSP configuration from resource metadata."), permissions: N.optional().describe("Sandbox permissions from resource metadata.") }) });
|
|
28495
|
+
var R = exports_external.object({ method: exports_external.literal("ui/notifications/tool-result"), params: CallToolResultSchema.describe("Standard MCP tool execution result.") });
|
|
28496
|
+
var E = exports_external.object({ toolInfo: exports_external.object({ id: RequestIdSchema.optional().describe("JSON-RPC id of the tools/call request."), tool: ToolSchema.describe("Tool definition including name, inputSchema, etc.") }).optional().describe("Metadata of the tool call that instantiated this App."), theme: S.optional().describe("Current color theme preference."), styles: C.optional().describe("Style configuration for theming the app."), displayMode: W.optional().describe("How the UI is currently displayed."), availableDisplayModes: exports_external.array(W).optional().describe("Display modes the host supports."), containerDimensions: exports_external.union([exports_external.object({ height: exports_external.number().describe("Fixed container height in pixels.") }), exports_external.object({ maxHeight: exports_external.union([exports_external.number(), exports_external.undefined()]).optional().describe("Maximum container height in pixels.") })]).and(exports_external.union([exports_external.object({ width: exports_external.number().describe("Fixed container width in pixels.") }), exports_external.object({ maxWidth: exports_external.union([exports_external.number(), exports_external.undefined()]).optional().describe("Maximum container width in pixels.") })])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
28341
28497
|
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`), locale: exports_external.string().optional().describe("User's language and region preference in BCP 47 format."), timeZone: exports_external.string().optional().describe("User's timezone in IANA format."), userAgent: exports_external.string().optional().describe("Host application identifier."), platform: exports_external.union([exports_external.literal("web"), exports_external.literal("desktop"), exports_external.literal("mobile")]).optional().describe("Platform type for responsive design decisions."), deviceCapabilities: exports_external.object({ touch: exports_external.boolean().optional().describe("Whether the device supports touch input."), hover: exports_external.boolean().optional().describe("Whether the device supports hover interactions.") }).optional().describe("Device input capabilities."), safeAreaInsets: exports_external.object({ top: exports_external.number().describe("Top safe area inset in pixels."), right: exports_external.number().describe("Right safe area inset in pixels."), bottom: exports_external.number().describe("Bottom safe area inset in pixels."), left: exports_external.number().describe("Left safe area inset in pixels.") }).optional().describe("Mobile safe area boundaries in pixels.") }).passthrough();
|
|
28342
|
-
var
|
|
28343
|
-
var
|
|
28344
|
-
var
|
|
28345
|
-
var
|
|
28346
|
-
var
|
|
28347
|
-
var
|
|
28498
|
+
var U = exports_external.object({ method: exports_external.literal("ui/notifications/host-context-changed"), params: E.describe("Partial context update containing only changed fields.") });
|
|
28499
|
+
var GQ = exports_external.object({ method: exports_external.literal("ui/update-model-context"), params: exports_external.object({ content: exports_external.array(ContentBlockSchema).optional().describe("Context content blocks (text, image, etc.)."), structuredContent: exports_external.record(exports_external.string(), exports_external.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.") }) });
|
|
28500
|
+
var LQ = exports_external.object({ method: exports_external.literal("ui/initialize"), params: exports_external.object({ appInfo: ImplementationSchema.describe("App identification (name and version)."), appCapabilities: v.describe("Features and capabilities this app provides."), protocolVersion: exports_external.string().describe("Protocol version this app supports.") }) });
|
|
28501
|
+
var k = exports_external.object({ protocolVersion: exports_external.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'), hostInfo: ImplementationSchema.describe("Host application identification and version."), hostCapabilities: y.describe("Features and capabilities provided by the host."), hostContext: E.describe("Rich context about the host environment.") }).passthrough();
|
|
28502
|
+
var M = "ui/resourceUri";
|
|
28503
|
+
var u = "text/html;profile=mcp-app";
|
|
28348
28504
|
|
|
28349
|
-
class
|
|
28505
|
+
class zQ extends j {
|
|
28350
28506
|
_appInfo;
|
|
28351
28507
|
_capabilities;
|
|
28352
28508
|
options;
|
|
28353
28509
|
_hostCapabilities;
|
|
28354
28510
|
_hostInfo;
|
|
28355
28511
|
_hostContext;
|
|
28512
|
+
eventSchemas = { toolinput: A, toolinputpartial: P, toolresult: R, toolcancelled: H, hostcontextchanged: U };
|
|
28513
|
+
onEventDispatch(Z, $) {
|
|
28514
|
+
if (Z === "hostcontextchanged")
|
|
28515
|
+
this._hostContext = { ...this._hostContext, ...$ };
|
|
28516
|
+
}
|
|
28356
28517
|
constructor(Z, $ = {}, J = { autoResize: true }) {
|
|
28357
28518
|
super(J);
|
|
28358
28519
|
this._appInfo = Z;
|
|
@@ -28360,7 +28521,7 @@ class FQ extends Protocol {
|
|
|
28360
28521
|
this.options = J;
|
|
28361
28522
|
this.setRequestHandler(PingRequestSchema, (X) => {
|
|
28362
28523
|
return console.log("Received ping:", X.params), {};
|
|
28363
|
-
}), this.
|
|
28524
|
+
}), this.setEventHandler("hostcontextchanged", undefined);
|
|
28364
28525
|
}
|
|
28365
28526
|
getHostCapabilities() {
|
|
28366
28527
|
return this._hostCapabilities;
|
|
@@ -28371,31 +28532,68 @@ class FQ extends Protocol {
|
|
|
28371
28532
|
getHostContext() {
|
|
28372
28533
|
return this._hostContext;
|
|
28373
28534
|
}
|
|
28535
|
+
get ontoolinput() {
|
|
28536
|
+
return this.getEventHandler("toolinput");
|
|
28537
|
+
}
|
|
28374
28538
|
set ontoolinput(Z) {
|
|
28375
|
-
this.
|
|
28539
|
+
this.setEventHandler("toolinput", Z);
|
|
28540
|
+
}
|
|
28541
|
+
get ontoolinputpartial() {
|
|
28542
|
+
return this.getEventHandler("toolinputpartial");
|
|
28376
28543
|
}
|
|
28377
28544
|
set ontoolinputpartial(Z) {
|
|
28378
|
-
this.
|
|
28545
|
+
this.setEventHandler("toolinputpartial", Z);
|
|
28546
|
+
}
|
|
28547
|
+
get ontoolresult() {
|
|
28548
|
+
return this.getEventHandler("toolresult");
|
|
28379
28549
|
}
|
|
28380
28550
|
set ontoolresult(Z) {
|
|
28381
|
-
this.
|
|
28551
|
+
this.setEventHandler("toolresult", Z);
|
|
28552
|
+
}
|
|
28553
|
+
get ontoolcancelled() {
|
|
28554
|
+
return this.getEventHandler("toolcancelled");
|
|
28382
28555
|
}
|
|
28383
28556
|
set ontoolcancelled(Z) {
|
|
28384
|
-
this.
|
|
28557
|
+
this.setEventHandler("toolcancelled", Z);
|
|
28558
|
+
}
|
|
28559
|
+
get onhostcontextchanged() {
|
|
28560
|
+
return this.getEventHandler("hostcontextchanged");
|
|
28385
28561
|
}
|
|
28386
28562
|
set onhostcontextchanged(Z) {
|
|
28387
|
-
this.
|
|
28388
|
-
|
|
28389
|
-
|
|
28563
|
+
this.setEventHandler("hostcontextchanged", Z);
|
|
28564
|
+
}
|
|
28565
|
+
_onteardown;
|
|
28566
|
+
get onteardown() {
|
|
28567
|
+
return this._onteardown;
|
|
28390
28568
|
}
|
|
28391
28569
|
set onteardown(Z) {
|
|
28392
|
-
this.
|
|
28570
|
+
this.warnIfRequestHandlerReplaced("onteardown", this._onteardown, Z), this._onteardown = Z, this.replaceRequestHandler(_, ($, J) => {
|
|
28571
|
+
if (!this._onteardown)
|
|
28572
|
+
throw Error("No onteardown handler set");
|
|
28573
|
+
return this._onteardown($.params, J);
|
|
28574
|
+
});
|
|
28575
|
+
}
|
|
28576
|
+
_oncalltool;
|
|
28577
|
+
get oncalltool() {
|
|
28578
|
+
return this._oncalltool;
|
|
28393
28579
|
}
|
|
28394
28580
|
set oncalltool(Z) {
|
|
28395
|
-
this.
|
|
28581
|
+
this.warnIfRequestHandlerReplaced("oncalltool", this._oncalltool, Z), this._oncalltool = Z, this.replaceRequestHandler(CallToolRequestSchema, ($, J) => {
|
|
28582
|
+
if (!this._oncalltool)
|
|
28583
|
+
throw Error("No oncalltool handler set");
|
|
28584
|
+
return this._oncalltool($.params, J);
|
|
28585
|
+
});
|
|
28586
|
+
}
|
|
28587
|
+
_onlisttools;
|
|
28588
|
+
get onlisttools() {
|
|
28589
|
+
return this._onlisttools;
|
|
28396
28590
|
}
|
|
28397
28591
|
set onlisttools(Z) {
|
|
28398
|
-
this.
|
|
28592
|
+
this.warnIfRequestHandlerReplaced("onlisttools", this._onlisttools, Z), this._onlisttools = Z, this.replaceRequestHandler(ListToolsRequestSchema, ($, J) => {
|
|
28593
|
+
if (!this._onlisttools)
|
|
28594
|
+
throw Error("No onlisttools handler set");
|
|
28595
|
+
return this._onlisttools($.params, J);
|
|
28596
|
+
});
|
|
28399
28597
|
}
|
|
28400
28598
|
assertCapabilityForMethod(Z) {}
|
|
28401
28599
|
assertRequestHandlerCapability(Z) {
|
|
@@ -28431,7 +28629,7 @@ class FQ extends Protocol {
|
|
|
28431
28629
|
return await this.request({ method: "resources/list", params: Z }, ListResourcesResultSchema, $);
|
|
28432
28630
|
}
|
|
28433
28631
|
sendMessage(Z, $) {
|
|
28434
|
-
return this.request({ method: "ui/message", params: Z },
|
|
28632
|
+
return this.request({ method: "ui/message", params: Z }, w, $);
|
|
28435
28633
|
}
|
|
28436
28634
|
sendLog(Z) {
|
|
28437
28635
|
return this.notification({ method: "notifications/message", params: Z });
|
|
@@ -28440,17 +28638,17 @@ class FQ extends Protocol {
|
|
|
28440
28638
|
return this.request({ method: "ui/update-model-context", params: Z }, EmptyResultSchema, $);
|
|
28441
28639
|
}
|
|
28442
28640
|
openLink(Z, $) {
|
|
28443
|
-
return this.request({ method: "ui/open-link", params: Z },
|
|
28641
|
+
return this.request({ method: "ui/open-link", params: Z }, O, $);
|
|
28444
28642
|
}
|
|
28445
28643
|
sendOpenLink = this.openLink;
|
|
28446
28644
|
downloadFile(Z, $) {
|
|
28447
|
-
return this.request({ method: "ui/download-file", params: Z },
|
|
28645
|
+
return this.request({ method: "ui/download-file", params: Z }, I, $);
|
|
28448
28646
|
}
|
|
28449
28647
|
requestTeardown(Z = {}) {
|
|
28450
28648
|
return this.notification({ method: "ui/notifications/request-teardown", params: Z });
|
|
28451
28649
|
}
|
|
28452
28650
|
requestDisplayMode(Z, $) {
|
|
28453
|
-
return this.request({ method: "ui/request-display-mode", params: Z },
|
|
28651
|
+
return this.request({ method: "ui/request-display-mode", params: Z }, T, $);
|
|
28454
28652
|
}
|
|
28455
28653
|
sendSizeChanged(Z) {
|
|
28456
28654
|
return this.notification({ method: "ui/notifications/size-changed", params: Z });
|
|
@@ -28461,25 +28659,25 @@ class FQ extends Protocol {
|
|
|
28461
28659
|
return;
|
|
28462
28660
|
Z = true, requestAnimationFrame(() => {
|
|
28463
28661
|
Z = false;
|
|
28464
|
-
let
|
|
28465
|
-
|
|
28466
|
-
let
|
|
28467
|
-
|
|
28468
|
-
let
|
|
28469
|
-
if (
|
|
28470
|
-
$ =
|
|
28662
|
+
let D = document.documentElement, G = D.style.height;
|
|
28663
|
+
D.style.height = "max-content";
|
|
28664
|
+
let L = Math.ceil(D.getBoundingClientRect().height);
|
|
28665
|
+
D.style.height = G;
|
|
28666
|
+
let Y = Math.ceil(window.innerWidth);
|
|
28667
|
+
if (Y !== $ || L !== J)
|
|
28668
|
+
$ = Y, J = L, this.sendSizeChanged({ width: Y, height: L });
|
|
28471
28669
|
});
|
|
28472
28670
|
};
|
|
28473
28671
|
X();
|
|
28474
28672
|
let V = new ResizeObserver(X);
|
|
28475
28673
|
return V.observe(document.documentElement), V.observe(document.body), () => V.disconnect();
|
|
28476
28674
|
}
|
|
28477
|
-
async connect(Z = new
|
|
28675
|
+
async connect(Z = new B(window.parent, window.parent), $) {
|
|
28478
28676
|
if (this.transport)
|
|
28479
28677
|
throw Error("App is already connected. Call close() before connecting again.");
|
|
28480
28678
|
await super.connect(Z);
|
|
28481
28679
|
try {
|
|
28482
|
-
let J = await this.request({ method: "ui/initialize", params: { appCapabilities: this._capabilities, appInfo: this._appInfo, protocolVersion:
|
|
28680
|
+
let J = await this.request({ method: "ui/initialize", params: { appCapabilities: this._capabilities, appInfo: this._appInfo, protocolVersion: F } }, k, $);
|
|
28483
28681
|
if (J === undefined)
|
|
28484
28682
|
throw Error(`Server sent invalid initialize result: ${J}`);
|
|
28485
28683
|
if (this._hostCapabilities = J.hostCapabilities, this._hostInfo = J.hostInfo, this._hostContext = J.hostContext, await this.notification({ method: "ui/notifications/initialized" }), this.options?.autoResize)
|
|
@@ -28489,16 +28687,16 @@ class FQ extends Protocol {
|
|
|
28489
28687
|
}
|
|
28490
28688
|
}
|
|
28491
28689
|
}
|
|
28492
|
-
function
|
|
28493
|
-
let V = J._meta,
|
|
28494
|
-
if (
|
|
28495
|
-
|
|
28496
|
-
else if (
|
|
28497
|
-
|
|
28498
|
-
return Z.registerTool($, { ...J, _meta:
|
|
28690
|
+
function hZ(Z, $, J, X) {
|
|
28691
|
+
let V = J._meta, D = V.ui, G = V[M], L = V;
|
|
28692
|
+
if (D?.resourceUri && !G)
|
|
28693
|
+
L = { ...V, [M]: D.resourceUri };
|
|
28694
|
+
else if (G && !D?.resourceUri)
|
|
28695
|
+
L = { ...V, ui: { ...D, resourceUri: G } };
|
|
28696
|
+
return Z.registerTool($, { ...J, _meta: L }, X);
|
|
28499
28697
|
}
|
|
28500
|
-
function
|
|
28501
|
-
return Z.registerResource($, J, { mimeType:
|
|
28698
|
+
function mZ(Z, $, J, X, V) {
|
|
28699
|
+
return Z.registerResource($, J, { mimeType: u, ...X }, V);
|
|
28502
28700
|
}
|
|
28503
28701
|
|
|
28504
28702
|
// server.ts
|
|
@@ -28509,7 +28707,7 @@ function createServer() {
|
|
|
28509
28707
|
version: "1.0.0"
|
|
28510
28708
|
});
|
|
28511
28709
|
const resourceUri = "ui://get-time/mcp-app.html";
|
|
28512
|
-
|
|
28710
|
+
hZ(server, "get-time", {
|
|
28513
28711
|
title: "Get Time",
|
|
28514
28712
|
description: "Returns the current server time as an ISO 8601 string.",
|
|
28515
28713
|
inputSchema: {},
|
|
@@ -28518,11 +28716,11 @@ function createServer() {
|
|
|
28518
28716
|
const time3 = new Date().toISOString();
|
|
28519
28717
|
return { content: [{ type: "text", text: time3 }] };
|
|
28520
28718
|
});
|
|
28521
|
-
|
|
28719
|
+
mZ(server, resourceUri, resourceUri, { mimeType: u }, async () => {
|
|
28522
28720
|
const html = await fs.readFile(path.join(DIST_DIR, "mcp-app.html"), "utf-8");
|
|
28523
28721
|
return {
|
|
28524
28722
|
contents: [
|
|
28525
|
-
{ uri: resourceUri, mimeType:
|
|
28723
|
+
{ uri: resourceUri, mimeType: u, text: html }
|
|
28526
28724
|
]
|
|
28527
28725
|
};
|
|
28528
28726
|
});
|