@simpligen/mcp 0.5.0 → 0.5.1

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
@@ -22,7 +22,7 @@ The easiest path is in the SimpliGen app: **Settings -> Connect an agent**, pick
22
22
 
23
23
  `list_capabilities`, `get_status`, `list_projects`, `create_project`, `upload_file`, `generate`, `get_job`, `wait_for_result`, `list_jobs`, `cancel_job`, `prepare_preset`, `get_result_image`.
24
24
 
25
- **Video Studio** (connector 0.5.0 or newer): `list_films`, `create_film`, `get_film`, `update_film_settings`, `add_track`, `move_track`, `detect_tempo`, `add_clip`, `update_clip`, `move_clip`, `trim_clip`, `remove_clip`, `apply_film_plan`, `set_fades`, `add_marker`, `set_export_range`, `render_clips`, `wait_for_renders`, `list_takes`, `use_take`, `export_film`, `list_locations`, `create_location`. An agent can build a whole music video: a song, its tempo, clips on the bars, shots, renders and the export. With the film open in the Video Studio every change shows live and undoes with Ctrl+Z.
25
+ **Video Studio** (connector 0.5.0 or newer): `list_films`, `create_film`, `get_film`, `update_film_settings`, `add_track`, `move_track`, `detect_tempo`, `add_clip`, `update_clip`, `move_clip`, `trim_clip`, `remove_clip`, `apply_film_plan`, `set_fades`, `add_marker`, `set_export_range`, `render_clips`, `wait_for_renders`, `list_takes`, `use_take`, `export_film`, `list_locations`, `create_location`. An agent can build a whole music video: a song, its tempo, clips on the bars, shots, renders and the export. With the film open in the Video Studio every change shows live and undoes with Ctrl+Z. These tools are listed only when your SimpliGen has the Video Studio (connector 0.5.1 or newer, SimpliGen 1.75 or newer). If the agent starts before SimpliGen is running, they appear within a minute of SimpliGen starting; an agent app that does not refresh its tool list shows them after a restart.
26
26
 
27
27
  `get_result_image` returns a completed job's result image inline (a viewable image block) so the agent can display it in chat. Claude clients cap a tool result at ~1MB and only render base64 image blocks, so large renders are re-encoded to a **full-resolution WebP** preview (same dimensions; quality steps down, and only very large images are resized) that fits the cap. The uncompressed original file path is always included in the caption, so the agent keeps the full-quality artifact. Video results return the file path instead.
28
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpligen/mcp",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "MCP server for SimpliGen -- drive local/cloud AI image & video generation from an agent.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/bin.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  // packages/mcp-server/src/bin.js
3
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
4
  import { ControlApiClient } from './client.js';
@@ -7,6 +7,9 @@ import { createMcpServer } from './server.js';
7
7
  async function main() {
8
8
  const client = new ControlApiClient(); // resolves port (discovery file) + token (SIMPLIGEN_TOKEN)
9
9
  const server = createMcpServer(client);
10
+ // Whether the app holds the Video Studio decides which tools the client first sees.
11
+ // A closed app answers at once; a stuck one gets 3 s, then the poll takes over.
12
+ await Promise.race([server.studioGate.refresh(), new Promise((r) => setTimeout(r, 3000).unref())]);
10
13
  await server.connect(new StdioServerTransport());
11
14
  }
12
15
 
package/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // packages/mcp-server/src/index.js
2
2
  export { ControlApiClient, ControlApiError } from './client.js';
3
3
  export { createMcpServer } from './server.js';
4
- export { registerTools, TOOL_NAMES } from './tools.js';
4
+ export { registerTools, TOOL_NAMES, STUDIO_TOOL_NAMES } from './tools.js';
5
+ export { createStudioGate } from './studioGate.js';
5
6
  export { buildResultImageContent } from './resultImage.js';
6
7
  export { resolveUserDataDir, readDiscoveryPort } from './userdata.js';
package/src/server.js CHANGED
@@ -2,11 +2,23 @@
2
2
  import { createRequire } from 'node:module';
3
3
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
4
  import { registerTools } from './tools.js';
5
+ import { createStudioGate } from './studioGate.js';
5
6
 
6
7
  const { version } = createRequire(import.meta.url)('../package.json');
7
8
 
