@slatesvideo/mcp-server 0.6.15 → 0.6.17

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 CHANGED
@@ -75,7 +75,7 @@ No environment variables, no API keys to paste into config files.
75
75
 
76
76
  ## What the agent can do
77
77
 
78
- <!-- gen:tool-count -->236<!-- /gen:tool-count --> tools covering the full workspace: project, folder, character, location, look, and board management (create / update / delete), image generation and surgical image editing (<!-- gen:image-roster -->Nano Banana 2.1, GPT Image 2.6 Flare, GPT Image 2.6 Sunburst, FLUX 3 Image, Seedream 5.5<!-- /gen:image-roster --> — with project-asset reference images), video generation (<!-- gen:video-roster -->kling-v3.0-std, kling-v3.0-pro, kling-v3.0-omni, Seedance 2.0, Seedance 2.5, Gemini Omni Flash 1.2, Wan 3.0, Kling 4.0, MiniMax H3, MiniMax H3 Max, MiniMax H3 Max Turbo, LTX-2.5, LTX-2.5 Pro<!-- /gen:video-roster -->), audio generation (<!-- gen:audio-roster -->Seed Audio 1.0, ElevenLabs Sound Effects v2, Inworld Realtime TTS-2<!-- /gen:audio-roster -->), lip sync, motion transfer, background generation with status polling, timeline assembly (add / reorder / remove clips), MP4 export and FCP7 XML export for DaVinci Resolve, cost estimation, and credit balance. Bundled prompting/workflow guides are readable at runtime via the `slates_get_prompting_guide` tool — no skill installation needed for MCP-only clients.
78
+ <!-- gen:tool-count -->237<!-- /gen:tool-count --> tools covering the full workspace: project, folder, character, location, look, and board management (create / update / delete), image generation and surgical image editing (<!-- gen:image-roster -->Nano Banana 2.1, GPT Image 2.6 Flare, GPT Image 2.6 Sunburst, FLUX 3 Image, Seedream 5.5<!-- /gen:image-roster --> — with project-asset reference images), video generation (<!-- gen:video-roster -->kling-v3.0-std, kling-v3.0-pro, kling-v3.0-omni, Seedance 2.0, Seedance 2.5, Gemini Omni Flash 1.2, Wan 3.0, MAGI-2, Kling 4.0, MiniMax H3, MiniMax H3 Max, MiniMax H3 Max Turbo<!-- /gen:video-roster -->), audio generation (<!-- gen:audio-roster -->Seed Audio 1.0, ElevenLabs Sound Effects v2, Inworld Realtime TTS-2<!-- /gen:audio-roster -->), lip sync, motion transfer, background generation with status polling, timeline assembly (add / reorder / remove clips), MP4 export and FCP7 XML export for DaVinci Resolve, cost estimation, and credit balance. Bundled prompting/workflow guides are readable at runtime via the `slates_get_prompting_guide` tool — no skill installation needed for MCP-only clients.
79
79
 
80
80
  Generation tools estimate cost first and ask for confirmation on anything over <!-- gen:confirm-credits -->17<!-- /gen:confirm-credits --> credits, so the agent cannot silently burn credits. Every tool also carries MCP annotations, so a host can auto-approve a read and warn on a delete; the <!-- gen:skill-count -->53<!-- /gen:skill-count --> skills your Slates account opens are exposed as MCP **prompts**, and the manual, the model capability table and the live price list as **resources**.
81
81
 
