@costgate/momentum-mcp 0.1.37 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/momentum-mcp.mjs +148 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ MOMENTUM_TOKEN=mom_agent_xxx \
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
整条命令不用自己拼 —— 在 Momentum 的「设置 › Agent」里签发令牌时会直接给出,
|
|
12
|
-
默认用 `@latest`,发新版不用改配置;想固定某一版时把 latest 换成版本号(当前是 0.
|
|
12
|
+
默认用 `@latest`,发新版不用改配置;想固定某一版时把 latest 换成版本号(当前是 0.2.0)。
|
|
13
13
|
|
|
14
14
|
| 环境变量 | 必填 | 说明 |
|
|
15
15
|
|---|---|---|
|
|
@@ -18,4 +18,4 @@ MOMENTUM_TOKEN=mom_agent_xxx \
|
|
|
18
18
|
| `MOMENTUM_CF_ACCESS_CLIENT_ID` | 否 | 部署在 Cloudflare Access 后面时才需要 |
|
|
19
19
|
| `MOMENTUM_CF_ACCESS_CLIENT_SECRET` | 否 | 同上 |
|
|
20
20
|
|
|
21
|
-
版本 0.
|
|
21
|
+
版本 0.2.0。客户端和服务端版本不一致时,启动日志(stderr)会明确警告。
|
package/momentum-mcp.mjs
CHANGED
|
@@ -7195,7 +7195,7 @@ var require_dist = __commonJS({
|
|
|
7195
7195
|
}
|
|
7196
7196
|
});
|
|
7197
7197
|
|
|
7198
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
7198
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
7199
7199
|
import process2 from "node:process";
|
|
7200
7200
|
|
|
7201
7201
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/core.js
|
|
@@ -11699,7 +11699,7 @@ function preprocess(fn, schema) {
|
|
|
11699
11699
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/external.js
|
|
11700
11700
|
config(en_default());
|
|
11701
11701
|
|
|
11702
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
11702
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
11703
11703
|
var LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
11704
11704
|
var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
11705
11705
|
var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
|
|
@@ -13230,7 +13230,7 @@ var UrlElicitationRequiredError = class extends McpError {
|
|
|
13230
13230
|
}
|
|
13231
13231
|
};
|
|
13232
13232
|
|
|
13233
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
13233
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
|
|
13234
13234
|
var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
|
|
13235
13235
|
var ReadBuffer = class {
|
|
13236
13236
|
constructor(options) {
|
|
@@ -13267,7 +13267,7 @@ function serializeMessage(message) {
|
|
|
13267
13267
|
return JSON.stringify(message) + "\n";
|
|
13268
13268
|
}
|
|
13269
13269
|
|
|
13270
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
13270
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
13271
13271
|
var StdioServerTransport = class {
|
|
13272
13272
|
constructor(_stdin = process2.stdin, _stdout = process2.stdout, options) {
|
|
13273
13273
|
this._stdin = _stdin;
|
|
@@ -15339,7 +15339,7 @@ var allowErrorProps = SuperJSON.allowErrorProps;
|
|
|
15339
15339
|
|
|
15340
15340
|
// src/version.ts
|
|
15341
15341
|
var UNKNOWN = "unknown";
|
|
15342
|
-
var MCP_VERSION = true ? "0.
|
|
15342
|
+
var MCP_VERSION = true ? "0.2.0" : versionFromRepo();
|
|
15343
15343
|
var CLIENT_HEADER = `momentum-mcp/${MCP_VERSION}`;
|
|
15344
15344
|
function compareVersions(a, b) {
|
|
15345
15345
|
const parse4 = (v) => {
|
|
@@ -19477,7 +19477,7 @@ function object2(shape, params) {
|
|
|
19477
19477
|
return new ZodMiniObject(def);
|
|
19478
19478
|
}
|
|
19479
19479
|
|
|
19480
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
19480
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
19481
19481
|
function isZ4Schema(s) {
|
|
19482
19482
|
const schema = s;
|
|
19483
19483
|
return !!schema._zod;
|
|
@@ -19637,7 +19637,7 @@ function getLiteralValue(schema) {
|
|
|
19637
19637
|
return void 0;
|
|
19638
19638
|
}
|
|
19639
19639
|
|
|
19640
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
19640
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
|
|
19641
19641
|
function isTerminal(status) {
|
|
19642
19642
|
return status === "completed" || status === "failed" || status === "cancelled";
|
|
19643
19643
|
}
|
|
@@ -20926,7 +20926,7 @@ var zodToJsonSchema = (schema, options) => {
|
|
|
20926
20926
|
return combined;
|
|
20927
20927
|
};
|
|
20928
20928
|
|
|
20929
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
20929
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
|
|
20930
20930
|
function mapMiniTarget(t) {
|
|
20931
20931
|
if (!t)
|
|
20932
20932
|
return "draft-7";
|
|
@@ -20968,7 +20968,7 @@ function parseWithCompat(schema, data) {
|
|
|
20968
20968
|
return result.data;
|
|
20969
20969
|
}
|
|
20970
20970
|
|
|
20971
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
20971
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
|
|
20972
20972
|
var DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
|
|
20973
20973
|
var Protocol = class {
|
|
20974
20974
|
constructor(_options) {
|
|
@@ -21009,6 +21009,9 @@ var Protocol = class {
|
|
|
21009
21009
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
21010
21010
|
const handleTaskResult = async () => {
|
|
21011
21011
|
const taskId = request.params.taskId;
|
|
21012
|
+
if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
|
|
21013
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
21014
|
+
}
|
|
21012
21015
|
if (this._taskMessageQueue) {
|
|
21013
21016
|
let queuedMessage;
|
|
21014
21017
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -21039,12 +21042,12 @@ var Protocol = class {
|
|
|
21039
21042
|
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
21040
21043
|
}
|
|
21041
21044
|
if (!isTerminal(task.status)) {
|
|
21042
|
-
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
21045
|
+
await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
|
|
21043
21046
|
return await handleTaskResult();
|
|
21044
21047
|
}
|
|
21045
21048
|
if (isTerminal(task.status)) {
|
|
21046
21049
|
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
21047
|
-
this._clearTaskQueue(taskId);
|
|
21050
|
+
this._clearTaskQueue(taskId, extra.sessionId);
|
|
21048
21051
|
return {
|
|
21049
21052
|
...result,
|
|
21050
21053
|
_meta: {
|
|
@@ -21081,7 +21084,7 @@ var Protocol = class {
|
|
|
21081
21084
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
21082
21085
|
}
|
|
21083
21086
|
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
21084
|
-
this._clearTaskQueue(request.params.taskId);
|
|
21087
|
+
this._clearTaskQueue(request.params.taskId, extra.sessionId);
|
|
21085
21088
|
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
21086
21089
|
if (!cancelledTask) {
|
|
21087
21090
|
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
@@ -21209,6 +21212,19 @@ var Protocol = class {
|
|
|
21209
21212
|
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
21210
21213
|
const capturedTransport = this._transport;
|
|
21211
21214
|
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
21215
|
+
const sessionId = capturedTransport?.sessionId;
|
|
21216
|
+
const store = this._taskStore;
|
|
21217
|
+
let relatedTaskFound = true;
|
|
21218
|
+
let relatedTaskLookup;
|
|
21219
|
+
if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
|
|
21220
|
+
relatedTaskFound = false;
|
|
21221
|
+
relatedTaskLookup = (async () => {
|
|
21222
|
+
if (!await store.getTask(relatedTaskId, sessionId)) {
|
|
21223
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
|
|
21224
|
+
}
|
|
21225
|
+
relatedTaskFound = true;
|
|
21226
|
+
})();
|
|
21227
|
+
}
|
|
21212
21228
|
if (handler === void 0) {
|
|
21213
21229
|
const errorResponse = {
|
|
21214
21230
|
jsonrpc: "2.0",
|
|
@@ -21218,7 +21234,10 @@ var Protocol = class {
|
|
|
21218
21234
|
message: "Method not found"
|
|
21219
21235
|
}
|
|
21220
21236
|
};
|
|
21221
|
-
if (relatedTaskId &&
|
|
21237
|
+
if (relatedTaskId && relatedTaskLookup) {
|
|
21238
|
+
const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
|
|
21239
|
+
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error2) => this._onerror(new Error(`Failed to send an error response: ${error2}`)));
|
|
21240
|
+
} else if (relatedTaskId && this._taskMessageQueue) {
|
|
21222
21241
|
this._enqueueTaskMessage(relatedTaskId, {
|
|
21223
21242
|
type: "error",
|
|
21224
21243
|
message: errorResponse,
|
|
@@ -21269,7 +21288,10 @@ var Protocol = class {
|
|
|
21269
21288
|
closeSSEStream: extra?.closeSSEStream,
|
|
21270
21289
|
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
21271
21290
|
};
|
|
21272
|
-
Promise.resolve().then(() => {
|
|
21291
|
+
(relatedTaskLookup ?? Promise.resolve()).then(() => {
|
|
21292
|
+
if (relatedTaskLookup && abortController.signal.aborted) {
|
|
21293
|
+
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
21294
|
+
}
|
|
21273
21295
|
if (taskCreationParams) {
|
|
21274
21296
|
this.assertTaskHandlerCapability(request.method);
|
|
21275
21297
|
}
|
|
@@ -21304,7 +21326,7 @@ var Protocol = class {
|
|
|
21304
21326
|
...error2["data"] !== void 0 && { data: error2["data"] }
|
|
21305
21327
|
}
|
|
21306
21328
|
};
|
|
21307
|
-
if (relatedTaskId && this._taskMessageQueue) {
|
|
21329
|
+
if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
|
|
21308
21330
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
21309
21331
|
type: "error",
|
|
21310
21332
|
message: errorResponse,
|
|
@@ -21784,7 +21806,7 @@ var Protocol = class {
|
|
|
21784
21806
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
21785
21807
|
}
|
|
21786
21808
|
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
21787
|
-
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
21809
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
|
|
21788
21810
|
}
|
|
21789
21811
|
/**
|
|
21790
21812
|
* Clears the message queue for a task and rejects any pending request resolvers.
|
|
@@ -21813,12 +21835,13 @@ var Protocol = class {
|
|
|
21813
21835
|
* Uses polling to check for updates at the task's configured poll interval.
|
|
21814
21836
|
* @param taskId The task ID to wait for
|
|
21815
21837
|
* @param signal Abort signal to cancel the wait
|
|
21838
|
+
* @param sessionId Session of the request that waits, passed to the task store
|
|
21816
21839
|
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
21817
21840
|
*/
|
|
21818
|
-
async _waitForTaskUpdate(taskId, signal) {
|
|
21841
|
+
async _waitForTaskUpdate(taskId, signal, sessionId) {
|
|
21819
21842
|
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
21820
21843
|
try {
|
|
21821
|
-
const task = await this._taskStore?.getTask(taskId);
|
|
21844
|
+
const task = await this._taskStore?.getTask(taskId, sessionId);
|
|
21822
21845
|
if (task?.pollInterval) {
|
|
21823
21846
|
interval = task.pollInterval;
|
|
21824
21847
|
}
|
|
@@ -21922,7 +21945,7 @@ function mergeCapabilities(base, additional) {
|
|
|
21922
21945
|
return result;
|
|
21923
21946
|
}
|
|
21924
21947
|
|
|
21925
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
21948
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
|
|
21926
21949
|
var import_ajv = __toESM(require_ajv(), 1);
|
|
21927
21950
|
var import_ajv_formats = __toESM(require_dist(), 1);
|
|
21928
21951
|
function createDefaultAjvInstance() {
|
|
@@ -21990,7 +22013,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
21990
22013
|
}
|
|
21991
22014
|
};
|
|
21992
22015
|
|
|
21993
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
22016
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
|
|
21994
22017
|
var ExperimentalServerTasks = class {
|
|
21995
22018
|
constructor(_server) {
|
|
21996
22019
|
this._server = _server;
|
|
@@ -22203,7 +22226,7 @@ var ExperimentalServerTasks = class {
|
|
|
22203
22226
|
}
|
|
22204
22227
|
};
|
|
22205
22228
|
|
|
22206
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
22229
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
|
|
22207
22230
|
function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
22208
22231
|
if (!requests) {
|
|
22209
22232
|
throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
@@ -22238,7 +22261,7 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
|
|
|
22238
22261
|
}
|
|
22239
22262
|
}
|
|
22240
22263
|
|
|
22241
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
22264
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
22242
22265
|
var Server = class extends Protocol {
|
|
22243
22266
|
/**
|
|
22244
22267
|
* Initializes this server with the given name and version information.
|
|
@@ -22609,7 +22632,7 @@ var Server = class extends Protocol {
|
|
|
22609
22632
|
}
|
|
22610
22633
|
};
|
|
22611
22634
|
|
|
22612
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
22635
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
|
|
22613
22636
|
var COMPLETABLE_SYMBOL = Symbol.for("mcp.completable");
|
|
22614
22637
|
function isCompletable(schema) {
|
|
22615
22638
|
return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
|
|
@@ -22623,7 +22646,7 @@ var McpZodTypeKind;
|
|
|
22623
22646
|
McpZodTypeKind2["Completable"] = "McpCompletable";
|
|
22624
22647
|
})(McpZodTypeKind || (McpZodTypeKind = {}));
|
|
22625
22648
|
|
|
22626
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
22649
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
|
|
22627
22650
|
var TOOL_NAME_REGEX = /^[A-Za-z0-9._-]{1,128}$/;
|
|
22628
22651
|
function validateToolName(name) {
|
|
22629
22652
|
const warnings = [];
|
|
@@ -22681,7 +22704,7 @@ function validateAndWarnToolName(name) {
|
|
|
22681
22704
|
return result.isValid;
|
|
22682
22705
|
}
|
|
22683
22706
|
|
|
22684
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
22707
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
|
|
22685
22708
|
var ExperimentalMcpServerTasks = class {
|
|
22686
22709
|
constructor(_mcpServer) {
|
|
22687
22710
|
this._mcpServer = _mcpServer;
|
|
@@ -22696,7 +22719,43 @@ var ExperimentalMcpServerTasks = class {
|
|
|
22696
22719
|
}
|
|
22697
22720
|
};
|
|
22698
22721
|
|
|
22699
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
22722
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
|
|
22723
|
+
function toolInputElementCount(value, max) {
|
|
22724
|
+
let count = 0;
|
|
22725
|
+
const stack = [value];
|
|
22726
|
+
while (stack.length > 0) {
|
|
22727
|
+
const node = stack.pop();
|
|
22728
|
+
if (node === null || typeof node !== "object")
|
|
22729
|
+
continue;
|
|
22730
|
+
if (Array.isArray(node)) {
|
|
22731
|
+
for (const child of node) {
|
|
22732
|
+
if (++count > max)
|
|
22733
|
+
return count;
|
|
22734
|
+
if (child !== null && typeof child === "object")
|
|
22735
|
+
stack.push(child);
|
|
22736
|
+
}
|
|
22737
|
+
} else {
|
|
22738
|
+
for (const key in node) {
|
|
22739
|
+
if (!Object.prototype.hasOwnProperty.call(node, key))
|
|
22740
|
+
continue;
|
|
22741
|
+
if (++count > max)
|
|
22742
|
+
return count;
|
|
22743
|
+
const child = node[key];
|
|
22744
|
+
if (child !== null && typeof child === "object")
|
|
22745
|
+
stack.push(child);
|
|
22746
|
+
}
|
|
22747
|
+
}
|
|
22748
|
+
}
|
|
22749
|
+
return count;
|
|
22750
|
+
}
|
|
22751
|
+
function resolveMaxToolInputElements(value) {
|
|
22752
|
+
if (value === void 0 || value === Infinity)
|
|
22753
|
+
return void 0;
|
|
22754
|
+
if (typeof value !== "number" || Number.isNaN(value) || value < 1) {
|
|
22755
|
+
throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(value)}`);
|
|
22756
|
+
}
|
|
22757
|
+
return value;
|
|
22758
|
+
}
|
|
22700
22759
|
var McpServer = class {
|
|
22701
22760
|
constructor(serverInfo, options) {
|
|
22702
22761
|
this._registeredResources = {};
|
|
@@ -22708,6 +22767,7 @@ var McpServer = class {
|
|
|
22708
22767
|
this._resourceHandlersInitialized = false;
|
|
22709
22768
|
this._promptHandlersInitialized = false;
|
|
22710
22769
|
this.server = new Server(serverInfo, options);
|
|
22770
|
+
this._maxToolInputElements = resolveMaxToolInputElements(options?.maxToolInputElements);
|
|
22711
22771
|
}
|
|
22712
22772
|
/**
|
|
22713
22773
|
* Access experimental features.
|
|
@@ -22838,12 +22898,15 @@ var McpServer = class {
|
|
|
22838
22898
|
* Validates tool input arguments against the tool's input schema.
|
|
22839
22899
|
*/
|
|
22840
22900
|
async validateToolInput(tool, args, toolName) {
|
|
22901
|
+
if (this._maxToolInputElements !== void 0 && toolInputElementCount(args, this._maxToolInputElements) > this._maxToolInputElements) {
|
|
22902
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for tool ${toolName}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);
|
|
22903
|
+
}
|
|
22841
22904
|
if (!tool.inputSchema) {
|
|
22842
22905
|
return void 0;
|
|
22843
22906
|
}
|
|
22844
22907
|
const inputObj = normalizeObjectSchema(tool.inputSchema);
|
|
22845
22908
|
const schemaToParse = inputObj ?? tool.inputSchema;
|
|
22846
|
-
const parseResult = await safeParseAsync3(schemaToParse, args);
|
|
22909
|
+
const parseResult = await safeParseAsync3(schemaToParse, args ?? {});
|
|
22847
22910
|
if (!parseResult.success) {
|
|
22848
22911
|
const error2 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
22849
22912
|
const errorMessage = getParseErrorMessage(error2);
|
|
@@ -23081,7 +23144,7 @@ var McpServer = class {
|
|
|
23081
23144
|
}
|
|
23082
23145
|
if (prompt.argsSchema) {
|
|
23083
23146
|
const argsObj = normalizeObjectSchema(prompt.argsSchema);
|
|
23084
|
-
const parseResult = await safeParseAsync3(argsObj, request.params.arguments);
|
|
23147
|
+
const parseResult = await safeParseAsync3(argsObj, request.params.arguments ?? {});
|
|
23085
23148
|
if (!parseResult.success) {
|
|
23086
23149
|
const error2 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
23087
23150
|
const errorMessage = getParseErrorMessage(error2);
|
|
@@ -23935,6 +23998,11 @@ var TOOL_META = {
|
|
|
23935
23998
|
get_task: { annotations: READ, outputSchema: CONTEXT_SCHEMA },
|
|
23936
23999
|
get_task_spec: { annotations: READ },
|
|
23937
24000
|
list_tasks: { annotations: READ, outputSchema: TASKS_OUTPUT },
|
|
24001
|
+
list_task_templates: { annotations: READ },
|
|
24002
|
+
list_recycled_tasks: { annotations: READ, outputSchema: PAGE_OUTPUT },
|
|
24003
|
+
delete_task: { annotations: write(true, false) },
|
|
24004
|
+
restore_task: { annotations: write(false, false) },
|
|
24005
|
+
purge_task: { annotations: write(true, false) },
|
|
23938
24006
|
browse_tasks: { annotations: READ, outputSchema: BROWSE_OUTPUT },
|
|
23939
24007
|
list_ready_tasks: { annotations: READ, outputSchema: TASKS_OUTPUT },
|
|
23940
24008
|
list_projects: { annotations: READ, outputSchema: PAGE_OUTPUT },
|
|
@@ -24025,6 +24093,10 @@ var BROWSE_MAX_PROJECTS = 50;
|
|
|
24025
24093
|
var STATUS_CATEGORIES = ["backlog", "unstarted", "started", "blocked", "review", "done", "canceled"];
|
|
24026
24094
|
var WORK_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
24027
24095
|
"begin_task",
|
|
24096
|
+
"list_recycled_tasks",
|
|
24097
|
+
"delete_task",
|
|
24098
|
+
"restore_task",
|
|
24099
|
+
"purge_task",
|
|
24028
24100
|
"finish_task_work",
|
|
24029
24101
|
"get_task_context",
|
|
24030
24102
|
// 不知道任务编号时找活的入口(IMMO-221):只读、有界、只回摘要。list_projects / list_tasks
|
|
@@ -24933,6 +25005,52 @@ ${JSON.stringify(receipt)}`),
|
|
|
24933
25005
|
);
|
|
24934
25006
|
}
|
|
24935
25007
|
}),
|
|
25008
|
+
defineTool({
|
|
25009
|
+
name: "delete_task",
|
|
25010
|
+
description: "\u5C06\u4EFB\u52A1\u79FB\u5165\u9879\u76EE\u56DE\u6536\u7AD9\uFF0C\u91CA\u653E\u7F16\u53F7\u4F9B\u65B0\u4EFB\u52A1\u590D\u7528\u3002\u5B50\u4EFB\u52A1\u4FDD\u7559\u5E76\u63D0\u5347\u4E3A\u6839\u4EFB\u52A1\uFF0C\u4F9D\u8D56\u5173\u7CFB\u79FB\u9664\uFF1B\u8BC4\u8BBA\u3001\u8BF4\u660E\u7248\u672C\u548C\u4EA4\u4ED8\u4FDD\u7559\u3002\u4ECD\u88AB\u9886\u53D6\u65F6\u987B\u5148\u91CA\u653E\u3002\u6309\u6388\u6743\u76F4\u63A5\u6267\u884C\u6216\u63D0\u4EA4\u5BA1\u6279\u3002",
|
|
25011
|
+
inputSchema: { task: external_exports.string().describe("\u4EFB\u52A1\u7F16\u53F7\u6216 UUID") },
|
|
25012
|
+
async handler(args) {
|
|
25013
|
+
const task = await resolveTaskRef(args.task);
|
|
25014
|
+
return reportWrite("\u4EFB\u52A1\u5DF2\u79FB\u5165\u9879\u76EE\u56DE\u6536\u7AD9", await client.task.delete.mutate({ taskId: task.id }));
|
|
25015
|
+
}
|
|
25016
|
+
}),
|
|
25017
|
+
defineTool({
|
|
25018
|
+
name: "list_recycled_tasks",
|
|
25019
|
+
description: "\u5206\u9875\u67E5\u770B\u9879\u76EE\u56DE\u6536\u7AD9\u3002formerKey \u4EC5\u4E3A\u5386\u53F2\u7F16\u53F7\uFF0C\u53EF\u80FD\u5DF2\u88AB\u590D\u7528\uFF1B\u6062\u590D\u3001\u5F7B\u5E95\u5220\u9664\u5FC5\u987B\u4F7F\u7528\u8FD4\u56DE\u7684\u4EFB\u52A1 UUID\u3002",
|
|
25020
|
+
inputSchema: { project: external_exports.string(), limit: external_exports.number().int().min(1).max(100).optional(), offset: external_exports.number().int().min(0).optional() },
|
|
25021
|
+
async handler(args) {
|
|
25022
|
+
const project = await resolveProject(args.project);
|
|
25023
|
+
const offset = args.offset ?? 0;
|
|
25024
|
+
const limit = args.limit ?? 50;
|
|
25025
|
+
const items = await client.task.recycle.query({ projectId: project.id, offset, limit });
|
|
25026
|
+
return json({ items, nextOffset: items.length === limit ? offset + limit : null });
|
|
25027
|
+
}
|
|
25028
|
+
}),
|
|
25029
|
+
defineTool({
|
|
25030
|
+
name: "restore_task",
|
|
25031
|
+
description: "\u6062\u590D\u56DE\u6536\u7AD9\u4EFB\u52A1\uFF0CUUID \u548C\u5386\u53F2\u5185\u5BB9\u4E0D\u53D8\uFF0C\u4F46\u5206\u914D\u6700\u65B0\u9012\u589E\u7F16\u53F7\u3002\u4E0D\u4F1A\u6062\u590D\u7236\u5B50\u5173\u7CFB\u6216\u4F9D\u8D56\u8FB9\u3002\u6309\u6388\u6743\u76F4\u63A5\u6267\u884C\u6216\u63D0\u4EA4\u5BA1\u6279\u3002",
|
|
25032
|
+
inputSchema: { task_id: external_exports.string().uuid().describe("\u56DE\u6536\u7AD9\u91CC\u7684 UUID\uFF0C\u4E0D\u53EF\u4F7F\u7528\u5DF2\u91CA\u653E\u7684\u65E7\u7F16\u53F7") },
|
|
25033
|
+
async handler(args) {
|
|
25034
|
+
return reportWrite("\u4EFB\u52A1\u5DF2\u6062\u590D\u5E76\u5206\u914D\u65B0\u7F16\u53F7", await client.task.restore.mutate({ taskId: args.task_id }));
|
|
25035
|
+
}
|
|
25036
|
+
}),
|
|
25037
|
+
defineTool({
|
|
25038
|
+
name: "purge_task",
|
|
25039
|
+
description: "\u4E0D\u53EF\u9006\u5730\u5F7B\u5E95\u5220\u9664\u56DE\u6536\u7AD9\u4EFB\u52A1\u53CA\u8BC4\u8BBA\u3001\u8BF4\u660E\u7248\u672C\u548C\u4EA4\u4ED8\u3002\u4EC5\u7BA1\u7406\u5458\u6216\u7ECF\u5176\u660E\u786E\u6388\u6743\u7684 Agent \u53EF\u7528\uFF1B\u4FDD\u7559\u5BA1\u8BA1\u4E8B\u4EF6\u53CA\u8FD0\u884C\u6210\u672C\u8BB0\u5F55\u3002\u5FC5\u987B\u660E\u786E\u786E\u8BA4\u3002",
|
|
25040
|
+
inputSchema: { task_id: external_exports.string().uuid(), confirm: external_exports.literal(true).describe("\u660E\u786E\u786E\u8BA4\u4E0D\u53EF\u6062\u590D") },
|
|
25041
|
+
async handler(args) {
|
|
25042
|
+
return reportWrite("\u56DE\u6536\u7AD9\u4EFB\u52A1\u5DF2\u5F7B\u5E95\u5220\u9664\uFF0C\u4E0D\u53EF\u6062\u590D", await client.task.purge.mutate({ taskId: args.task_id, confirm: args.confirm }));
|
|
25043
|
+
}
|
|
25044
|
+
}),
|
|
25045
|
+
defineTool({
|
|
25046
|
+
name: "list_task_templates",
|
|
25047
|
+
description: "\u5217\u51FA\u9879\u76EE\u53EF\u7528\u7684\u4EFB\u52A1\u6A21\u677F\uFF0C\u8FD4\u56DE\u6A21\u677F ID\u3001\u8BF4\u660E\u3001\u9A8C\u6536\u6807\u51C6\u548C\u9ED8\u8BA4\u5C5E\u6027\uFF1Bcreate_task \u4F7F\u7528 template_id \u5E94\u7528\u6A21\u677F\u3002",
|
|
25048
|
+
inputSchema: { project: external_exports.string().describe("\u9879\u76EE key\u3001uuid \u6216\u540D\u5B57") },
|
|
25049
|
+
async handler(args) {
|
|
25050
|
+
const project = await resolveProject(args.project);
|
|
25051
|
+
return json(await client.taskTemplate.list.query({ projectId: project.id }));
|
|
25052
|
+
}
|
|
25053
|
+
}),
|
|
24936
25054
|
defineTool({
|
|
24937
25055
|
name: "get_task",
|
|
24938
25056
|
description: "\u5B8C\u6574\u8BCA\u65AD\u8BFB\u53D6\uFF08full profile\uFF09\uFF1A\u63CF\u8FF0\u3001\u9A8C\u6536\u6807\u51C6\u3001\u72B6\u6001\u3001\u6307\u6D3E\u4EBA\u3001\u8BC4\u8BBA\u3001\u7236\u5B50\u5C42\u7EA7\u3001\u4F9D\u8D56\u5173\u7CFB\u3001\u6240\u5728\u51B2\u523A\uFF08\u542B\u8FD9\u4E00\u8F6E\u7684\u76EE\u6807\u548C\u622A\u6B62\uFF09\u3001\u5386\u53F2\u4E8B\u4EF6\u3001\u72B6\u6001\u53D8\u66F4\u8BB0\u5F55\uFF08statusHistory\uFF1A\u8C01\u3001\u4EC0\u4E48\u65F6\u5019\u3001\u4ECE\u4EC0\u4E48\u72B6\u6001\u6539\u6210\u4EC0\u4E48\u72B6\u6001\uFF0C\u4EBA\u548C Agent \u90FD\u5728\uFF09\u3001\u4EE5\u53CA\u5DF2\u7ECF\u5728\u5B83\u4E0A\u9762\u8DD1\u8FC7\u7684 Agent \u8FD0\u884C\u3002\u65E5\u5E38\u6267\u884C\u4F18\u5148\u7528 get_task_context\u3002",
|
|
@@ -24950,6 +25068,7 @@ ${JSON.stringify(receipt)}`),
|
|
|
24950
25068
|
inputSchema: {
|
|
24951
25069
|
title: external_exports.string().min(1).max(500),
|
|
24952
25070
|
project: external_exports.string().optional().describe("\u9879\u76EE key\u3001uuid \u6216\u540D\u5B57"),
|
|
25071
|
+
template_id: external_exports.string().uuid().optional().describe("\u9879\u76EE\u4EFB\u52A1\u6A21\u677F ID\uFF0C\u53EF\u901A\u8FC7 list_task_templates \u9009\u62E9"),
|
|
24953
25072
|
description: markdownSchema.optional(),
|
|
24954
25073
|
acceptance: acceptanceSchema.optional(),
|
|
24955
25074
|
plan: external_exports.object({
|
|
@@ -24973,6 +25092,7 @@ ${JSON.stringify(receipt)}`),
|
|
|
24973
25092
|
title: args.title,
|
|
24974
25093
|
descriptionMd: args.description,
|
|
24975
25094
|
acceptance: args.acceptance,
|
|
25095
|
+
templateId: args.template_id,
|
|
24976
25096
|
agentPlan: args.plan ? { notesMd: args.plan.notes, verification: args.plan.verification, refs: args.plan.refs } : void 0,
|
|
24977
25097
|
type: args.type ?? "task",
|
|
24978
25098
|
priority: args.priority ?? 0,
|