@umbraco-cms/mcp-dev 17.6.7 → 17.6.9
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.cjs +160 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +77 -14
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -15664,6 +15664,9 @@ var Protocol = class {
|
|
|
15664
15664
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
15665
15665
|
const handleTaskResult = async () => {
|
|
15666
15666
|
const taskId = request.params.taskId;
|
|
15667
|
+
if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
|
|
15668
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
15669
|
+
}
|
|
15667
15670
|
if (this._taskMessageQueue) {
|
|
15668
15671
|
let queuedMessage;
|
|
15669
15672
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -15694,12 +15697,12 @@ var Protocol = class {
|
|
|
15694
15697
|
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
15695
15698
|
}
|
|
15696
15699
|
if (!isTerminal(task.status)) {
|
|
15697
|
-
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
15700
|
+
await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
|
|
15698
15701
|
return await handleTaskResult();
|
|
15699
15702
|
}
|
|
15700
15703
|
if (isTerminal(task.status)) {
|
|
15701
15704
|
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
15702
|
-
this._clearTaskQueue(taskId);
|
|
15705
|
+
this._clearTaskQueue(taskId, extra.sessionId);
|
|
15703
15706
|
return {
|
|
15704
15707
|
...result,
|
|
15705
15708
|
_meta: {
|
|
@@ -15736,7 +15739,7 @@ var Protocol = class {
|
|
|
15736
15739
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
15737
15740
|
}
|
|
15738
15741
|
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
15739
|
-
this._clearTaskQueue(request.params.taskId);
|
|
15742
|
+
this._clearTaskQueue(request.params.taskId, extra.sessionId);
|
|
15740
15743
|
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
15741
15744
|
if (!cancelledTask) {
|
|
15742
15745
|
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
@@ -15864,6 +15867,19 @@ var Protocol = class {
|
|
|
15864
15867
|
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
15865
15868
|
const capturedTransport = this._transport;
|
|
15866
15869
|
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
15870
|
+
const sessionId = capturedTransport?.sessionId;
|
|
15871
|
+
const store = this._taskStore;
|
|
15872
|
+
let relatedTaskFound = true;
|
|
15873
|
+
let relatedTaskLookup;
|
|
15874
|
+
if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
|
|
15875
|
+
relatedTaskFound = false;
|
|
15876
|
+
relatedTaskLookup = (async () => {
|
|
15877
|
+
if (!await store.getTask(relatedTaskId, sessionId)) {
|
|
15878
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
|
|
15879
|
+
}
|
|
15880
|
+
relatedTaskFound = true;
|
|
15881
|
+
})();
|
|
15882
|
+
}
|
|
15867
15883
|
if (handler === void 0) {
|
|
15868
15884
|
const errorResponse = {
|
|
15869
15885
|
jsonrpc: "2.0",
|
|
@@ -15873,7 +15889,10 @@ var Protocol = class {
|
|
|
15873
15889
|
message: "Method not found"
|
|
15874
15890
|
}
|
|
15875
15891
|
};
|
|
15876
|
-
if (relatedTaskId &&
|
|
15892
|
+
if (relatedTaskId && relatedTaskLookup) {
|
|
15893
|
+
const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
|
|
15894
|
+
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error) => this._onerror(new Error(`Failed to send an error response: ${error}`)));
|
|
15895
|
+
} else if (relatedTaskId && this._taskMessageQueue) {
|
|
15877
15896
|
this._enqueueTaskMessage(relatedTaskId, {
|
|
15878
15897
|
type: "error",
|
|
15879
15898
|
message: errorResponse,
|
|
@@ -15924,7 +15943,10 @@ var Protocol = class {
|
|
|
15924
15943
|
closeSSEStream: extra?.closeSSEStream,
|
|
15925
15944
|
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
15926
15945
|
};
|
|
15927
|
-
Promise.resolve().then(() => {
|
|
15946
|
+
(relatedTaskLookup ?? Promise.resolve()).then(() => {
|
|
15947
|
+
if (relatedTaskLookup && abortController.signal.aborted) {
|
|
15948
|
+
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
15949
|
+
}
|
|
15928
15950
|
if (taskCreationParams) {
|
|
15929
15951
|
this.assertTaskHandlerCapability(request.method);
|
|
15930
15952
|
}
|
|
@@ -15959,7 +15981,7 @@ var Protocol = class {
|
|
|
15959
15981
|
...error["data"] !== void 0 && { data: error["data"] }
|
|
15960
15982
|
}
|
|
15961
15983
|
};
|
|
15962
|
-
if (relatedTaskId && this._taskMessageQueue) {
|
|
15984
|
+
if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
|
|
15963
15985
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
15964
15986
|
type: "error",
|
|
15965
15987
|
message: errorResponse,
|
|
@@ -16439,7 +16461,7 @@ var Protocol = class {
|
|
|
16439
16461
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
16440
16462
|
}
|
|
16441
16463
|
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
16442
|
-
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
16464
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
|
|
16443
16465
|
}
|
|
16444
16466
|
/**
|
|
16445
16467
|
* Clears the message queue for a task and rejects any pending request resolvers.
|
|
@@ -16468,12 +16490,13 @@ var Protocol = class {
|
|
|
16468
16490
|
* Uses polling to check for updates at the task's configured poll interval.
|
|
16469
16491
|
* @param taskId The task ID to wait for
|
|
16470
16492
|
* @param signal Abort signal to cancel the wait
|
|
16493
|
+
* @param sessionId Session of the request that waits, passed to the task store
|
|
16471
16494
|
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
16472
16495
|
*/
|
|
16473
|
-
async _waitForTaskUpdate(taskId, signal) {
|
|
16496
|
+
async _waitForTaskUpdate(taskId, signal, sessionId) {
|
|
16474
16497
|
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
16475
16498
|
try {
|
|
16476
|
-
const task = await this._taskStore?.getTask(taskId);
|
|
16499
|
+
const task = await this._taskStore?.getTask(taskId, sessionId);
|
|
16477
16500
|
if (task?.pollInterval) {
|
|
16478
16501
|
interval = task.pollInterval;
|
|
16479
16502
|
}
|
|
@@ -17353,6 +17376,42 @@ var ExperimentalMcpServerTasks = class {
|
|
|
17353
17376
|
|
|
17354
17377
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
|
|
17355
17378
|
import { ZodOptional } from "zod";
|
|
17379
|
+
function toolInputElementCount(value, max) {
|
|
17380
|
+
let count = 0;
|
|
17381
|
+
const stack = [value];
|
|
17382
|
+
while (stack.length > 0) {
|
|
17383
|
+
const node = stack.pop();
|
|
17384
|
+
if (node === null || typeof node !== "object")
|
|
17385
|
+
continue;
|
|
17386
|
+
if (Array.isArray(node)) {
|
|
17387
|
+
for (const child of node) {
|
|
17388
|
+
if (++count > max)
|
|
17389
|
+
return count;
|
|
17390
|
+
if (child !== null && typeof child === "object")
|
|
17391
|
+
stack.push(child);
|
|
17392
|
+
}
|
|
17393
|
+
} else {
|
|
17394
|
+
for (const key in node) {
|
|
17395
|
+
if (!Object.prototype.hasOwnProperty.call(node, key))
|
|
17396
|
+
continue;
|
|
17397
|
+
if (++count > max)
|
|
17398
|
+
return count;
|
|
17399
|
+
const child = node[key];
|
|
17400
|
+
if (child !== null && typeof child === "object")
|
|
17401
|
+
stack.push(child);
|
|
17402
|
+
}
|
|
17403
|
+
}
|
|
17404
|
+
}
|
|
17405
|
+
return count;
|
|
17406
|
+
}
|
|
17407
|
+
function resolveMaxToolInputElements(value) {
|
|
17408
|
+
if (value === void 0 || value === Infinity)
|
|
17409
|
+
return void 0;
|
|
17410
|
+
if (typeof value !== "number" || Number.isNaN(value) || value < 1) {
|
|
17411
|
+
throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(value)}`);
|
|
17412
|
+
}
|
|
17413
|
+
return value;
|
|
17414
|
+
}
|
|
17356
17415
|
var McpServer = class {
|
|
17357
17416
|
constructor(serverInfo, options) {
|
|
17358
17417
|
this._registeredResources = {};
|
|
@@ -17364,6 +17423,7 @@ var McpServer = class {
|
|
|
17364
17423
|
this._resourceHandlersInitialized = false;
|
|
17365
17424
|
this._promptHandlersInitialized = false;
|
|
17366
17425
|
this.server = new Server(serverInfo, options);
|
|
17426
|
+
this._maxToolInputElements = resolveMaxToolInputElements(options?.maxToolInputElements);
|
|
17367
17427
|
}
|
|
17368
17428
|
/**
|
|
17369
17429
|
* Access experimental features.
|
|
@@ -17494,12 +17554,15 @@ var McpServer = class {
|
|
|
17494
17554
|
* Validates tool input arguments against the tool's input schema.
|
|
17495
17555
|
*/
|
|
17496
17556
|
async validateToolInput(tool, args, toolName) {
|
|
17557
|
+
if (this._maxToolInputElements !== void 0 && toolInputElementCount(args, this._maxToolInputElements) > this._maxToolInputElements) {
|
|
17558
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for tool ${toolName}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);
|
|
17559
|
+
}
|
|
17497
17560
|
if (!tool.inputSchema) {
|
|
17498
17561
|
return void 0;
|
|
17499
17562
|
}
|
|
17500
17563
|
const inputObj = normalizeObjectSchema(tool.inputSchema);
|
|
17501
17564
|
const schemaToParse = inputObj ?? tool.inputSchema;
|
|
17502
|
-
const parseResult = await safeParseAsync2(schemaToParse, args);
|
|
17565
|
+
const parseResult = await safeParseAsync2(schemaToParse, args ?? {});
|
|
17503
17566
|
if (!parseResult.success) {
|
|
17504
17567
|
const error = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
17505
17568
|
const errorMessage = getParseErrorMessage(error);
|
|
@@ -17737,7 +17800,7 @@ var McpServer = class {
|
|
|
17737
17800
|
}
|
|
17738
17801
|
if (prompt.argsSchema) {
|
|
17739
17802
|
const argsObj = normalizeObjectSchema(prompt.argsSchema);
|
|
17740
|
-
const parseResult = await safeParseAsync2(argsObj, request.params.arguments);
|
|
17803
|
+
const parseResult = await safeParseAsync2(argsObj, request.params.arguments ?? {});
|
|
17741
17804
|
if (!parseResult.success) {
|
|
17742
17805
|
const error = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
17743
17806
|
const errorMessage = getParseErrorMessage(error);
|
|
@@ -18254,7 +18317,7 @@ var StdioServerTransport = class {
|
|
|
18254
18317
|
// package.json
|
|
18255
18318
|
var package_default = {
|
|
18256
18319
|
name: "@umbraco-cms/mcp-dev",
|
|
18257
|
-
version: "17.6.
|
|
18320
|
+
version: "17.6.9",
|
|
18258
18321
|
type: "module",
|
|
18259
18322
|
description: "A model context protocol (MCP) server for Umbraco CMS",
|
|
18260
18323
|
main: "dist/index.js",
|
|
@@ -18325,8 +18388,8 @@ var package_default = {
|
|
|
18325
18388
|
"@modelcontextprotocol/sdk": "^1.28.0",
|
|
18326
18389
|
"@types/uuid": "^10.0.0",
|
|
18327
18390
|
"@types/yargs": "^17.0.33",
|
|
18328
|
-
"@umbraco-cms/mcp-hosted": "^1.0.0-beta.
|
|
18329
|
-
"@umbraco-cms/mcp-server-sdk": "^1.0.0-beta.
|
|
18391
|
+
"@umbraco-cms/mcp-hosted": "^1.0.0-beta.45",
|
|
18392
|
+
"@umbraco-cms/mcp-server-sdk": "^1.0.0-beta.45",
|
|
18330
18393
|
dotenv: "^16.5.0",
|
|
18331
18394
|
"form-data": "^4.0.4",
|
|
18332
18395
|
"mime-types": "^3.0.1",
|