@@ -0,0 +1,37 @@
1
+ import type { OperationResult, ToolDefinition } from '@slatesvideo/shared';
2
+ /**
3
+ * WHO ASKS THE USER BEFORE AN OP THAT TAKES `confirm` RUNS.
4
+ *
5
+ * A model's `confirm: true` is not the user's yes: a prompt-injected agent can
6
+ * send it on its first call. Where the host can show the user a form, the user
7
+ * is asked, and which side asks is read off the op's rendered schema:
8
+ *
9
+ * - `op-asks`: `confirm` is optional. The op run without it spends nothing and
10
+ * returns `requires_confirm` with its quote; the user answers that quote.
11
+ * - `server-asks`: `confirm` is required, so the op has no call that only
12
+ * quotes. The user is asked before it runs at all. Until 2026-11-24 these ran
13
+ * with the model's confirm stripped, expecting a quote the op never returns,
14
+ * so the two draft-finish ops spent credits with nobody asked.
15
+ * - `none`: no `confirm` input, nothing to ask (a quote op's `requires_confirm`
16
+ * is information about a later call).
17
+ */
18
+ export type ConfirmGate = 'none' | 'op-asks' | 'server-asks';
19
+ export declare function confirmGate(inputSchema: ToolDefinition['inputSchema']): ConfirmGate;
20
+ export declare const DECLINED_TEXT = "The user declined or did not answer, so nothing ran. Do not re-call without new instructions.";
21
+ export interface ConsentCall {
22
+ opId: string;
23
+ gate: ConfirmGate;
24
+ /** The parsed arguments the model sent. */
25
+ args: Record<string, unknown>;
26
+ /** Whether this host can put a form in front of the user right now. */
27
+ hostCanAsk: boolean;
28
+ /** Run the op; `patch` overrides fields of the parsed arguments for that run. */
29
+ run(patch?: Record<string, unknown>): Promise<OperationResult>;
30
+ /** The user's answer, or null when no person gave one and the model's own arguments stand. */
31
+ ask(message: string): Promise<boolean | null>;
32
+ }
33
+ /** Run one tool call with the user's consent where the host can ask for it. `declined` means nothing ran. */
34
+ export declare function runWithConsent(call: ConsentCall): Promise<OperationResult | {
35
+ declined: true;
36
+ }>;
37
+ //# sourceMappingURL=confirm-gate.d.ts.map
@@ -0,0 +1,54 @@
1
+ export function confirmGate(inputSchema) {
2
+ const properties = (inputSchema.properties ?? {});
3
+ if (!Object.hasOwn(properties, 'confirm'))
4
+ return 'none';
5
+ const required = Array.isArray(inputSchema.required) ? inputSchema.required : [];
6
+ return required.includes('confirm') ? 'server-asks' : 'op-asks';
7
+ }
8
+ export const DECLINED_TEXT = 'The user declined or did not answer, so nothing ran. Do not re-call without new instructions.';
9
+ /** The question for an op that cannot quote itself: its id and the ceiling the model sent. */
10
+ function serverQuestion(opId, args) {
11
+ const ceiling = typeof args.maxCredits === 'number' ? ` It may spend up to ${args.maxCredits} credits.` : '';
12
+ return `Slates is about to run ${opId}, which the assistant marked as approved by you.${ceiling} Go ahead?`;
13
+ }
14
+ /** Run one tool call with the user's consent where the host can ask for it. `declined` means nothing ran. */
15
+ export async function runWithConsent(call) {
16
+ const { gate, args, run, ask } = call;
17
+ if (gate === 'none' || !call.hostCanAsk)
18
+ return run();
19
+ if (gate === 'server-asks') {
20
+ if ((await ask(serverQuestion(call.opId, args))) === false)
21
+ return { declined: true };
22
+ return run();
23
+ }
24
+ // The op runs without the model's confirm, so its own gate quotes and the user answers the quote.
25
+ const claimed = args.confirm === true;
26
+ const first = await run(claimed ? { confirm: undefined } : undefined);
27
+ const data = first.data;
28
+ // `confirm_sends_as_written` is the one clarification confirm answers: without it, a claimed
29
+ // confirm would come back the same clarification forever, with nobody asked.
30
+ if (!(data?.requires_confirm === true || (claimed && data?.confirm_sends_as_written === true)))
31
+ return first;
32
+ const answer = await ask(typeof data.message === 'string' ? data.message : first.text);
33
+ if (answer === false)
34
+ return { declined: true };
35
+ if (answer === true) {
36
+ // A quote that carries a fingerprint (`slates_generate_from_shots`) is fired only with it: the
37
+ // user approved THAT quote, and a changed recipe must still refuse.
38
+ const fingerprint = typeof data.fingerprint === 'string' ? { fingerprint: data.fingerprint } : {};
39
+ // A quote that minted a request id (`slates_upscale_image`) is paid under that id: the
40
+ // confirmed run and any retry of it are then one run to the desktop.
41
+ const requestId = typeof data.requestId === 'string' ? { requestId: data.requestId } : {};
42
+ // The amount the user approved is the one the run is held to: the quote's own `approvedCredits`, never a
43
+ // figure the model put in its arguments, which is dropped when the quote names none. The op treats it as a
44
+ // ceiling and asks again if its price has since risen above it.
45
+ const approvedCredits = typeof data.approvedCredits === 'number'
46
+ ? { approvedCredits: data.approvedCredits }
47
+ : Object.hasOwn(args, 'approvedCredits') ? { approvedCredits: undefined } : {};
48
+ return run({ ...fingerprint, ...requestId, ...approvedCredits, confirm: true });
49
+ }
50
+ // null: no person answered, so this call stands as it would on a host with no elicitation. The
51
+ // model's own confirm and fingerprint run, and without a confirm the quote goes back to the model.
52
+ return claimed ? run() : first;
53
+ }
54
+ //# sourceMappingURL=confirm-gate.js.map
package/dist/server.js CHANGED
@@ -6,8 +6,8 @@ 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/v3';
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';
9
+ 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, prepareOperation, runOperation, toolDefinitions, cachedLatestVersion, refreshLatestVersion, updateNotice, readMcpLauncher, setDesktopClientIdentity, isDesktopDown, } from '@slatesvideo/shared';
10
+ import { DECLINED_TEXT, confirmGate, runWithConsent } from './confirm-gate.js';
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
13
13
  // cloud API are reached through env-discovered creds in
