@softure-ai/mcp-access 0.3.0 → 0.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/CHANGELOG.md +11 -0
- package/README.md +11 -1
- package/dist/index.js +1 -1
- package/dist/jobs/index.d.ts +1 -1
- package/dist/jobs/index.d.ts.map +1 -1
- package/dist/jobs/index.js +1 -1
- package/dist/jobs/index.js.map +1 -1
- package/dist/jobs/operation-tasks.d.ts +11 -4
- package/dist/jobs/operation-tasks.d.ts.map +1 -1
- package/dist/jobs/operation-tasks.js +5 -3
- package/dist/jobs/operation-tasks.js.map +1 -1
- package/dist/jobs/operations.d.ts +28 -7
- package/dist/jobs/operations.d.ts.map +1 -1
- package/dist/jobs/operations.js +27 -6
- package/dist/jobs/operations.js.map +1 -1
- package/module.json +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/jobs/index.ts +2 -0
- package/src/jobs/operation-tasks.ts +12 -7
- package/src/jobs/operations.ts +62 -17
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,17 @@ Newest first. Each version lists what changed for an app that uses `@softure-ai/
|
|
|
4
4
|
production, the version gets a line `verified in: <app>@<commit>` ([docs/05](../../docs/05-adoption-playbook.md),
|
|
5
5
|
"Definition of done"). Versions before the first one below are described in their GitHub Releases (`mcp-access@x.y.z`).
|
|
6
6
|
|
|
7
|
+
## 0.4.0
|
|
8
|
+
|
|
9
|
+
- Operation tools with a context getter (#990), in `@softure-ai/mcp-access/jobs`: `registerOperationStatusTool`,
|
|
10
|
+
`registerOperationCancelTool` and `registerOperationTasks` take `getContext: () => Promise<JobsContext>` instead of
|
|
11
|
+
`ctx`, resolved inside each call (never at registration, so listing the tools opens no database), with an optional
|
|
12
|
+
`config` for the tool descriptions (default: the English dictionary). The error sentences now come from the config
|
|
13
|
+
of the call. `getOperationErrorHints(config)` exports the hints for `mcp-access.operation_not_found` and
|
|
14
|
+
`mcp-access.operation_finished`, for an app that wraps `getOperation` or `cancelOperation` itself. `{ ctx }` works
|
|
15
|
+
as before. Migrate: an app that registered its own `get_operation` / `cancel_operation` around a per-call context
|
|
16
|
+
can drop them and pass `getContext` (README "Long operations").
|
|
17
|
+
|
|
7
18
|
## 0.3.0
|
|
8
19
|
|
|
9
20
|
- Long operations as MCP Tasks (#977), in `@softure-ai/mcp-access/jobs`: `startOperation` takes `taskRequest` (the
|
package/README.md
CHANGED
|
@@ -346,7 +346,17 @@ export async function createServer(identity: McpServerIdentity) {
|
|
|
346
346
|
"No operation with this id belongs to this account." No table of its own: an operation lives as long as its job
|
|
347
347
|
(`retention` of jobs).
|
|
348
348
|
- `getOperation` and `cancelOperation` are the same reads as functions; the texts are under `operations` in the
|
|
349
|
-
module dictionary, and `name`/`description` rename a tool.
|
|
349
|
+
module dictionary, and `name`/`description` rename a tool. An app that wraps them in tools of its own answers with
|
|
350
|
+
the module's sentences through `withToolErrors(work, { hints: getOperationErrorHints(ctx.config) })`.
|
|
351
|
+
- A server factory that resolves its context per call passes `getContext` instead of `ctx` (to
|
|
352
|
+
`registerOperationStatusTool`, `registerOperationCancelTool` and `registerOperationTasks`): it is called inside each
|
|
353
|
+
call, once, never at registration, so listing the tools opens no database. The error sentences come from the config
|
|
354
|
+
the call resolves; the tool description from `config` when given, else the built-in English dictionary.
|
|
355
|
+
|
|
356
|
+
```ts
|
|
357
|
+
registerOperationStatusTool(server, { getContext: () => getJobsContext(), config, identity, readResult });
|
|
358
|
+
registerOperationCancelTool(server, { getContext: () => getJobsContext(), config, identity });
|
|
359
|
+
```
|
|
350
360
|
|
|
351
361
|
#### As MCP Tasks
|
|
352
362
|
|
package/dist/index.js
CHANGED
|
@@ -45,7 +45,7 @@ export const API_TOKEN_RATE_LIMIT_BUCKETS = {
|
|
|
45
45
|
export const mcpAccess = defineModule({
|
|
46
46
|
manifest: {
|
|
47
47
|
id: MODULE_ID,
|
|
48
|
-
version: "0.
|
|
48
|
+
version: "0.4.0",
|
|
49
49
|
dependsOn: { security: "^0.2.0", auth: "^0.2.0", jobs: "^0.1.1?", ops: "^0.2.0?" },
|
|
50
50
|
dbSchema: "mcp",
|
|
51
51
|
tables: ["access_tokens", "oauth_clients", "oauth_authorization_codes", "oauth_grants", "oauth_registration_window", "used_confirmations", "operation_tasks"],
|
package/dist/jobs/index.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ export declare const mcpAccessJobSchedules: {
|
|
|
9
9
|
every: string;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export { cancelOperation, getOperation, getOperationStatus, getPollAfterSeconds, MAX_OPERATION_DEDUP_KEY_LENGTH, OPERATION_CANCEL_TOOL_NAME, OPERATION_ORIGIN, OPERATION_STATUS_TOOL_NAME, OPERATION_STATUSES, registerOperationCancelTool, registerOperationStatusTool, startOperation, type GetOperationOptions, type OperationAnswer, type OperationCancelToolOptions, type OperationErrorCode, type OperationJob, type OperationPollOptions, type OperationStatus, type OperationStatusToolOptions, type ReadOperationResult, type StartOperationInput, } from "./operations.js";
|
|
12
|
+
export { cancelOperation, getOperation, getOperationErrorHints, getOperationStatus, getPollAfterSeconds, MAX_OPERATION_DEDUP_KEY_LENGTH, OPERATION_CANCEL_TOOL_NAME, OPERATION_ORIGIN, OPERATION_STATUS_TOOL_NAME, OPERATION_STATUSES, registerOperationCancelTool, registerOperationStatusTool, startOperation, type GetOperationOptions, type OperationAnswer, type OperationCancelToolOptions, type OperationErrorCode, type OperationJob, type OperationPollOptions, type OperationStatus, type OperationStatusToolOptions, type OperationToolContext, type ReadOperationResult, type StartOperationInput, } from "./operations.js";
|
|
13
13
|
export { DEFAULT_TASK_TTL_SECONDS, getOperationTask, isTasksRequest, MAX_TASK_TTL_SECONDS, MIN_TASK_TTL_SECONDS, registerOperationTasks, TASKS_EXTENSION, type OperationTask, type OperationTaskRequest, type OperationTasksOptions, type OperationTaskStatus, } from "./operation-tasks.js";
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/jobs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jobs/index.ts"],"names":[],"mappings":"AAQA,wEAAwE;AACxE,eAAO,MAAM,oBAAoB;IAC/B,+EAA+E;;CAQ1D,CAAC;AAExB,gFAAgF;AAChF,eAAO,MAAM,qBAAqB;;;;CAEL,CAAC;AAE9B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,8BAA8B,EAC9B,0BAA0B,EAC1B,gBAAgB,EAChB,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC3B,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jobs/index.ts"],"names":[],"mappings":"AAQA,wEAAwE;AACxE,eAAO,MAAM,oBAAoB;IAC/B,+EAA+E;;CAQ1D,CAAC;AAExB,gFAAgF;AAChF,eAAO,MAAM,qBAAqB;;;;CAEL,CAAC;AAE9B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,8BAA8B,EAC9B,0BAA0B,EAC1B,gBAAgB,EAChB,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC3B,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,sBAAsB,CAAC"}
|
package/dist/jobs/index.js
CHANGED
|
@@ -20,6 +20,6 @@ export const mcpAccessJobHandlers = {
|
|
|
20
20
|
export const mcpAccessJobSchedules = {
|
|
21
21
|
"mcp-access.prune": { every: "1d" },
|
|
22
22
|
};
|
|
23
|
-
export { cancelOperation, getOperation, getOperationStatus, getPollAfterSeconds, MAX_OPERATION_DEDUP_KEY_LENGTH, OPERATION_CANCEL_TOOL_NAME, OPERATION_ORIGIN, OPERATION_STATUS_TOOL_NAME, OPERATION_STATUSES, registerOperationCancelTool, registerOperationStatusTool, startOperation, } from "./operations.js";
|
|
23
|
+
export { cancelOperation, getOperation, getOperationErrorHints, getOperationStatus, getPollAfterSeconds, MAX_OPERATION_DEDUP_KEY_LENGTH, OPERATION_CANCEL_TOOL_NAME, OPERATION_ORIGIN, OPERATION_STATUS_TOOL_NAME, OPERATION_STATUSES, registerOperationCancelTool, registerOperationStatusTool, startOperation, } from "./operations.js";
|
|
24
24
|
export { DEFAULT_TASK_TTL_SECONDS, getOperationTask, isTasksRequest, MAX_TASK_TTL_SECONDS, MIN_TASK_TTL_SECONDS, registerOperationTasks, TASKS_EXTENSION, } from "./operation-tasks.js";
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
package/dist/jobs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/jobs/index.ts"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,kGAAkG;AAClG,6GAA6G;AAC7G,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAA4C,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wEAAwE;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,+EAA+E;IAC/E,kBAAkB,EAAE,gBAAgB,CAAC;QACnC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;QACrB,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE;YAC3B,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;YAC1B,OAAO,EAAE,EAAE,CAAC;QACd,CAAC;KACF,CAAC;CACmB,CAAC;AAExB,gFAAgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,kBAAkB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;CACR,CAAC;AAE9B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,8BAA8B,EAC9B,0BAA0B,EAC1B,gBAAgB,EAChB,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC3B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/jobs/index.ts"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,kGAAkG;AAClG,6GAA6G;AAC7G,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAA4C,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wEAAwE;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,+EAA+E;IAC/E,kBAAkB,EAAE,gBAAgB,CAAC;QACnC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;QACrB,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE;YAC3B,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;YAC1B,OAAO,EAAE,EAAE,CAAC;QACd,CAAC;KACF,CAAC;CACmB,CAAC;AAExB,gFAAgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,kBAAkB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;CACR,CAAC;AAE9B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,8BAA8B,EAC9B,0BAA0B,EAC1B,gBAAgB,EAChB,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC3B,cAAc,GAYf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,GAKhB,MAAM,sBAAsB,CAAC"}
|
|
@@ -30,14 +30,20 @@ export interface OperationTask {
|
|
|
30
30
|
readonly pollIntervalMs?: number;
|
|
31
31
|
readonly result?: CallToolResult;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
readonly ctx: JobsContext;
|
|
33
|
+
/** `ctx`, or `getContext` resolved inside each task request (see `OperationToolContext`). */
|
|
34
|
+
export type OperationTasksOptions = OperationTaskContext & {
|
|
36
35
|
/** The request's identity: a task is found only for its owner, and only a writer may cancel it. */
|
|
37
36
|
readonly identity: McpServerIdentity;
|
|
38
37
|
readonly readResult?: ReadOperationResult;
|
|
39
38
|
readonly poll?: OperationPollOptions;
|
|
40
|
-
}
|
|
39
|
+
};
|
|
40
|
+
type OperationTaskContext = {
|
|
41
|
+
readonly ctx: JobsContext;
|
|
42
|
+
readonly getContext?: never;
|
|
43
|
+
} | {
|
|
44
|
+
readonly ctx?: never;
|
|
45
|
+
readonly getContext: () => Promise<JobsContext>;
|
|
46
|
+
};
|
|
41
47
|
export interface AnswerOperationTaskInput {
|
|
42
48
|
readonly jobId: string;
|
|
43
49
|
readonly ttlSeconds?: number;
|
|
@@ -58,4 +64,5 @@ export declare function getOperationTask(ctx: JobsContext, identity: McpServerId
|
|
|
58
64
|
* `tasks/cancel` for the request's account. Register it on every server whose tools pass `taskRequest`.
|
|
59
65
|
*/
|
|
60
66
|
export declare function registerOperationTasks(server: McpServer, options: OperationTasksOptions): void;
|
|
67
|
+
export {};
|
|
61
68
|
//# sourceMappingURL=operation-tasks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-tasks.d.ts","sourceRoot":"","sources":["../../src/jobs/operation-tasks.ts"],"names":[],"mappings":"AAWA,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,OAAO,EAKL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACzB,MAAM,sBAAsB,CAAC;AAE9B,uHAAuH;AACvH,eAAO,MAAM,eAAe,kCAAkC,CAAC;AAC/D,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,oBAAoB,UAAY,CAAC;AAQ9C,+GAA+G;AAC/G,MAAM,WAAW,oBAAoB;IACnC,Q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,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC;CACtC;AAQD,yHAAyH;AACzH,wBAAgB,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAIrE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC,CAQjJ;AAED,oHAAoH;AACpH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,IAAI,CAAC,qBAAqB,EAAE,YAAY,GAAG,MAAM,CAAM,GAC/D,OAAO,CAAC,aAAa,GAAG,SAAS,GAAG,IAAI,CAAC,CAI3C;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,qBAAqB,GAAG,IAAI,CA6B9F"}
|
|
@@ -66,21 +66,23 @@ export async function getOperationTask(ctx, identity, taskId, options = {}) {
|
|
|
66
66
|
* `tasks/cancel` for the request's account. Register it on every server whose tools pass `taskRequest`.
|
|
67
67
|
*/
|
|
68
68
|
export function registerOperationTasks(server, options) {
|
|
69
|
-
const {
|
|
69
|
+
const { identity } = options;
|
|
70
|
+
const resolveContext = () => (options.getContext === undefined ? Promise.resolve(options.ctx) : options.getContext());
|
|
70
71
|
const describeOptions = { ...(options.readResult === undefined ? {} : { readResult: options.readResult }), ...(options.poll === undefined ? {} : { poll: options.poll }) };
|
|
71
72
|
server.server.registerCapabilities({ extensions: { [TASKS_EXTENSION]: {} } });
|
|
72
73
|
server.server.setRequestHandler("tasks/get", { params: taskIdParams, result: taskResult }, async ({ taskId }, request) => {
|
|
73
74
|
requireTasksCapability(request);
|
|
74
|
-
return { ...(await requireTask(
|
|
75
|
+
return { ...(await requireTask(await resolveContext(), identity, taskId, describeOptions)) };
|
|
75
76
|
});
|
|
76
77
|
// Operations never ask for input, so there is nothing to update; an owned task is acknowledged, as the spec asks.
|
|
77
78
|
server.server.setRequestHandler("tasks/update", { params: taskIdParams, result: taskResult }, async ({ taskId }, request) => {
|
|
78
79
|
requireTasksCapability(request);
|
|
79
|
-
await requireTask(
|
|
80
|
+
await requireTask(await resolveContext(), identity, taskId, describeOptions);
|
|
80
81
|
return {};
|
|
81
82
|
});
|
|
82
83
|
server.server.setRequestHandler("tasks/cancel", { params: taskIdParams, result: taskResult }, async ({ taskId }, request) => {
|
|
83
84
|
requireTasksCapability(request);
|
|
85
|
+
const ctx = await resolveContext();
|
|
84
86
|
const found = await findTask(ctx, identity, taskId);
|
|
85
87
|
if (found === null)
|
|
86
88
|
throw new ProtocolError(ProtocolErrorCode.InvalidParams, TASK_NOT_FOUND);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-tasks.js","sourceRoot":"","sources":["../../src/jobs/operation-tasks.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,wHAAwH;AACxH,iHAAiH;AACjH,EAAE;AACF,mGAAmG;AACnG,4EAA4E;AAC5E,sGAAsG;AACtG,EAAE;AACF,sHAAsH;AACtH,kHAAkH;AAClH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,4BAA4B,EAC5B,oCAAoC,EACpC,aAAa,EACb,iBAAiB,GAGlB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAoB,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CA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AQ,CAAC,SAAS,EAAE,CAAC;IACvG,4GAA4G;IAC5G,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACnG,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;AACjF,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { CallToolResult, McpServer } from "@modelcontextprotocol/server";
|
|
2
|
-
import { type Err, type Ok } from "@softure-ai/core";
|
|
2
|
+
import { type Err, type Ok, type SoftureConfig } from "@softure-ai/core";
|
|
3
3
|
import { type JobsContext } from "@softure-ai/jobs/server";
|
|
4
4
|
import type { McpServerIdentity } from "../contract.js";
|
|
5
|
+
import { type ToolErrorHints } from "../server/tools.js";
|
|
5
6
|
import { type OperationTaskRequest } from "./operation-tasks.js";
|
|
6
7
|
import { type GetOperationOptions, type OperationAnswer, type OperationErrorCode, type OperationPollOptions, type ReadOperationResult } from "./operation-state.js";
|
|
7
8
|
export { getOperationStatus, getPollAfterSeconds, MAX_OPERATION_DEDUP_KEY_LENGTH, OPERATION_CANCEL_TOOL_NAME, OPERATION_ORIGIN, OPERATION_STATUS_TOOL_NAME, OPERATION_STATUSES, type GetOperationOptions, type OperationAnswer, type OperationErrorCode, type OperationJob, type OperationPollOptions, type OperationStatus, type ReadOperationResult, } from "./operation-state.js";
|
|
@@ -27,27 +28,42 @@ export interface StartOperationInput {
|
|
|
27
28
|
/** How long a task can be read after it was created, in seconds. Default 86 400 (a day). */
|
|
28
29
|
readonly taskTtlSeconds?: number;
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Where an operation tool finds its `{ db, clock, config }`: the request's context as a value, or a getter resolved
|
|
33
|
+
* inside each call (for a server factory that opens the database per call, so registering and listing the tools
|
|
34
|
+
* opens nothing).
|
|
35
|
+
*/
|
|
36
|
+
export type OperationToolContext = {
|
|
31
37
|
/** `{ db, clock, config }` of the request. */
|
|
32
38
|
readonly ctx: JobsContext;
|
|
39
|
+
readonly getContext?: never;
|
|
40
|
+
readonly config?: never;
|
|
41
|
+
} | {
|
|
42
|
+
readonly ctx?: never;
|
|
43
|
+
/** Resolves `{ db, clock, config }` inside each call, once per call. */
|
|
44
|
+
readonly getContext: () => Promise<JobsContext>;
|
|
45
|
+
/** The app's config for the tool description at registration. Default: the built-in English dictionary. */
|
|
46
|
+
readonly config?: SoftureConfig;
|
|
47
|
+
};
|
|
48
|
+
type OperationToolOptions = OperationToolContext & {
|
|
33
49
|
/** The request's identity: operations are scoped to `identity.userId`. */
|
|
34
50
|
readonly identity: McpServerIdentity;
|
|
35
51
|
/** Default: the module dictionary's description. */
|
|
36
52
|
readonly description?: string;
|
|
37
|
-
}
|
|
38
|
-
export
|
|
53
|
+
};
|
|
54
|
+
export type OperationStatusToolOptions = OperationToolOptions & {
|
|
39
55
|
/** Default `get_operation`. */
|
|
40
56
|
readonly name?: string;
|
|
41
57
|
readonly readResult?: ReadOperationResult;
|
|
42
58
|
readonly poll?: OperationPollOptions;
|
|
43
|
-
}
|
|
44
|
-
export
|
|
59
|
+
};
|
|
60
|
+
export type OperationCancelToolOptions = OperationToolOptions & {
|
|
45
61
|
/** Default `cancel_operation`. */
|
|
46
62
|
readonly name?: string;
|
|
47
63
|
/** The status tool the answer points to. Default `get_operation`. */
|
|
48
64
|
readonly statusToolName?: string;
|
|
49
65
|
readonly poll?: OperationPollOptions;
|
|
50
|
-
}
|
|
66
|
+
};
|
|
51
67
|
/**
|
|
52
68
|
* For a tool handler: enqueues the operation's job and answers its id with the fixed sentence (ask the status tool,
|
|
53
69
|
* do not start again). Throws on an unknown queue or a dedup key over 150 characters (a bug in the caller); database
|
|
@@ -65,4 +81,9 @@ export declare function cancelOperation(ctx: JobsContext, identity: McpServerIde
|
|
|
65
81
|
export declare function registerOperationStatusTool(server: McpServer, options: OperationStatusToolOptions): void;
|
|
66
82
|
/** Registers the cancel tool (`cancel_operation`), a write: nothing is registered without `identity.canWrite`. */
|
|
67
83
|
export declare function registerOperationCancelTool(server: McpServer, options: OperationCancelToolOptions): void;
|
|
84
|
+
/**
|
|
85
|
+
* The module's sentences for the operation error codes, as `withToolErrors({ hints })` takes them: for an app that
|
|
86
|
+
* wraps `getOperation` or `cancelOperation` in tools of its own.
|
|
87
|
+
*/
|
|
88
|
+
export declare function getOperationErrorHints(config: SoftureConfig): ToolErrorHints;
|
|
68
89
|
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/jobs/operations.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAW,KAAK,GAAG,EAAE,KAAK,EAAE,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/jobs/operations.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAW,KAAK,GAAG,EAAE,KAAK,EAAE,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAgC,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxD,OAAO,EAA2C,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClG,OAAO,EAA6E,KAAK,oBAAoB,EA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AM,EACnB,OAAO,GAAE,IAAI,CAAC,mBAAmB,EAAE,YAAY,CAAM,GACpD,OAAO,CAAC,EAAE,CAAC,eAAe,CAAC,GAAG,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAMxD;AAED,uFAAuF;AACvF,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,0BAA0B,GAAG,IAAI,CAwBxG;AAED,kHAAkH;AAClH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,0BAA0B,GAAG,IAAI,CAqBxG;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,GAAG,cAAc,CAG5E"}
|
package/dist/jobs/operations.js
CHANGED
|
@@ -13,8 +13,9 @@ import { randomUUID } from "node:crypto";
|
|
|
13
13
|
import { err, ok } from "@softure-ai/core";
|
|
14
14
|
import { enqueueJob, requestJobCancel } from "@softure-ai/jobs/server";
|
|
15
15
|
import { z } from "zod";
|
|
16
|
+
import { mcpAccessMessages } from "../messages/index.js";
|
|
16
17
|
import { getMcpAccessMessages } from "../server/options.js";
|
|
17
|
-
import { toolResult, withToolErrors } from "../server/tools.js";
|
|
18
|
+
import { answerValue, toolResult, withToolErrors } from "../server/tools.js";
|
|
18
19
|
import { answerOperationTask, isTasksRequest, isTaskTtlValid, MAX_TASK_TTL_SECONDS } from "./operation-tasks.js";
|
|
19
20
|
import { describeOperation, fillToolName, findOwnedJob, getOwnerPrefix, getPollMin, MAX_OPERATION_DEDUP_KEY_LENGTH, OPERATION_ORIGIN, OPERATION_STATUS_TOOL_NAME, OPERATION_CANCEL_TOOL_NAME, } from "./operation-state.js";
|
|
20
21
|
export { getOperationStatus, getPollAfterSeconds, MAX_OPERATION_DEDUP_KEY_LENGTH, OPERATION_CANCEL_TOOL_NAME, OPERATION_ORIGIN, OPERATION_STATUS_TOOL_NAME, OPERATION_STATUSES, } from "./operation-state.js";
|
|
@@ -79,7 +80,7 @@ export async function cancelOperation(ctx, identity, operationId, options = {})
|
|
|
79
80
|
/** Registers the read-only status tool (`get_operation`) for the request's account. */
|
|
80
81
|
export function registerOperationStatusTool(server, options) {
|
|
81
82
|
const name = options.name ?? OPERATION_STATUS_TOOL_NAME;
|
|
82
|
-
const messages =
|
|
83
|
+
const messages = getRegistrationMessages(options);
|
|
83
84
|
const getOptions = {
|
|
84
85
|
statusToolName: name,
|
|
85
86
|
...(options.readResult === undefined ? {} : { readResult: options.readResult }),
|
|
@@ -89,22 +90,42 @@ export function registerOperationStatusTool(server, options) {
|
|
|
89
90
|
description: options.description ?? messages.statusToolDescription,
|
|
90
91
|
inputSchema: operationInput,
|
|
91
92
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
92
|
-
}, ({ operationId }) => withToolErrors(() =>
|
|
93
|
+
}, ({ operationId }) => withToolErrors(async () => {
|
|
94
|
+
const ctx = await resolveOperationContext(options);
|
|
95
|
+
return answerValue(await getOperation(ctx, options.identity, operationId, getOptions), getOperationErrorHints(ctx.config));
|
|
96
|
+
}, { label: name }));
|
|
93
97
|
}
|
|
94
98
|
/** Registers the cancel tool (`cancel_operation`), a write: nothing is registered without `identity.canWrite`. */
|
|
95
99
|
export function registerOperationCancelTool(server, options) {
|
|
96
100
|
if (!options.identity.canWrite)
|
|
97
101
|
return;
|
|
98
102
|
const name = options.name ?? OPERATION_CANCEL_TOOL_NAME;
|
|
99
|
-
const messages =
|
|
103
|
+
const messages = getRegistrationMessages(options);
|
|
100
104
|
const cancelOptions = { statusToolName: options.statusToolName ?? OPERATION_STATUS_TOOL_NAME, ...(options.poll === undefined ? {} : { poll: options.poll }) };
|
|
101
105
|
server.registerTool(name, {
|
|
102
106
|
description: options.description ?? messages.cancelToolDescription,
|
|
103
107
|
inputSchema: operationInput,
|
|
104
108
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
105
|
-
}, ({ operationId }) => withToolErrors(() =>
|
|
109
|
+
}, ({ operationId }) => withToolErrors(async () => {
|
|
110
|
+
const ctx = await resolveOperationContext(options);
|
|
111
|
+
return answerValue(await cancelOperation(ctx, options.identity, operationId, cancelOptions), getOperationErrorHints(ctx.config));
|
|
112
|
+
}, { label: name }));
|
|
106
113
|
}
|
|
107
|
-
|
|
114
|
+
/**
|
|
115
|
+
* The module's sentences for the operation error codes, as `withToolErrors({ hints })` takes them: for an app that
|
|
116
|
+
* wraps `getOperation` or `cancelOperation` in tools of its own.
|
|
117
|
+
*/
|
|
118
|
+
export function getOperationErrorHints(config) {
|
|
119
|
+
const messages = getMcpAccessMessages(config).operations;
|
|
108
120
|
return { "mcp-access.operation_not_found": messages.notFound, "mcp-access.operation_finished": messages.finished };
|
|
109
121
|
}
|
|
122
|
+
/** The context of this call: the value given, or the getter resolved now. */
|
|
123
|
+
function resolveOperationContext(source) {
|
|
124
|
+
return source.getContext === undefined ? Promise.resolve(source.ctx) : source.getContext();
|
|
125
|
+
}
|
|
126
|
+
/** The texts a registration needs before any call: from the context or config given, else the English dictionary. */
|
|
127
|
+
function getRegistrationMessages(source) {
|
|
128
|
+
const config = source.getContext === undefined ? source.ctx.config : source.config;
|
|
129
|
+
return config === undefined ? mcpAccessMessages.en.operations : getMcpAccessMessages(config).operations;
|
|
130
|
+
}
|
|
110
131
|
//# sourceMappingURL=operations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/jobs/operations.ts"],"names":[],"mappings":"AAAA,qHAAqH;AACrH,sHAAsH;AACtH,qHAAqH;AACrH,mCAAmC;AACnC,EAAE;AACF,6IAA6I;AAC7I,wGAAwG;AACxG,4DAA4D;AAC5D,EAAE;AACF,sHAAsH;AACtH,iFAAiF;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,GAAG,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/jobs/operations.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AAC,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC;AAC1G,CAAC"}
|
package/module.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "mcp-access",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"dependsOn": { "security": "^0.2.0", "auth": "^0.2.0", "jobs": "^0.1.1?", "ops": "^0.2.0?" },
|
|
5
5
|
"dbSchema": "mcp",
|
|
6
6
|
"tables": ["access_tokens", "oauth_clients", "oauth_authorization_codes", "oauth_grants", "oauth_registration_window", "used_confirmations", "operation_tasks"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softure-ai/mcp-access",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "SOFTURE AI MCP access module: hashed, scoped, expiring access tokens, a rate-limited Bearer endpoint around the app's MCP server factory, and a token page with client setup instructions for Next.js; tool result helpers with a safe error boundary, a stdio entry, a catalog parity check and the softure-mcp prune command.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/index.ts
CHANGED
|
@@ -51,7 +51,7 @@ export const API_TOKEN_RATE_LIMIT_BUCKETS = {
|
|
|
51
51
|
export const mcpAccess = defineModule({
|
|
52
52
|
manifest: {
|
|
53
53
|
id: MODULE_ID,
|
|
54
|
-
version: "0.
|
|
54
|
+
version: "0.4.0",
|
|
55
55
|
dependsOn: { security: "^0.2.0", auth: "^0.2.0", jobs: "^0.1.1?", ops: "^0.2.0?" },
|
|
56
56
|
dbSchema: "mcp",
|
|
57
57
|
tables: ["access_tokens", "oauth_clients", "oauth_authorization_codes", "oauth_grants", "oauth_registration_window", "used_confirmations", "operation_tasks"],
|
package/src/jobs/index.ts
CHANGED
|
@@ -26,6 +26,7 @@ export const mcpAccessJobSchedules = {
|
|
|
26
26
|
export {
|
|
27
27
|
cancelOperation,
|
|
28
28
|
getOperation,
|
|
29
|
+
getOperationErrorHints,
|
|
29
30
|
getOperationStatus,
|
|
30
31
|
getPollAfterSeconds,
|
|
31
32
|
MAX_OPERATION_DEDUP_KEY_LENGTH,
|
|
@@ -44,6 +45,7 @@ export {
|
|
|
44
45
|
type OperationPollOptions,
|
|
45
46
|
type OperationStatus,
|
|
46
47
|
type OperationStatusToolOptions,
|
|
48
|
+
type OperationToolContext,
|
|
47
49
|
type ReadOperationResult,
|
|
48
50
|
type StartOperationInput,
|
|
49
51
|
} from "./operations.js";
|
|
@@ -70,14 +70,17 @@ export interface OperationTask {
|
|
|
70
70
|
readonly result?: CallToolResult;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
readonly ctx: JobsContext;
|
|
73
|
+
/** `ctx`, or `getContext` resolved inside each task request (see `OperationToolContext`). */
|
|
74
|
+
export type OperationTasksOptions = OperationTaskContext & {
|
|
76
75
|
/** The request's identity: a task is found only for its owner, and only a writer may cancel it. */
|
|
77
76
|
readonly identity: McpServerIdentity;
|
|
78
77
|
readonly readResult?: ReadOperationResult;
|
|
79
78
|
readonly poll?: OperationPollOptions;
|
|
80
|
-
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
type OperationTaskContext =
|
|
82
|
+
| { readonly ctx: JobsContext; readonly getContext?: never }
|
|
83
|
+
| { readonly ctx?: never; readonly getContext: () => Promise<JobsContext> };
|
|
81
84
|
|
|
82
85
|
export interface AnswerOperationTaskInput {
|
|
83
86
|
readonly jobId: string;
|
|
@@ -133,24 +136,26 @@ export async function getOperationTask(
|
|
|
133
136
|
* `tasks/cancel` for the request's account. Register it on every server whose tools pass `taskRequest`.
|
|
134
137
|
*/
|
|
135
138
|
export function registerOperationTasks(server: McpServer, options: OperationTasksOptions): void {
|
|
136
|
-
const {
|
|
139
|
+
const { identity } = options;
|
|
140
|
+
const resolveContext = (): Promise<JobsContext> => (options.getContext === undefined ? Promise.resolve(options.ctx) : options.getContext());
|
|
137
141
|
const describeOptions = { ...(options.readResult === undefined ? {} : { readResult: options.readResult }), ...(options.poll === undefined ? {} : { poll: options.poll }) };
|
|
138
142
|
server.server.registerCapabilities({ extensions: { [TASKS_EXTENSION]: {} } });
|
|
139
143
|
|
|
140
144
|
server.server.setRequestHandler("tasks/get", { params: taskIdParams, result: taskResult }, async ({ taskId }, request) => {
|
|
141
145
|
requireTasksCapability(request);
|
|
142
|
-
return { ...(await requireTask(
|
|
146
|
+
return { ...(await requireTask(await resolveContext(), identity, taskId, describeOptions)) };
|
|
143
147
|
});
|
|
144
148
|
|
|
145
149
|
// Operations never ask for input, so there is nothing to update; an owned task is acknowledged, as the spec asks.
|
|
146
150
|
server.server.setRequestHandler("tasks/update", { params: taskIdParams, result: taskResult }, async ({ taskId }, request) => {
|
|
147
151
|
requireTasksCapability(request);
|
|
148
|
-
await requireTask(
|
|
152
|
+
await requireTask(await resolveContext(), identity, taskId, describeOptions);
|
|
149
153
|
return {};
|
|
150
154
|
});
|
|
151
155
|
|
|
152
156
|
server.server.setRequestHandler("tasks/cancel", { params: taskIdParams, result: taskResult }, async ({ taskId }, request) => {
|
|
153
157
|
requireTasksCapability(request);
|
|
158
|
+
const ctx = await resolveContext();
|
|
154
159
|
const found = await findTask(ctx, identity, taskId);
|
|
155
160
|
if (found === null) throw new ProtocolError(ProtocolErrorCode.InvalidParams, TASK_NOT_FOUND);
|
|
156
161
|
if (found === "expired") throw new ProtocolError(ProtocolErrorCode.InvalidParams, TASK_EXPIRED);
|
package/src/jobs/operations.ts
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
// keeps after the job ends. Any other job, or another account's, is "not found".
|
|
12
12
|
import { randomUUID } from "node:crypto";
|
|
13
13
|
import type { CallToolResult, McpServer } from "@modelcontextprotocol/server";
|
|
14
|
-
import { err, ok, type Err, type Ok } from "@softure-ai/core";
|
|
14
|
+
import { err, ok, type Err, type Ok, type SoftureConfig } from "@softure-ai/core";
|
|
15
15
|
import { enqueueJob, requestJobCancel, type JobsContext } from "@softure-ai/jobs/server";
|
|
16
16
|
import { z } from "zod";
|
|
17
17
|
import type { McpServerIdentity } from "../contract.js";
|
|
18
|
-
import type
|
|
18
|
+
import { mcpAccessMessages, type McpAccessMessages } from "../messages/index.js";
|
|
19
19
|
import { getMcpAccessMessages } from "../server/options.js";
|
|
20
|
-
import { toolResult, withToolErrors, type ToolErrorHints } from "../server/tools.js";
|
|
20
|
+
import { answerValue, toolResult, withToolErrors, type ToolErrorHints } from "../server/tools.js";
|
|
21
21
|
import { answerOperationTask, isTasksRequest, isTaskTtlValid, MAX_TASK_TTL_SECONDS, type OperationTaskRequest } from "./operation-tasks.js";
|
|
22
22
|
import {
|
|
23
23
|
describeOperation,
|
|
@@ -76,29 +76,47 @@ export interface StartOperationInput {
|
|
|
76
76
|
readonly taskTtlSeconds?: number;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Where an operation tool finds its `{ db, clock, config }`: the request's context as a value, or a getter resolved
|
|
81
|
+
* inside each call (for a server factory that opens the database per call, so registering and listing the tools
|
|
82
|
+
* opens nothing).
|
|
83
|
+
*/
|
|
84
|
+
export type OperationToolContext =
|
|
85
|
+
| {
|
|
86
|
+
/** `{ db, clock, config }` of the request. */
|
|
87
|
+
readonly ctx: JobsContext;
|
|
88
|
+
readonly getContext?: never;
|
|
89
|
+
readonly config?: never;
|
|
90
|
+
}
|
|
91
|
+
| {
|
|
92
|
+
readonly ctx?: never;
|
|
93
|
+
/** Resolves `{ db, clock, config }` inside each call, once per call. */
|
|
94
|
+
readonly getContext: () => Promise<JobsContext>;
|
|
95
|
+
/** The app's config for the tool description at registration. Default: the built-in English dictionary. */
|
|
96
|
+
readonly config?: SoftureConfig;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
type OperationToolOptions = OperationToolContext & {
|
|
82
100
|
/** The request's identity: operations are scoped to `identity.userId`. */
|
|
83
101
|
readonly identity: McpServerIdentity;
|
|
84
102
|
/** Default: the module dictionary's description. */
|
|
85
103
|
readonly description?: string;
|
|
86
|
-
}
|
|
104
|
+
};
|
|
87
105
|
|
|
88
|
-
export
|
|
106
|
+
export type OperationStatusToolOptions = OperationToolOptions & {
|
|
89
107
|
/** Default `get_operation`. */
|
|
90
108
|
readonly name?: string;
|
|
91
109
|
readonly readResult?: ReadOperationResult;
|
|
92
110
|
readonly poll?: OperationPollOptions;
|
|
93
|
-
}
|
|
111
|
+
};
|
|
94
112
|
|
|
95
|
-
export
|
|
113
|
+
export type OperationCancelToolOptions = OperationToolOptions & {
|
|
96
114
|
/** Default `cancel_operation`. */
|
|
97
115
|
readonly name?: string;
|
|
98
116
|
/** The status tool the answer points to. Default `get_operation`. */
|
|
99
117
|
readonly statusToolName?: string;
|
|
100
118
|
readonly poll?: OperationPollOptions;
|
|
101
|
-
}
|
|
119
|
+
};
|
|
102
120
|
|
|
103
121
|
const operationInput = z.object({ operationId: z.string().min(1).max(100) });
|
|
104
122
|
|
|
@@ -171,7 +189,7 @@ export async function cancelOperation(
|
|
|
171
189
|
/** Registers the read-only status tool (`get_operation`) for the request's account. */
|
|
172
190
|
export function registerOperationStatusTool(server: McpServer, options: OperationStatusToolOptions): void {
|
|
173
191
|
const name = options.name ?? OPERATION_STATUS_TOOL_NAME;
|
|
174
|
-
const messages =
|
|
192
|
+
const messages = getRegistrationMessages(options);
|
|
175
193
|
const getOptions: GetOperationOptions = {
|
|
176
194
|
statusToolName: name,
|
|
177
195
|
...(options.readResult === undefined ? {} : { readResult: options.readResult }),
|
|
@@ -185,7 +203,13 @@ export function registerOperationStatusTool(server: McpServer, options: Operatio
|
|
|
185
203
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
186
204
|
},
|
|
187
205
|
({ operationId }) =>
|
|
188
|
-
withToolErrors(
|
|
206
|
+
withToolErrors(
|
|
207
|
+
async () => {
|
|
208
|
+
const ctx = await resolveOperationContext(options);
|
|
209
|
+
return answerValue(await getOperation(ctx, options.identity, operationId, getOptions), getOperationErrorHints(ctx.config));
|
|
210
|
+
},
|
|
211
|
+
{ label: name },
|
|
212
|
+
),
|
|
189
213
|
);
|
|
190
214
|
}
|
|
191
215
|
|
|
@@ -193,7 +217,7 @@ export function registerOperationStatusTool(server: McpServer, options: Operatio
|
|
|
193
217
|
export function registerOperationCancelTool(server: McpServer, options: OperationCancelToolOptions): void {
|
|
194
218
|
if (!options.identity.canWrite) return;
|
|
195
219
|
const name = options.name ?? OPERATION_CANCEL_TOOL_NAME;
|
|
196
|
-
const messages =
|
|
220
|
+
const messages = getRegistrationMessages(options);
|
|
197
221
|
const cancelOptions = { statusToolName: options.statusToolName ?? OPERATION_STATUS_TOOL_NAME, ...(options.poll === undefined ? {} : { poll: options.poll }) };
|
|
198
222
|
server.registerTool(
|
|
199
223
|
name,
|
|
@@ -203,11 +227,32 @@ export function registerOperationCancelTool(server: McpServer, options: Operatio
|
|
|
203
227
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
204
228
|
},
|
|
205
229
|
({ operationId }) =>
|
|
206
|
-
withToolErrors(
|
|
230
|
+
withToolErrors(
|
|
231
|
+
async () => {
|
|
232
|
+
const ctx = await resolveOperationContext(options);
|
|
233
|
+
return answerValue(await cancelOperation(ctx, options.identity, operationId, cancelOptions), getOperationErrorHints(ctx.config));
|
|
234
|
+
},
|
|
235
|
+
{ label: name },
|
|
236
|
+
),
|
|
207
237
|
);
|
|
208
238
|
}
|
|
209
239
|
|
|
210
|
-
|
|
211
|
-
|
|
240
|
+
/**
|
|
241
|
+
* The module's sentences for the operation error codes, as `withToolErrors({ hints })` takes them: for an app that
|
|
242
|
+
* wraps `getOperation` or `cancelOperation` in tools of its own.
|
|
243
|
+
*/
|
|
244
|
+
export function getOperationErrorHints(config: SoftureConfig): ToolErrorHints {
|
|
245
|
+
const messages = getMcpAccessMessages(config).operations;
|
|
212
246
|
return { "mcp-access.operation_not_found": messages.notFound, "mcp-access.operation_finished": messages.finished };
|
|
213
247
|
}
|
|
248
|
+
|
|
249
|
+
/** The context of this call: the value given, or the getter resolved now. */
|
|
250
|
+
function resolveOperationContext(source: OperationToolContext): Promise<JobsContext> {
|
|
251
|
+
return source.getContext === undefined ? Promise.resolve(source.ctx) : source.getContext();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** The texts a registration needs before any call: from the context or config given, else the English dictionary. */
|
|
255
|
+
function getRegistrationMessages(source: OperationToolContext): McpAccessMessages["operations"] {
|
|
256
|
+
const config = source.getContext === undefined ? source.ctx.config : source.config;
|
|
257
|
+
return config === undefined ? mcpAccessMessages.en.operations : getMcpAccessMessages(config).operations;
|
|
258
|
+
}
|