@slatesvideo/mcp-server 0.6.9 → 0.6.10
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/server.js +50 -24
- package/package.json +3 -3
package/dist/server.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
-
import { CallToolRequestSchema, ListToolsRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, McpError, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import { spawn } from 'node:child_process';
|
|
6
6
|
import { existsSync, readFileSync } from 'node:fs';
|
|
7
7
|
import { join, dirname } from 'node:path';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
|
-
import { z } from 'zod';
|
|
9
|
+
import { z } from 'zod/v3';
|
|
10
10
|
import { ALL_OPERATIONS, ARCHIVE_AFTER_DAYS, brainSkills, parseSkillMetadata, MODEL_CAPABILITIES, MODEL_FACTS, SlatesCloudClient, buildMcpInstructions, BRAIN_ROUTER, MY_BRAIN_TOPIC, ROUTER_NOTICE, archiveUnusedDaily, refreshServedBrain, myBrainPreload, noteUsed, APP_MANUAL, defaultContext, toolDefinitions, cachedLatestVersion, refreshLatestVersion, updateNotice, readMcpLauncher, setDesktopClientIdentity, } from '@slatesvideo/shared';
|
|
11
11
|
// Slates MCP server. Stdio transport. Wires every operation in
|
|
12
12
|
// @slatesvideo/shared as an MCP tool. Both the desktop server and the
|
|
@@ -216,8 +216,11 @@ function warn(message) {
|
|
|
216
216
|
* half-supports it must not hang the call.
|
|
217
217
|
*/
|
|
218
218
|
const ELICIT_TIMEOUT_MS = 60_000;
|
|
219
|
+
/** A decline or cancel back inside this came from the host's own policy, not from a person reading the question. */
|
|
220
|
+
const HUMAN_ANSWER_MS = 500;
|
|
221
|
+
/** The question is a form, so a host that declares only `url` elicitation counts as a host without elicitation. */
|
|
219
222
|
function clientSupportsElicitation() {
|
|
220
|
-
return !!server.getClientCapabilities()?.elicitation;
|
|
223
|
+
return !!server.getClientCapabilities()?.elicitation?.form;
|
|
221
224
|
}
|
|
222
225
|
/** Does this op actually have a `confirm` gate to satisfy? */
|
|
223
226
|
function opTakesConfirm(op) {
|
|
@@ -225,7 +228,14 @@ function opTakesConfirm(op) {
|
|
|
225
228
|
const shape = typeof def?.shape === 'function' ? def.shape() : undefined;
|
|
226
229
|
return !!shape && 'confirm' in shape;
|
|
227
230
|
}
|
|
231
|
+
/** The host advertised elicitation and has no such method: its text path is all this connection has. */
|
|
232
|
+
let elicitationFailed = false;
|
|
233
|
+
/**
|
|
234
|
+
* The user's answer, or null when no person gave one and the text path decides this call. Anything else that
|
|
235
|
+
* goes wrong is a no: a prompt nobody answered must never leave a model's `confirm` to spend alone.
|
|
236
|
+
*/
|
|
228
237
|
async function elicitConfirm(message) {
|
|
238
|
+
const asked = Date.now();
|
|
229
239
|
try {
|
|
230
240
|
const res = await server.elicitInput({
|
|
231
241
|
message,
|
|
@@ -234,21 +244,25 @@ async function elicitConfirm(message) {
|
|
|
234
244
|
properties: {
|
|
235
245
|
confirm: {
|
|
236
246
|
type: 'boolean',
|
|
237
|
-
title: '
|
|
238
|
-
description: 'Yes
|
|
247
|
+
title: 'Go ahead',
|
|
248
|
+
description: 'Yes does what the message above says, including any charge to the account.',
|
|
239
249
|
},
|
|
240
250
|
},
|
|
241
251
|
required: ['confirm'],
|
|
242
252
|
},
|
|
243
253
|
}, { timeout: ELICIT_TIMEOUT_MS });
|
|
244
|
-
if (res.action
|
|
245
|
-
return
|
|
246
|
-
|
|
254
|
+
if (res.action === 'accept')
|
|
255
|
+
return res.content?.confirm === true;
|
|
256
|
+
// Codex with approval policy "never" declines every form at once. Counting that as the user's no would
|
|
257
|
+
// leave its users unable to spend or delete at all.
|
|
258
|
+
return Date.now() - asked < HUMAN_ANSWER_MS ? null : false;
|
|
247
259
|
}
|
|
248
|
-
catch {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
260
|
+
catch (err) {
|
|
261
|
+
if (err instanceof McpError && err.code === ErrorCode.MethodNotFound) {
|
|
262
|
+
elicitationFailed = true;
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
return false;
|
|
252
266
|
}
|
|
253
267
|
}
|
|
254
268
|
// The guides this connection has read. One server process is one client session
|
|
@@ -303,9 +317,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
|
303
317
|
}, 5_000);
|
|
304
318
|
ticker.unref?.();
|
|
305
319
|
}
|
|
320
|
+
// 🚨 A MODEL'S `confirm: true` IS NOT THE USER'S YES. A prompt-injected agent can send it on its first
|
|
321
|
+
// call, so where the host can ask the user, the op runs without it and the gate below asks. On a host
|
|
322
|
+
// with no form elicitation, the CLI among them, nobody is asked: a spend there is the model's word and
|
|
323
|
+
// no one's approval, and the desktop's checks are all that stands behind it.
|
|
324
|
+
const canAskUser = opTakesConfirm(op) && clientSupportsElicitation() && !elicitationFailed;
|
|
325
|
+
const { confirm: agentConfirm, ...unconfirmed } = args;
|
|
326
|
+
const claimed = canAskUser && agentConfirm === true;
|
|
327
|
+
const runOp = (input) => op.run(input, { ...defaultContext(), signal: extra?.signal, guidesRead });
|
|
306
328
|
let result;
|
|
307
329
|
try {
|
|
308
|
-
result = await
|
|
330
|
+
result = await runOp(claimed ? unconfirmed : args);
|
|
309
331
|
}
|
|
310
332
|
finally {
|
|
311
333
|
if (ticker)
|
|
@@ -320,26 +342,30 @@ server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
|
320
342
|
// no `confirm` param at all. Eliciting there would ask the user to approve
|
|
321
343
|
// a spend that is not happening, on a read-only pre-flight quote, and then
|
|
322
344
|
// re-run the quote with a parameter it does not have.
|
|
323
|
-
|
|
345
|
+
//
|
|
346
|
+
// `confirm_sends_as_written` is the one clarification confirm answers: without this, a claimed confirm
|
|
347
|
+
// would come back the same clarification forever, with nobody asked.
|
|
348
|
+
if (canAskUser && (data?.requires_confirm === true || (claimed && data?.confirm_sends_as_written === true))) {
|
|
324
349
|
const answer = await elicitConfirm(typeof data.message === 'string' ? data.message : result.text);
|
|
350
|
+
if (answer === false) {
|
|
351
|
+
return {
|
|
352
|
+
content: [{ type: 'text', text: 'The user declined or did not answer, so nothing ran. Do not re-call without new instructions.' }],
|
|
353
|
+
};
|
|
354
|
+
}
|
|
325
355
|
if (answer === true) {
|
|
326
356
|
// A quote that carries a fingerprint (`slates_generate_from_shots`) is
|
|
327
357
|
// fired only with it: the user approved THAT quote, and a changed
|
|
328
358
|
// recipe must still refuse.
|
|
329
359
|
const fingerprint = typeof data.fingerprint === 'string' ? { fingerprint: data.fingerprint } : {};
|
|
330
|
-
result = await
|
|
331
|
-
...defaultContext(),
|
|
332
|
-
signal: extra?.signal,
|
|
333
|
-
guidesRead,
|
|
334
|
-
});
|
|
360
|
+
result = await runOp({ ...unconfirmed, ...fingerprint, confirm: true });
|
|
335
361
|
data = result.data;
|
|
336
362
|
}
|
|
337
|
-
else if (
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
363
|
+
else if (claimed) {
|
|
364
|
+
// null → no person answered, so this call stands as it would on a host with no elicitation: the
|
|
365
|
+
// model's own confirm and fingerprint run, and without a confirm the quote goes back to the model.
|
|
366
|
+
result = await runOp(args);
|
|
367
|
+
data = result.data;
|
|
341
368
|
}
|
|
342
|
-
// null → the host could not answer; the text path below still applies.
|
|
343
369
|
}
|
|
344
370
|
if (typeof data?.prompt_warning === 'string' && data.prompt_warning) {
|
|
345
371
|
warn(data.prompt_warning);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slatesvideo/mcp-server",
|
|
3
3
|
"mcpName": "io.github.EricDisero/slates",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.10",
|
|
5
5
|
"description": "MCP server for the Slates desktop app. Your AI agent (ChatGPT via Codex, Claude, Cursor, or another local MCP client) drives a local AI video studio: projects, characters, storyboards, image and video generation. Files land on disk.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
53
|
-
"@slatesvideo/shared": "^0.7.
|
|
54
|
-
"zod": "^
|
|
53
|
+
"@slatesvideo/shared": "^0.7.15",
|
|
54
|
+
"zod": "^4.6.7"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@anthropic-ai/mcpb": "^2.1.2",
|