@@ -104,6 +104,8 @@ const server = new Server({ name: 'slates-studio', version: pkg.version }, {
104
104
  // Code and nothing measurable in Codex. Legacy --tools=compact and
105
105
  // --tools=flat flags remain accepted; every launch exposes the same full list.
106
106
  const TOOLS = toolDefinitions(ops, { surface: 'mcp' });
107
+ /** Who asks the user before each op runs, read off the same rendered schema the host was sent. */
108
+ const CONFIRM_GATES = new Map(TOOLS.map((tool) => [tool.name, confirmGate(tool.inputSchema)]));
107
109
  /**
108
110
  * Output schemas for the ops whose result shape is STABLE.
109
111
  *
@@ -180,32 +182,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
180
182
  ...(OUTPUT_SCHEMAS[t.name] ? { outputSchema: OUTPUT_SCHEMAS[t.name] } : {}),
181
183
  })),
182
184
  }));
183
- /**
184
- * Zod's default error is a JSON blob of issue objects. The model has to parse
185
- * prose out of it to learn that `aspectRatio` was the problem and what the
186
- * legal values are — so flatten to one line per issue, and print the legal set
187
- * whenever an enum was the thing that failed.
188
- */
189
- function flattenZodError(err) {
190
- return err.issues
191
- .map((issue) => {
192
- const path = issue.path.length > 0 ? issue.path.join('.') : '(root)';
193
- if (issue.code === 'invalid_enum_value') {
194
- const legal = issue.options ?? [];
195
- return `${path}: ${issue.message}. Legal values: ${legal.join(', ')}`;
196
- }
197
- if (issue.code === 'unrecognized_keys') {
198
- const keys = issue.keys ?? [];
199
- return `${path}: unknown parameter(s) ${keys.join(', ')} — check the tool schema`;
200
- }
201
- return `${path}: ${issue.message}`;
202
- })
203
- .join('\n');
204
- }
205
- /** Fire-and-forget: a host that has not enabled logging must not break a call. */
185
+ /** Fire-and-forget. The SDK drops it below the level the host asked for, and a failed send must not break a call. */
206
186
  function warn(message) {
207
- if (!server.getClientCapabilities()?.['logging'])
208
- return;
209
187
  void server.sendLoggingMessage({ level: 'warning', logger: 'slates', data: message }).catch(() => { });
210
188
  }
211
189
  /**
@@ -222,12 +200,6 @@ const HUMAN_ANSWER_MS = 500;
222
200
  function clientSupportsElicitation() {
223
201
  return !!server.getClientCapabilities()?.elicitation?.form;
224
202
  }
225
- /** Does this op actually have a `confirm` gate to satisfy? */
226
- function opTakesConfirm(op) {
227
- const def = op.input._def;
228
- const shape = typeof def?.shape === 'function' ? def.shape() : undefined;
229
- return !!shape && 'confirm' in shape;
230
- }
231
203
  /** The host advertised elicitation and has no such method: its text path is all this connection has. */
232
204
  let elicitationFailed = false;
233
205
  /**
@@ -278,24 +250,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
278
250
  };
279
251
  }
280
252
  try {
281
- let args;
282
- try {
283
- args = op.input.parse(request.params.arguments ?? {});
284
- }
285
- catch (err) {
286
- if (err instanceof z.ZodError) {
287
- return {
288
- content: [
289
- {
290
- type: 'text',
291
- text: `Invalid arguments for ${op.id}:\n${flattenZodError(err)}`,
292
- },
293
- ],
294
- isError: true,
295
- };
296
- }
297
- throw err;
298
- }
253
+ const prepared = prepareOperation(op, request.params.arguments);
254
+ if (!prepared.ok)
255
+ return { content: [{ type: 'text', text: prepared.message }], isError: true };
256
+ const { call } = prepared;
257
+ const args = call.input;
299
258
  // Progress notifications: a background render is invisible to the host
300
259
  // until the model polls. When the client sent a progress token, tick while
301
260
  // the long-poll is in flight so the host can show something moving.
@@ -317,56 +276,27 @@ server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
317
276
  }, 5_000);
318
277
  ticker.unref?.();
319
278
  }
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 });
328
- let result;
279
+ // On a host with no form elicitation, the CLI among them, nobody is asked: a spend there is the model's
280
+ // word and no one's approval, and the desktop's checks are all that stands behind it.
281
+ let outcome;
329
282
  try {
330
- result = await runOp(claimed ? unconfirmed : args);
283
+ outcome = await runWithConsent({
284
+ opId: op.id,
285
+ gate: CONFIRM_GATES.get(op.id) ?? 'none',
286
+ args: args,
287
+ hostCanAsk: clientSupportsElicitation() && !elicitationFailed,
288
+ run: (patch) => call.run({ ...defaultContext(), signal: extra?.signal, guidesRead }, patch),
289
+ ask: elicitConfirm,
290
+ });
331
291
  }
332
292
  finally {
333
293
  if (ticker)
334
294
  clearInterval(ticker);
335
295
  }
296
+ if ('declined' in outcome)
297
+ return { content: [{ type: 'text', text: DECLINED_TEXT }] };
298
+ const result = outcome;
336
299
  let data = result.data;
337
- // The one place the server can ask the USER instead of the model.
338
- //
339
- // 🚨 GATED ON THE OP HAVING A `confirm` INPUT, not merely on the flag.
340
- // `slates_estimate_generation_cost` returns `requires_confirm: true` as
341
- // INFORMATION — "the generation this quotes will trip the gate" — and takes
342
- // no `confirm` param at all. Eliciting there would ask the user to approve
343
- // a spend that is not happening, on a read-only pre-flight quote, and then
344
- // re-run the quote with a parameter it does not have.
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))) {
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
- }
355
- if (answer === true) {
356
- // A quote that carries a fingerprint (`slates_generate_from_shots`) is
357
- // fired only with it: the user approved THAT quote, and a changed
358
- // recipe must still refuse.
359
- const fingerprint = typeof data.fingerprint === 'string' ? { fingerprint: data.fingerprint } : {};
360
- result = await runOp({ ...unconfirmed, ...fingerprint, confirm: true });
361
- data = result.data;
362
- }
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;
368
- }
369
- }
370
300
  if (typeof data?.prompt_warning === 'string' && data.prompt_warning) {
371
301
  warn(data.prompt_warning);
372
302
  }
@@ -403,7 +333,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
403
333
  }
404
334
  catch (err) {
405
335
  const message = err instanceof Error ? err.message : String(err);
406
- if (/not reachable|is not running|AI tools|Agent Control/i.test(message))
336
+ if (isDesktopDown(err))
407
337
  warn(message);
408
338
  return {
409
339
  content: [{ type: 'text', text: `Error: ${message}` }],
@@ -567,7 +497,9 @@ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
567
497
  const op = opsById.get('slates_list_shots');
568
498
  if (!op)
569
499
  throw new Error('slates_list_shots is not registered');
570
- const r = await op.run({ projectId: decodeURIComponent(shots[1]) }, defaultContext());
500
+ const r = await runOperation(op, { projectId: decodeURIComponent(shots[1]) }, defaultContext());
501
+ if (r.invalid)
502
+ throw new Error(r.text);
571
503
  return JSON.stringify(r.data ?? {}, null, 2);
572
504
  }
573
505
  throw new Error(`Unknown resource: ${uri}`);
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.15",
4
+ "version": "0.6.17",
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,7 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@modelcontextprotocol/sdk": "^1.32.1",
53
- "@slatesvideo/shared": "^0.7.21",
53
+ "@slatesvideo/shared": "^0.7.23",
54
54
  "zod": "^4.6.7"
55
55
  },
56
56
  "devDependencies": {