8
- export function createMcpServer(client) {
9
+ /**
10
+ * @param {object} client a ControlApiClient
11
+ * @param {{ studioPollMs?: number }} [options] how often to ask the app whether it holds the Video Studio
12
+ */
13
+ export function createMcpServer(client, { studioPollMs } = {}) {
9
14
  const server = new McpServer({ name: 'simpligen', version });
10
- registerTools(server, client);
15
+ let gate = null;
16
+ const { studioTools } = registerTools(server, client, { onStatus: (status) => gate?.observe(status) });
17
+ gate = createStudioGate({ client, tools: studioTools, notify: () => server.sendToolListChanged(), pollMs: studioPollMs });
18
+ // The gate asks the app once a client is connected, and stops when it goes.
19
+ server.server.oninitialized = () => gate.start();
20
+ server.server.onclose = () => gate.stop();
21
+ // bin.js reads the status once before connecting, so the first tool list is already right.
22
+ server.studioGate = gate;
11
23
  return server;
12
24
  }
@@ -0,0 +1,51 @@
1
+ // packages/mcp-server/src/studioGate.js
2
+ // The Video Studio tools are listed only to an agent whose SimpliGen holds the studio.
3
+ // Without it every film call is refused (studio_not_installed), so listing them only
4
+ // invites calls that cannot work. The app answers whether it holds the studio in
5
+ // /status (videoStudio.held, App 1.75.0 and newer); the gate reads that on start, every
6
+ // pollMs, and whenever the agent asks get_status, and tells the client when the set changes.
7
+
8
+ /**
9
+ * @param {{ client: { getStatus: () => Promise<object> },
10
+ * tools: Array<{ enabled: boolean }>,
11
+ * notify: () => void,
12
+ * pollMs?: number }} deps
13
+ */
14
+ export function createStudioGate({ client, tools, notify, pollMs = 60_000 }) {
15
+ let held = false;
16
+ let timer = null;
17
+ // Hidden until the app says otherwise. Set directly so a client that is not connected
18
+ // yet is not told, and a whole switch is one notification, not one per tool.
19
+ for (const t of tools) t.enabled = false;
20
+
21
+ const apply = (next) => {
22
+ if (next === held) return;
23
+ held = next;
24
+ for (const t of tools) t.enabled = next;
25
+ notify();
26
+ };
27
+
28
+ /** Read one /status answer. An app that does not report the studio does not hold it. */
29
+ const observe = (status) => apply(status?.videoStudio?.held === true);
30
+
31
+ /** Ask the app. A failed read (the app closed for a moment) changes nothing. */
32
+ const refresh = async () => {
33
+ try { observe(await client.getStatus()); } catch { /* keep what we had */ }
34
+ };
35
+
36
+ return {
37
+ observe,
38
+ refresh,
39
+ start() {
40
+ if (timer) return;
41
+ refresh();
42
+ timer = setInterval(refresh, pollMs);
43
+ timer.unref?.();
44
+ },
45
+ stop() {
46
+ clearInterval(timer);
47
+ timer = null;
48
+ },
49
+ get held() { return held; },
50
+ };
51
+ }
package/src/tools.js CHANGED
@@ -22,18 +22,25 @@ export const TOOL_NAMES = [
22
22
  'set_export_range', 'render_clips', 'wait_for_renders', 'list_takes', 'use_take', 'export_film', 'list_locations', 'create_location',
23
23
  ];
24
24
 
25
+ // The tools that need the Video Studio. Listed only while the app holds it (studioGate.js).
26
+ export const STUDIO_TOOL_NAMES = TOOL_NAMES.slice(TOOL_NAMES.indexOf('list_films'));
27
+
25
28
  const ok = (data) => ({ content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] });
26
29
  const fail = (err) => ({ isError: true, content: [{ type: 'text', text: `${err.errorCode ? err.errorCode + ': ' : ''}${err.message || String(err)}` }] });
27
30
  const wrap = (fn) => async (args) => { try { return ok(await fn(args)); } catch (e) { return fail(e); } };
28
31
 
29
- export function registerTools(server, client) {
32
+ export function registerTools(host, client, { onStatus } = {}) {
33
+ // Every tool's handle by name, so the studio's can be shown and hidden later.
34
+ const registered = {};
35
+ const server = { registerTool: (name, ...rest) => (registered[name] = host.registerTool(name, ...rest)) };
36
+
30
37
  server.registerTool('list_capabilities',
31
38
  { title: 'List capabilities', description: 'List every SimpliGen preset the agent can generate with (image/video), its inputs/options, whether it is installed locally (localReady) and cloud-eligible + credit cost. Local presets also carry onThisMachine: how likely a run is to finish on this machine (rating, finish %, p90Min: the slow end in minutes on similar cards), the typical minutes on this exact GPU (or notEnoughRunsOnGpu when there is too little data), and what size still fits.', inputSchema: {} },
32
39
  wrap(() => client.getCapabilities()));
33
40
 
34
41
  server.registerTool('get_status',
35
42
  { title: 'Get status', description: 'Engine running state, whether cloud is connected, credit balance, and the active project.', inputSchema: {} },
36
- wrap(() => client.getStatus()));
43
+ wrap(async () => { const status = await client.getStatus(); onStatus?.(status); return status; }));
37
44
 
38
45
  // The engine's lifecycle. get_status could always report it was down and
39
46
  // there was nothing an agent could do about it but ask the human to click
@@ -676,4 +683,6 @@ export function registerTools(server, client) {
676
683
  server.registerTool('publish_recipe',
677
684
  { title: 'Publish a recipe', description: 'Submit a saved recipe to the SimpliGen Creator Marketplace (queued for human review). Requires a connected account: if none, returns not_connected and the user connects once in Settings, then this succeeds on the same recipe. priceTokens sets an optional one-time price (0 or omitted = free). Every preset the recipe uses must be a distributable first-party pack.', inputSchema: { id: z.string().describe('Recipe id to publish'), changelog: z.string().optional(), priceTokens: z.number().optional().describe('One-time price in tokens (0/omitted = free).') } },
678
685
  wrap(({ id, changelog, priceTokens }) => client.publishRecipe(id, { changelog, priceTokens })));
686
+
687
+ return { studioTools: STUDIO_TOOL_NAMES.map((name) => registered[name]) };
679
688
  }