@marlinjai/studio-mcp 0.9.0 → 0.11.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 CHANGED
@@ -104,8 +104,8 @@ The token is held in memory only. It is never logged, never serialized into a re
104
104
  | `studio_get_usage` | What limits the key's company and what it has used: month-to-date spend and job count in what the company paid, the monthly USD cap (`capUsd`) and requests-per-minute limit (`null` = none), a per-model breakdown, and `credits`. For a company on prepaid credits (every new company) `credits` is `{ balanceUsd, dailyLimitUsd, usedTodayUsd, dailyResetsAt, operatorMonthlyLimit }`: the balance, the daily limit, what left the balance today, when the day resets and whether the operator set a monthly limit on top; for a company held to a monthly cap it is `null`. Call before a large batch to check remaining room, or after a `402`/`429` to see what tripped. `usedUsd` includes in-flight (not yet settled) job estimates, so it can go DOWN as well as up: a job that later fails releases its estimate. |
105
105
  | `studio_workflow_describe` | The node vocabulary: every task type with ports, prompt policy and runnability, the input types, the op types, the patch limits. Settings and models only with `includeSettings` / `includeModels`; filter with `tasks`. |
106
106
  | `studio_workflow_get` | A saved workflow as a summary (nodes, wire counts, edge and group counts, `revision`, `readOnly`, `projection`), or the whole response with `full: true`. |
107
- | `studio_workflow_create` | Build a new saved workflow from ops applied to an empty document. Returns `{ ok, savedId, revision, summary }`. |
108
- | `studio_workflow_apply` | Change a saved workflow atomically on top of `baseRevision`. Returns counts, the affected nodes, the projection and `replayed`; every refusal (stale base, invalid patch, missing scope, not editable, lossy import, idempotency mismatch) comes back as a structured `{ ok: false, code, hint }` result. Character references on an image-to-video node (models whose `studio_workflow_describe` entry carries `characterReferences`, Kling O3): `connect` each photo with `port: "reference"`, each character's frontal view first, and with more than one character `setNodeSetting` key `referenceElements`, value `{ "<sourceNodeId>": 2 }`; they never count as the start or end frame. |
107
+ | `studio_workflow_create` | Build a new saved workflow from ops applied to an empty document. Returns `{ ok, savedId, revision, summary, idempotencyKey }`; a retry with that `idempotencyKey` returns the first workflow (`replayed: true`) instead of a second one. |
108
+ | `studio_workflow_apply` | Change a saved workflow atomically on top of `baseRevision`. Returns counts, the affected nodes, the projection and `replayed`; every refusal (stale base, invalid patch, missing scope, not editable, lossy import, idempotency mismatch) comes back as a structured `{ ok: false, code, hint }` result. Character references on an image-to-video node (models whose `studio_workflow_describe` entry carries `characterReferences`, Kling O3): `connect` each photo with `port: "reference"`, each character's frontal view first, and with more than one character `setNodeSetting` key `referenceElements`, value `{ "<sourceNodeId>": 2 }`; they never count as the start or end frame. Gemini Omni 1.1 Flash with references takes 1 to 6 character images and sends the start frame as the first reference (KIE locks no first frame in that mode). |
109
109
  | `studio_workflow_validate` | Dry-run a document (inline or by `savedId`) with optional ops and run params: the Studio's `{ apply, document, projection, run }` verdict, no side effects, no cost. |
110
110
  | `studio_workflow_screenshot` | Render a saved workflow's document as a diagram (labelled boxes and wires, positioned by the document's own layout), the Figma `get_screenshot` equivalent for a workflow graph. Not a pixel-exact canvas preview, a diagnostic diagram for checking topology. Returns `{ url, width, height }` (a 24h signed link). Free, read-only. |
111
111
  | `studio_list_assets` | A project's assets, newest first, optionally one subtype: `Image` for slide backgrounds, `Video` for reel clips, and earlier renders. Free, read-only. |
@@ -124,7 +124,7 @@ The token is held in memory only. It is never logged, never serialized into a re
124
124
  | `studio_describe_published` | Describe one published recipe by slug: `{ slug, definition, hasEffects }`. `definition` is the FROZEN workflow (params, node shapes) exactly as it was at publish time, never the live authoring document. Read this before `studio_run_published` to know what params it needs. Free, read-only. |
125
125
  | `studio_run_published` | Run a published recipe by slug against its frozen definition; `params` fill the definition's own param bindings. On success, the recipe's declared post-run effects fire automatically (e.g. minting creates the character and attaches its reference views); effects never fire on a failed, partial or cancelled run. Each node is a paid job. A recipe that creates a character requires `likenessRightsConfirmed: true`, refused before any spend otherwise. |
126
126
 
127
- All waiting tools accept `waitSeconds` (default 600) and back off between polls (2s doubling up to 15s). A timeout never cancels anything server-side: the tool error carries the id so the agent can poll again.
127
+ All waiting tools accept `waitSeconds` (default 600) and back off between polls (2s doubling up to 15s). A timeout never cancels anything server-side: the tool error carries the id so the agent can poll again. A poll that gets a 503 (Studio could not reach its sign-in service, `auth_unavailable`) or no answer at all is waited out within the same budget instead of ending the wait, because the job keeps running either way.
128
128
 
129
129
  ### Tool signatures (the contract shared with the `lumitra-studio` plugin)
130
130
 
@@ -185,7 +185,10 @@ The six `studio_workflow_*` tools are the agent's side of the Studio's workflow
185
185
 
186
186
  ```
187
187
  studio_workflow_describe what nodes exist, their ports, the op vocabulary
188
- studio_workflow_create { ops, label? } -> { ok, savedId, revision, summary }
188
+ studio_workflow_create { ops, label?, projectId?, idempotencyKey? }
189
+ -> { ok: true, savedId, revision, summary, idempotencyKey, replayed? }
190
+ -> { ok: false, code: "idempotency_mismatch" } that key made a different workflow: use a fresh one
191
+ -> { ok: false, code: "network_error" | "server_error", idempotencyKey } retry with the SAME key, label and ops
189
192
  studio_workflow_get { savedId, full? } -> summary (revision = the baseRevision for apply)
190
193
  studio_workflow_apply { savedId, baseRevision, ops, idempotencyKey?, acknowledgeLossy? }
191
194
  -> { ok: true, revision, appliedCount, inverseCount, affectedNodes, projection, idempotencyKey, replayed }
package/dist/cli.js CHANGED
@@ -298,7 +298,12 @@ var StudioClient = class {
298
298
  getWorkflowDocument(savedId2, opts = {}) {
299
299
  return this.json("GET", `/api/v1/workflows/${encodeURIComponent(savedId2)}${projectQuery(opts.projectId)}`);
300
300
  }
301
- /** Create a document by applying `ops` to an empty one (the same code path as apply). */
301
+ /**
302
+ * Create a document by applying `ops` to an empty one (the same code path as
303
+ * apply). 201 created; 200 with `replayed: true` when a create with this
304
+ * idempotencyKey already made it; 409 `idempotency_mismatch` when that key
305
+ * made a different one.
306
+ */
302
307
  createWorkflow(body) {
303
308
  return this.json("POST", "/api/v1/workflows", { json: body });
304
309
  }
@@ -1169,6 +1174,21 @@ var CATALOG_ENTRIES = [
1169
1174
  description: "Google Gemini Omni 1.1 Flash via KIE, first-and-last-frame mode. A start frame and an optional end frame, 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. KIE refuses registered characters in this mode, so identity comes from the frames alone. Accepted a minted character's photoreal stills on 2026-09-24 (set 9:16 for a portrait still: it defaults to 16:9 and crops). No fal equivalent.",
1170
1175
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1171
1176
  },
1177
+ {
1178
+ id: "kie/gemini-omni-flash-1-1-reference-to-video",
1179
+ provider: "kie",
1180
+ modality: "video",
1181
+ task: "image-to-video",
1182
+ label: "Gemini Omni 1.1 Flash with references (KIE)",
1183
+ description: "Google Gemini Omni 1.1 Flash via KIE in its reference mode: the start keyframe and up to 6 character images wired into the reference port go in as up to 7 reference images, and the prompt names the keyframe as the exact scene and first frame and each character's images in order. KIE does not lock the first frame in this mode (it refuses a first frame together with references), so the clip follows the keyframe closely but may not start on it pixel for pixel; for a locked first frame with references use Kling O3. 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. No end frame.",
1184
+ // `characterReferences` mirrors
1185
+ // KIE_VIDEO_SPECS['google/gemini-omni-flash-1-1/references'] (checked by a spec).
1186
+ capabilities: {
1187
+ needsImageInput: true,
1188
+ maxInputImages: 1,
1189
+ characterReferences: { maxElements: 6, minImagesPerElement: 1, maxImagesPerElement: 6, maxTotalImages: 6 }
1190
+ }
1191
+ },
1172
1192
  {
1173
1193
  id: "kie/kling-o3-image-to-video",
1174
1194
  provider: "kie",
@@ -1565,6 +1585,21 @@ function routeEntry(id) {
1565
1585
  function tryGetModel(id) {
1566
1586
  return MODEL_CATALOG.find((m) => m.id === id) ?? routeEntry(id);
1567
1587
  }
1588
+ function omniReferencesPrompt(prompt, elements) {
1589
+ const parts = ["Image 1 is the exact scene and the first frame of the video: start the clip on it and keep its setting, framing and light."];
1590
+ let next = 2;
1591
+ for (const [i, e] of elements.entries()) {
1592
+ const count2 = 1 + e.referenceImageUrls.length;
1593
+ const span = count2 === 1 ? `Image ${next} shows` : `Images ${next} to ${next + count2 - 1} show`;
1594
+ parts.push(
1595
+ `${span} character ${i + 1}${count2 > 1 ? ", the first of them from the front" : ""}; keep their face, hair and clothing exactly as shown for the whole clip.`
1596
+ );
1597
+ next += count2;
1598
+ }
1599
+ const text = prompt?.trim() ?? "";
1600
+ return text ? `${parts.join(" ")} ${text}` : parts.join(" ");
1601
+ }
1602
+ var OMNI_MAX_REFERENCE_IMAGES = 7;
1568
1603
  function veoSpec(model, label) {
1569
1604
  return {
1570
1605
  family: "veo",
@@ -1782,6 +1817,44 @@ var KIE_VIDEO_SPECS = {
1782
1817
  ...i.seed !== void 0 ? { seed: i.seed } : {}
1783
1818
  })
1784
1819
  },
1820
+ // Gemini Omni 1.1 Flash in its REFERENCE mode: up to seven `image_urls`
1821
+ // ("Multiple reference images can be uploaded to provide references for
1822
+ // characters, scenes, styles, or storyboards"; "Maximum of 7 images"), and
1823
+ // no locked first frame, because KIE makes `first_frame_url` "mutually
1824
+ // exclusive with `image_urls`" (docs.kie.ai, read 2026-10-24). The start
1825
+ // keyframe goes first among the images and the prompt names it the exact
1826
+ // scene and first frame (`omniReferencesPrompt`); each character's views
1827
+ // follow. Same model, same price as the first-frame mode.
1828
+ "google/gemini-omni-flash-1-1/references": {
1829
+ family: "job",
1830
+ label: "Gemini Omni 1.1 Flash with references",
1831
+ upstreamModel: "google/gemini-omni-flash-1-1",
1832
+ endFrame: false,
1833
+ aspectRatios: ["16:9", "9:16"],
1834
+ resolutions: ["720p", "1080p", "4k"],
1835
+ durations: { values: [4, 6, 8, 10] },
1836
+ defaultSeconds: 8,
1837
+ defaultResolution: "720p",
1838
+ audioSwitch: false,
1839
+ defaultAudio: false,
1840
+ // Six character images, because the start keyframe takes one of the seven.
1841
+ characterReferences: {
1842
+ maxElements: 6,
1843
+ minImagesPerElement: 1,
1844
+ maxImagesPerElement: 6,
1845
+ maxTotalImages: OMNI_MAX_REFERENCE_IMAGES - 1
1846
+ },
1847
+ maxPromptChars: 2e4,
1848
+ referencesPrompt: omniReferencesPrompt,
1849
+ build: (i) => ({
1850
+ prompt: i.prompt,
1851
+ image_urls: [i.start, ...(i.elements ?? []).flatMap((e) => [e.frontalImageUrl, ...e.referenceImageUrls])],
1852
+ duration: String(i.seconds),
1853
+ resolution: i.resolution,
1854
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio } : {},
1855
+ ...i.seed !== void 0 ? { seed: i.seed } : {}
1856
+ })
1857
+ },
1785
1858
  "kling-3.0-omni/image-to-video": {
1786
1859
  family: "job",
1787
1860
  label: "Kling O3",
@@ -3755,6 +3828,21 @@ var CATALOG_ENTRIES2 = [
3755
3828
  description: "Google Gemini Omni 1.1 Flash via KIE, first-and-last-frame mode. A start frame and an optional end frame, 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. KIE refuses registered characters in this mode, so identity comes from the frames alone. Accepted a minted character's photoreal stills on 2026-09-24 (set 9:16 for a portrait still: it defaults to 16:9 and crops). No fal equivalent.",
3756
3829
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
3757
3830
  },
3831
+ {
3832
+ id: "kie/gemini-omni-flash-1-1-reference-to-video",
3833
+ provider: "kie",
3834
+ modality: "video",
3835
+ task: "image-to-video",
3836
+ label: "Gemini Omni 1.1 Flash with references (KIE)",
3837
+ description: "Google Gemini Omni 1.1 Flash via KIE in its reference mode: the start keyframe and up to 6 character images wired into the reference port go in as up to 7 reference images, and the prompt names the keyframe as the exact scene and first frame and each character's images in order. KIE does not lock the first frame in this mode (it refuses a first frame together with references), so the clip follows the keyframe closely but may not start on it pixel for pixel; for a locked first frame with references use Kling O3. 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. No end frame.",
3838
+ // `characterReferences` mirrors
3839
+ // KIE_VIDEO_SPECS['google/gemini-omni-flash-1-1/references'] (checked by a spec).
3840
+ capabilities: {
3841
+ needsImageInput: true,
3842
+ maxInputImages: 1,
3843
+ characterReferences: { maxElements: 6, minImagesPerElement: 1, maxImagesPerElement: 6, maxTotalImages: 6 }
3844
+ }
3845
+ },
3758
3846
  {
3759
3847
  id: "kie/kling-o3-image-to-video",
3760
3848
  provider: "kie",
@@ -5372,6 +5460,9 @@ function assertImage(file, source) {
5372
5460
  // src/poll.ts
5373
5461
  var DEFAULT_TIMEOUT_MS = 6e5;
5374
5462
  var defaultSleep = (ms) => new Promise((r) => setTimeout(r, ms));
5463
+ function isTransientPollError(err) {
5464
+ return err instanceof StudioApiError && (err.status === 503 || err.status === 0);
5465
+ }
5375
5466
  async function pollUntil(what, fetchState, isDone, opts = {}) {
5376
5467
  const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
5377
5468
  const factor = opts.factor ?? 1.5;
@@ -5380,15 +5471,30 @@ async function pollUntil(what, fetchState, isDone, opts = {}) {
5380
5471
  const now = opts.now ?? Date.now;
5381
5472
  const start = now();
5382
5473
  let delay = opts.initialDelayMs ?? 2e3;
5383
- let last = await fetchState();
5384
- if (isDone(last)) return last;
5474
+ let observed = false;
5475
+ let last;
5476
+ let lastTransient;
5477
+ const poll = async () => {
5478
+ try {
5479
+ last = await fetchState();
5480
+ observed = true;
5481
+ return isDone(last);
5482
+ } catch (err) {
5483
+ if (!isTransientPollError(err)) throw err;
5484
+ lastTransient = err;
5485
+ return false;
5486
+ }
5487
+ };
5488
+ if (await poll()) return last;
5385
5489
  for (; ; ) {
5386
5490
  const elapsed = now() - start;
5387
5491
  const remaining = timeoutMs - elapsed;
5388
- if (remaining <= 0) throw new PollTimeoutError(what, timeoutMs, last);
5492
+ if (remaining <= 0) {
5493
+ if (!observed) throw lastTransient;
5494
+ throw new PollTimeoutError(what, timeoutMs, last);
5495
+ }
5389
5496
  await sleep(Math.min(delay, remaining));
5390
- last = await fetchState();
5391
- if (isDone(last)) return last;
5497
+ if (await poll()) return last;
5392
5498
  delay = Math.min(maxDelay, Math.round(delay * factor));
5393
5499
  }
5394
5500
  }
@@ -5620,7 +5726,7 @@ function affectedNodes(doc, ids) {
5620
5726
  // src/workflowTools.ts
5621
5727
  var savedId = z7.string().min(1).describe('The saved workflow id (it carries a "saved:" prefix), from studio_workflow_create or the Studio workflow list.');
5622
5728
  var opsSchema = PatchSchema.shape.ops.describe(
5623
- `The ops to apply in order, 1 to ${MAX_PATCH_OPS}: addNode, removeNode, setNodeProps, setNodeSetting, setBakedInput, connect, disconnect, exposeAsInput, freezeInput, setActiveGeneration, setLayout, group, ungroup, setGroupProps, setDocumentProps. Node ids are yours to choose (UUIDv7 recommended); a later op may reference an id added earlier in the same list. Character references on an image-to-video node: connect each image (an image-source, an image input or an image-producing node) with port "reference", in order, each character's frontal view first; they never count as the start or end frame (those are the "image" port). Only a model whose studio_workflow_describe entry carries characterReferences takes them (Kling O3). With more than one character, set which one each image shows with setNodeSetting key "referenceElements", value { "<sourceNodeId>": 2 } (an unnamed source is character 1).`
5729
+ `The ops to apply in order, 1 to ${MAX_PATCH_OPS}: addNode, removeNode, setNodeProps, setNodeSetting, setBakedInput, connect, disconnect, exposeAsInput, freezeInput, setActiveGeneration, setLayout, group, ungroup, setGroupProps, setDocumentProps. Node ids are yours to choose (UUIDv7 recommended); a later op may reference an id added earlier in the same list. Character references on an image-to-video node: connect each image (an image-source, an image input or an image-producing node) with port "reference", in order, each character's frontal view first; they never count as the start or end frame (those are the "image" port). Only a model whose studio_workflow_describe entry carries characterReferences takes them (Kling O3: 2 to 4 images per character, a locked first frame; Gemini Omni 1.1 Flash with references: 1 to 6 images in all, the start frame sent as the first reference rather than locked). With more than one character, set which one each image shows with setNodeSetting key "referenceElements", value { "<sourceNodeId>": 2 } (an unnamed source is character 1).`
5624
5730
  );
5625
5731
  var paramsSchema = z7.record(z7.string(), z7.unknown()).describe("Run parameters by input-node name, checked against the declared inputs (unknown names, missing required values and wrong shapes are issues).");
5626
5732
  var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -5649,6 +5755,8 @@ function applyErrorOf(raw, ctx) {
5649
5755
  }
5650
5756
  var REBASE_HINT = "Re-read the workflow (studio_workflow_get), rebase your ops on the current revision (node ids are stable) and apply again with that revision as baseRevision.";
5651
5757
  var RETRY_HINT = "The outcome of this attempt is unknown. Retry studio_workflow_apply with the SAME idempotencyKey and baseRevision: if the first attempt landed, the Studio returns its original result instead of applying the patch twice.";
5758
+ var CREATE_RETRY_HINT = "The outcome of this attempt is unknown. Retry studio_workflow_create with the SAME idempotencyKey, label and ops: if the first attempt landed, the Studio returns that workflow (replayed: true) instead of making a second one.";
5759
+ var CREATE_IDEMPOTENCY_HINT = "This is not a replay: that idempotencyKey was already used to create a different workflow. Send this create with a NEW idempotencyKey.";
5652
5760
  var NOT_EDITABLE_HINT = "This workflow is readable (studio_workflow_get) and runnable (studio_run_workflow with its savedId), but it cannot be patched. Build a new workflow with studio_workflow_create instead of trying to edit this one.";
5653
5761
  var LOSSY_HINT = "Read the notes: they name what the import drops for good. To go ahead, resend the SAME ops with acknowledgeLossy: true and a NEW idempotencyKey (the first patch materializes the imported document).";
5654
5762
  var IDEMPOTENCY_HINT = "This is not a replay: that key was used for a different patch. Send this patch again with a NEW idempotencyKey, on the revision above.";
@@ -5711,6 +5819,24 @@ function mapWriteFailure(err, ctx, info) {
5711
5819
  }
5712
5820
  return null;
5713
5821
  }
5822
+ function mapCreateFailure(err, ctx, idempotencyKey) {
5823
+ if (!(err instanceof StudioApiError)) return null;
5824
+ const body = isRecord(err.body) ? err.body : {};
5825
+ if (err.status === 409 && body.code === "idempotency_mismatch") {
5826
+ return { ok: false, code: "idempotency_mismatch", message: messageOf(body, ctx), hint: CREATE_IDEMPOTENCY_HINT };
5827
+ }
5828
+ if (err.status === 0 || err.status >= 500) {
5829
+ return {
5830
+ ok: false,
5831
+ code: err.status === 0 ? "network_error" : "server_error",
5832
+ status: err.status,
5833
+ message: ctx.client.redact(err.message),
5834
+ idempotencyKey,
5835
+ hint: CREATE_RETRY_HINT
5836
+ };
5837
+ }
5838
+ return null;
5839
+ }
5714
5840
  var studioWorkflowDescribe = defineTool({
5715
5841
  name: "studio_workflow_describe",
5716
5842
  description: "Describe the node vocabulary before authoring a workflow (read-only, free). Returns { tasks: [{ task, label, family, modality, jobKind, runnable, output, inputs: [{ port, wireable, cardinality, binding }], prompt: { needed, required, key } | null, settingCount, modelCount }], inputTypes (what an input node can declare), opTypes (what studio_workflow_apply accepts), limits: { maxPatchOps } }. Settings knobs and the model catalog are large, so they are dropped unless includeSettings / includeModels is true; filter with tasks to keep the result small.",
@@ -5786,22 +5912,25 @@ var studioWorkflowGet = defineTool({
5786
5912
  });
5787
5913
  var studioWorkflowCreate = defineTool({
5788
5914
  name: "studio_workflow_create",
5789
- description: 'Create a new saved workflow by applying ops to an empty document (call studio_workflow_describe first for the task vocabulary and ports). Returns { ok: true, savedId, revision, summary } (the studio_workflow_get summary shape, its projection tells you whether it can run). A bad patch returns { ok: false, code: "invalid_patch", error: { opIndex, code, message } } naming the offending op; a missing credential scope returns { ok: false, code: "forbidden", opIndex, missingScope }. Creating is free; running it with studio_run_workflow (savedId) is what spends money.',
5915
+ description: 'Create a new saved workflow by applying ops to an empty document (call studio_workflow_describe first for the task vocabulary and ports). Returns { ok: true, savedId, revision, summary, idempotencyKey } (the studio_workflow_get summary shape, its projection tells you whether it can run), plus replayed: true when an earlier attempt with the same idempotencyKey had already made it (revision is then its current one). A bad patch returns { ok: false, code: "invalid_patch", error: { opIndex, code, message } } naming the offending op; a missing credential scope returns { ok: false, code: "forbidden", opIndex, missingScope }; "idempotency_mismatch" means that key was used for a different create (send a new one); "network_error" / "server_error" carry the idempotencyKey to retry with, so a retry can never make a second workflow. A key is scoped to its project (the same key on another project makes a new workflow), and a retry after the workflow was deleted creates a new one. Creating is free; running it with studio_run_workflow (savedId) is what spends money.',
5790
5916
  inputSchema: {
5791
5917
  ops: opsSchema,
5792
5918
  label: LabelSchema.optional().describe("Display label of the saved workflow."),
5793
- projectId: z7.string().min(1).optional().describe("Project id from studio_list_projects; omit for the default project.")
5919
+ projectId: z7.string().min(1).optional().describe("Project id from studio_list_projects; omit for the default project."),
5920
+ idempotencyKey: z7.string().min(1).max(200).optional().describe("Omit on a first call (one is generated). After a network_error or server_error, retry with the idempotencyKey that result returned: the first workflow comes back instead of a second one.")
5794
5921
  },
5795
5922
  handler: async (args, ctx) => {
5923
+ const idempotencyKey = args.idempotencyKey ?? randomUUID();
5796
5924
  let res;
5797
5925
  try {
5798
5926
  res = await ctx.client.createWorkflow({
5799
5927
  ops: args.ops,
5928
+ idempotencyKey,
5800
5929
  ...args.label !== void 0 ? { label: args.label } : {},
5801
5930
  ...args.projectId !== void 0 ? { projectId: args.projectId } : {}
5802
5931
  });
5803
5932
  } catch (err) {
5804
- const mapped = mapWriteFailure(err, ctx, {});
5933
+ const mapped = mapCreateFailure(err, ctx, idempotencyKey) ?? mapWriteFailure(err, ctx, {});
5805
5934
  if (mapped) return mapped;
5806
5935
  throw err;
5807
5936
  }
@@ -5814,7 +5943,9 @@ var studioWorkflowCreate = defineTool({
5814
5943
  savedId: res.savedId,
5815
5944
  revision: res.revision,
5816
5945
  ...res.projection ? { projection: res.projection } : {}
5817
- })
5946
+ }),
5947
+ idempotencyKey,
5948
+ ...res.replayed === true ? { replayed: true } : {}
5818
5949
  };
5819
5950
  }
5820
5951
  });
@@ -7078,7 +7209,7 @@ var studioUploadBrandReference = defineTool({
7078
7209
  }
7079
7210
  });
7080
7211
  var workflowDefinitionSchema = WorkflowDefinitionSchema.describe(
7081
- `Inline workflow DAG: { id, label?, params?: [{ name, type: string|number|boolean|json, required?, label?, description?, inputType?, cardinality?: one|many, default? }], nodes: [{ id, task (one of the model tasks listed), model (catalog id, e.g. fal/nano-banana-2-edit), inputs, retry? }] }. Node inputs are bindings: {kind:"literal",value}, {kind:"param",name,wrap?:"array"}, {kind:"ref",node,path:"url",wrap?:"array"} or an ordered {kind:"list",items:[...]} of those. Image-edit nodes take inputImages (an array: one wrapped ref/param, or a list in reference order, scene frame first); image-to-video nodes take inputImageUrl (start frame) and optionally endImageUrl (end frame, on models that accept one), EXCEPT on a keyframes model (fal/flux-3-keyframes-to-video and its -draft tier), which instead takes keyframeImageUrls (an ordered list of up to 10 images) with keyframeFrameIndexes (one strictly increasing frame per image on a fixed 24 fps timeline). Pass one shape or the other, never both. To hold a character's identity through the clip, an image-to-video node on a model with character references (route/kling-o3, kie/kling-o3-image-to-video, fal/kling-o3-pro-reference-to-video) also takes referenceImageUrls (a list of character photos, grouped by character, each character's frontal view first, 2 to 4 images per character, up to 3 characters) with referenceElementIndexes (the 0-based character of each image, ascending without gaps, e.g. [0,0,0,1,1]); they never count as the start or end frame, and they need inputImageUrl.`
7212
+ `Inline workflow DAG: { id, label?, params?: [{ name, type: string|number|boolean|json, required?, label?, description?, inputType?, cardinality?: one|many, default? }], nodes: [{ id, task (one of the model tasks listed), model (catalog id, e.g. fal/nano-banana-2-edit), inputs, retry? }] }. Node inputs are bindings: {kind:"literal",value}, {kind:"param",name,wrap?:"array"}, {kind:"ref",node,path:"url",wrap?:"array"} or an ordered {kind:"list",items:[...]} of those. Image-edit nodes take inputImages (an array: one wrapped ref/param, or a list in reference order, scene frame first); image-to-video nodes take inputImageUrl (start frame) and optionally endImageUrl (end frame, on models that accept one), EXCEPT on a keyframes model (fal/flux-3-keyframes-to-video and its -draft tier), which instead takes keyframeImageUrls (an ordered list of up to 10 images) with keyframeFrameIndexes (one strictly increasing frame per image on a fixed 24 fps timeline). Pass one shape or the other, never both. To hold a character's identity through the clip, an image-to-video node on a model with character references (route/kling-o3, kie/kling-o3-image-to-video, fal/kling-o3-pro-reference-to-video) also takes referenceImageUrls (a list of character photos, grouped by character, each character's frontal view first, 2 to 4 images per character, up to 3 characters) with referenceElementIndexes (the 0-based character of each image, ascending without gaps, e.g. [0,0,0,1,1]); they never count as the start or end frame, and they need inputImageUrl. kie/gemini-omni-flash-1-1-reference-to-video takes the same two fields with 1 to 6 character images in all and no end frame: its start frame goes in as reference image 1, named in the prompt as the exact scene and first frame, because KIE does not lock a first frame in its reference mode.`
7082
7213
  );
7083
7214
  var studioRunWorkflow = defineTool({
7084
7215
  name: "studio_run_workflow",
@@ -7429,7 +7560,7 @@ function registerTools(server, base) {
7429
7560
 
7430
7561
  // src/server.ts
7431
7562
  var SERVER_NAME = "lumitra-studio";
7432
- var SERVER_VERSION = "0.9.0";
7563
+ var SERVER_VERSION = "0.11.0";
7433
7564
  function createStudioMcpServer(opts = {}) {
7434
7565
  const config = opts.config ?? resolveConfig(opts.env ?? process.env);
7435
7566
  const client = new StudioClient(config, {
package/dist/index.d.ts CHANGED
@@ -1554,6 +1554,8 @@ interface WorkflowCreateResponse {
1554
1554
  revision: number;
1555
1555
  document: WorkflowDocument;
1556
1556
  projection?: Projection;
1557
+ /** true when an earlier create with the same idempotencyKey made this workflow. */
1558
+ replayed?: boolean;
1557
1559
  }
1558
1560
  /** `PATCH /api/v1/workflows/:savedId`: 200. */
1559
1561
  interface WorkflowApplyResponse {
@@ -1830,11 +1832,17 @@ declare class StudioClient {
1830
1832
  getWorkflowDocument(savedId: string, opts?: {
1831
1833
  projectId?: string;
1832
1834
  }): Promise<WorkflowDocumentResponse>;
1833
- /** Create a document by applying `ops` to an empty one (the same code path as apply). */
1835
+ /**
1836
+ * Create a document by applying `ops` to an empty one (the same code path as
1837
+ * apply). 201 created; 200 with `replayed: true` when a create with this
1838
+ * idempotencyKey already made it; 409 `idempotency_mismatch` when that key
1839
+ * made a different one.
1840
+ */
1834
1841
  createWorkflow(body: {
1835
1842
  ops: Op[];
1836
1843
  label?: string;
1837
1844
  projectId?: string;
1845
+ idempotencyKey?: string;
1838
1846
  }): Promise<WorkflowCreateResponse>;
1839
1847
  /**
1840
1848
  * Apply a patch atomically on top of `patch.baseRevision`. 409 on a stale
@@ -1955,7 +1963,10 @@ interface PollOptions {
1955
1963
  declare const DEFAULT_TIMEOUT_MS = 600000;
1956
1964
  /**
1957
1965
  * Call `fetchState` until `isDone(state)` is true or the budget is exhausted.
1958
- * Throws PollTimeoutError (carrying the last observed state) on timeout.
1966
+ * A transient failure (`isTransientPollError`) is waited out like a not-done
1967
+ * state; any other error ends the wait. Throws PollTimeoutError (carrying the
1968
+ * last observed state) on timeout, or the last transient error when no state
1969
+ * was ever observed.
1959
1970
  */
1960
1971
  declare function pollUntil<T>(what: string, fetchState: () => Promise<T>, isDone: (state: T) => boolean, opts?: PollOptions): Promise<T>;
1961
1972
  declare function waitForJob(client: StudioClient, jobId: string, opts?: PollOptions): Promise<JobResponse>;
@@ -2043,7 +2054,7 @@ declare function registerTools(server: McpServer, base: ToolContext): void;
2043
2054
  */
2044
2055
 
2045
2056
  declare const SERVER_NAME = "lumitra-studio";
2046
- declare const SERVER_VERSION = "0.9.0";
2057
+ declare const SERVER_VERSION = "0.11.0";
2047
2058
  interface CreateServerOptions {
2048
2059
  config?: StudioConfig;
2049
2060
  env?: NodeJS.ProcessEnv;
@@ -2391,6 +2402,7 @@ declare const studioWorkflowCreate: ToolDef<{
2391
2402
  }, z.core.$strip>], "type">>;
2392
2403
  label: z.ZodOptional<z.ZodString>;
2393
2404
  projectId: z.ZodOptional<z.ZodString>;
2405
+ idempotencyKey: z.ZodOptional<z.ZodString>;
2394
2406
  }>;
2395
2407
  declare const studioWorkflowApply: ToolDef<{
2396
2408
  savedId: z.ZodString;
package/dist/index.js CHANGED
@@ -245,7 +245,12 @@ var StudioClient = class {
245
245
  getWorkflowDocument(savedId2, opts = {}) {
246
246
  return this.json("GET", `/api/v1/workflows/${encodeURIComponent(savedId2)}${projectQuery(opts.projectId)}`);
247
247
  }
248
- /** Create a document by applying `ops` to an empty one (the same code path as apply). */
248
+ /**
249
+ * Create a document by applying `ops` to an empty one (the same code path as
250
+ * apply). 201 created; 200 with `replayed: true` when a create with this
251
+ * idempotencyKey already made it; 409 `idempotency_mismatch` when that key
252
+ * made a different one.
253
+ */
249
254
  createWorkflow(body) {
250
255
  return this.json("POST", "/api/v1/workflows", { json: body });
251
256
  }
@@ -1161,6 +1166,21 @@ var CATALOG_ENTRIES = [
1161
1166
  description: "Google Gemini Omni 1.1 Flash via KIE, first-and-last-frame mode. A start frame and an optional end frame, 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. KIE refuses registered characters in this mode, so identity comes from the frames alone. Accepted a minted character's photoreal stills on 2026-09-24 (set 9:16 for a portrait still: it defaults to 16:9 and crops). No fal equivalent.",
1162
1167
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1163
1168
  },
1169
+ {
1170
+ id: "kie/gemini-omni-flash-1-1-reference-to-video",
1171
+ provider: "kie",
1172
+ modality: "video",
1173
+ task: "image-to-video",
1174
+ label: "Gemini Omni 1.1 Flash with references (KIE)",
1175
+ description: "Google Gemini Omni 1.1 Flash via KIE in its reference mode: the start keyframe and up to 6 character images wired into the reference port go in as up to 7 reference images, and the prompt names the keyframe as the exact scene and first frame and each character's images in order. KIE does not lock the first frame in this mode (it refuses a first frame together with references), so the clip follows the keyframe closely but may not start on it pixel for pixel; for a locked first frame with references use Kling O3. 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. No end frame.",
1176
+ // `characterReferences` mirrors
1177
+ // KIE_VIDEO_SPECS['google/gemini-omni-flash-1-1/references'] (checked by a spec).
1178
+ capabilities: {
1179
+ needsImageInput: true,
1180
+ maxInputImages: 1,
1181
+ characterReferences: { maxElements: 6, minImagesPerElement: 1, maxImagesPerElement: 6, maxTotalImages: 6 }
1182
+ }
1183
+ },
1164
1184
  {
1165
1185
  id: "kie/kling-o3-image-to-video",
1166
1186
  provider: "kie",
@@ -1557,6 +1577,21 @@ function routeEntry(id) {
1557
1577
  function tryGetModel(id) {
1558
1578
  return MODEL_CATALOG.find((m) => m.id === id) ?? routeEntry(id);
1559
1579
  }
1580
+ function omniReferencesPrompt(prompt, elements) {
1581
+ const parts = ["Image 1 is the exact scene and the first frame of the video: start the clip on it and keep its setting, framing and light."];
1582
+ let next = 2;
1583
+ for (const [i, e] of elements.entries()) {
1584
+ const count2 = 1 + e.referenceImageUrls.length;
1585
+ const span = count2 === 1 ? `Image ${next} shows` : `Images ${next} to ${next + count2 - 1} show`;
1586
+ parts.push(
1587
+ `${span} character ${i + 1}${count2 > 1 ? ", the first of them from the front" : ""}; keep their face, hair and clothing exactly as shown for the whole clip.`
1588
+ );
1589
+ next += count2;
1590
+ }
1591
+ const text = prompt?.trim() ?? "";
1592
+ return text ? `${parts.join(" ")} ${text}` : parts.join(" ");
1593
+ }
1594
+ var OMNI_MAX_REFERENCE_IMAGES = 7;
1560
1595
  function veoSpec(model, label) {
1561
1596
  return {
1562
1597
  family: "veo",
@@ -1774,6 +1809,44 @@ var KIE_VIDEO_SPECS = {
1774
1809
  ...i.seed !== void 0 ? { seed: i.seed } : {}
1775
1810
  })
1776
1811
  },
1812
+ // Gemini Omni 1.1 Flash in its REFERENCE mode: up to seven `image_urls`
1813
+ // ("Multiple reference images can be uploaded to provide references for
1814
+ // characters, scenes, styles, or storyboards"; "Maximum of 7 images"), and
1815
+ // no locked first frame, because KIE makes `first_frame_url` "mutually
1816
+ // exclusive with `image_urls`" (docs.kie.ai, read 2026-10-24). The start
1817
+ // keyframe goes first among the images and the prompt names it the exact
1818
+ // scene and first frame (`omniReferencesPrompt`); each character's views
1819
+ // follow. Same model, same price as the first-frame mode.
1820
+ "google/gemini-omni-flash-1-1/references": {
1821
+ family: "job",
1822
+ label: "Gemini Omni 1.1 Flash with references",
1823
+ upstreamModel: "google/gemini-omni-flash-1-1",
1824
+ endFrame: false,
1825
+ aspectRatios: ["16:9", "9:16"],
1826
+ resolutions: ["720p", "1080p", "4k"],
1827
+ durations: { values: [4, 6, 8, 10] },
1828
+ defaultSeconds: 8,
1829
+ defaultResolution: "720p",
1830
+ audioSwitch: false,
1831
+ defaultAudio: false,
1832
+ // Six character images, because the start keyframe takes one of the seven.
1833
+ characterReferences: {
1834
+ maxElements: 6,
1835
+ minImagesPerElement: 1,
1836
+ maxImagesPerElement: 6,
1837
+ maxTotalImages: OMNI_MAX_REFERENCE_IMAGES - 1
1838
+ },
1839
+ maxPromptChars: 2e4,
1840
+ referencesPrompt: omniReferencesPrompt,
1841
+ build: (i) => ({
1842
+ prompt: i.prompt,
1843
+ image_urls: [i.start, ...(i.elements ?? []).flatMap((e) => [e.frontalImageUrl, ...e.referenceImageUrls])],
1844
+ duration: String(i.seconds),
1845
+ resolution: i.resolution,
1846
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio } : {},
1847
+ ...i.seed !== void 0 ? { seed: i.seed } : {}
1848
+ })
1849
+ },
1777
1850
  "kling-3.0-omni/image-to-video": {
1778
1851
  family: "job",
1779
1852
  label: "Kling O3",
@@ -3747,6 +3820,21 @@ var CATALOG_ENTRIES2 = [
3747
3820
  description: "Google Gemini Omni 1.1 Flash via KIE, first-and-last-frame mode. A start frame and an optional end frame, 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. KIE refuses registered characters in this mode, so identity comes from the frames alone. Accepted a minted character's photoreal stills on 2026-09-24 (set 9:16 for a portrait still: it defaults to 16:9 and crops). No fal equivalent.",
3748
3821
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
3749
3822
  },
3823
+ {
3824
+ id: "kie/gemini-omni-flash-1-1-reference-to-video",
3825
+ provider: "kie",
3826
+ modality: "video",
3827
+ task: "image-to-video",
3828
+ label: "Gemini Omni 1.1 Flash with references (KIE)",
3829
+ description: "Google Gemini Omni 1.1 Flash via KIE in its reference mode: the start keyframe and up to 6 character images wired into the reference port go in as up to 7 reference images, and the prompt names the keyframe as the exact scene and first frame and each character's images in order. KIE does not lock the first frame in this mode (it refuses a first frame together with references), so the clip follows the keyframe closely but may not start on it pixel for pixel; for a locked first frame with references use Kling O3. 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. No end frame.",
3830
+ // `characterReferences` mirrors
3831
+ // KIE_VIDEO_SPECS['google/gemini-omni-flash-1-1/references'] (checked by a spec).
3832
+ capabilities: {
3833
+ needsImageInput: true,
3834
+ maxInputImages: 1,
3835
+ characterReferences: { maxElements: 6, minImagesPerElement: 1, maxImagesPerElement: 6, maxTotalImages: 6 }
3836
+ }
3837
+ },
3750
3838
  {
3751
3839
  id: "kie/kling-o3-image-to-video",
3752
3840
  provider: "kie",
@@ -5367,6 +5455,9 @@ function assertImage(file, source) {
5367
5455
  // src/poll.ts
5368
5456
  var DEFAULT_TIMEOUT_MS = 6e5;
5369
5457
  var defaultSleep = (ms) => new Promise((r) => setTimeout(r, ms));
5458
+ function isTransientPollError(err) {
5459
+ return err instanceof StudioApiError && (err.status === 503 || err.status === 0);
5460
+ }
5370
5461
  async function pollUntil(what, fetchState, isDone, opts = {}) {
5371
5462
  const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
5372
5463
  const factor = opts.factor ?? 1.5;
@@ -5375,15 +5466,30 @@ async function pollUntil(what, fetchState, isDone, opts = {}) {
5375
5466
  const now = opts.now ?? Date.now;
5376
5467
  const start = now();
5377
5468
  let delay = opts.initialDelayMs ?? 2e3;
5378
- let last = await fetchState();
5379
- if (isDone(last)) return last;
5469
+ let observed = false;
5470
+ let last;
5471
+ let lastTransient;
5472
+ const poll = async () => {
5473
+ try {
5474
+ last = await fetchState();
5475
+ observed = true;
5476
+ return isDone(last);
5477
+ } catch (err) {
5478
+ if (!isTransientPollError(err)) throw err;
5479
+ lastTransient = err;
5480
+ return false;
5481
+ }
5482
+ };
5483
+ if (await poll()) return last;
5380
5484
  for (; ; ) {
5381
5485
  const elapsed = now() - start;
5382
5486
  const remaining = timeoutMs - elapsed;
5383
- if (remaining <= 0) throw new PollTimeoutError(what, timeoutMs, last);
5487
+ if (remaining <= 0) {
5488
+ if (!observed) throw lastTransient;
5489
+ throw new PollTimeoutError(what, timeoutMs, last);
5490
+ }
5384
5491
  await sleep(Math.min(delay, remaining));
5385
- last = await fetchState();
5386
- if (isDone(last)) return last;
5492
+ if (await poll()) return last;
5387
5493
  delay = Math.min(maxDelay, Math.round(delay * factor));
5388
5494
  }
5389
5495
  }
@@ -5615,7 +5721,7 @@ function affectedNodes(doc, ids) {
5615
5721
  // src/workflowTools.ts
5616
5722
  var savedId = z7.string().min(1).describe('The saved workflow id (it carries a "saved:" prefix), from studio_workflow_create or the Studio workflow list.');
5617
5723
  var opsSchema = PatchSchema.shape.ops.describe(
5618
- `The ops to apply in order, 1 to ${MAX_PATCH_OPS}: addNode, removeNode, setNodeProps, setNodeSetting, setBakedInput, connect, disconnect, exposeAsInput, freezeInput, setActiveGeneration, setLayout, group, ungroup, setGroupProps, setDocumentProps. Node ids are yours to choose (UUIDv7 recommended); a later op may reference an id added earlier in the same list. Character references on an image-to-video node: connect each image (an image-source, an image input or an image-producing node) with port "reference", in order, each character's frontal view first; they never count as the start or end frame (those are the "image" port). Only a model whose studio_workflow_describe entry carries characterReferences takes them (Kling O3). With more than one character, set which one each image shows with setNodeSetting key "referenceElements", value { "<sourceNodeId>": 2 } (an unnamed source is character 1).`
5724
+ `The ops to apply in order, 1 to ${MAX_PATCH_OPS}: addNode, removeNode, setNodeProps, setNodeSetting, setBakedInput, connect, disconnect, exposeAsInput, freezeInput, setActiveGeneration, setLayout, group, ungroup, setGroupProps, setDocumentProps. Node ids are yours to choose (UUIDv7 recommended); a later op may reference an id added earlier in the same list. Character references on an image-to-video node: connect each image (an image-source, an image input or an image-producing node) with port "reference", in order, each character's frontal view first; they never count as the start or end frame (those are the "image" port). Only a model whose studio_workflow_describe entry carries characterReferences takes them (Kling O3: 2 to 4 images per character, a locked first frame; Gemini Omni 1.1 Flash with references: 1 to 6 images in all, the start frame sent as the first reference rather than locked). With more than one character, set which one each image shows with setNodeSetting key "referenceElements", value { "<sourceNodeId>": 2 } (an unnamed source is character 1).`
5619
5725
  );
5620
5726
  var paramsSchema = z7.record(z7.string(), z7.unknown()).describe("Run parameters by input-node name, checked against the declared inputs (unknown names, missing required values and wrong shapes are issues).");
5621
5727
  var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -5644,6 +5750,8 @@ function applyErrorOf(raw, ctx) {
5644
5750
  }
5645
5751
  var REBASE_HINT = "Re-read the workflow (studio_workflow_get), rebase your ops on the current revision (node ids are stable) and apply again with that revision as baseRevision.";
5646
5752
  var RETRY_HINT = "The outcome of this attempt is unknown. Retry studio_workflow_apply with the SAME idempotencyKey and baseRevision: if the first attempt landed, the Studio returns its original result instead of applying the patch twice.";
5753
+ var CREATE_RETRY_HINT = "The outcome of this attempt is unknown. Retry studio_workflow_create with the SAME idempotencyKey, label and ops: if the first attempt landed, the Studio returns that workflow (replayed: true) instead of making a second one.";
5754
+ var CREATE_IDEMPOTENCY_HINT = "This is not a replay: that idempotencyKey was already used to create a different workflow. Send this create with a NEW idempotencyKey.";
5647
5755
  var NOT_EDITABLE_HINT = "This workflow is readable (studio_workflow_get) and runnable (studio_run_workflow with its savedId), but it cannot be patched. Build a new workflow with studio_workflow_create instead of trying to edit this one.";
5648
5756
  var LOSSY_HINT = "Read the notes: they name what the import drops for good. To go ahead, resend the SAME ops with acknowledgeLossy: true and a NEW idempotencyKey (the first patch materializes the imported document).";
5649
5757
  var IDEMPOTENCY_HINT = "This is not a replay: that key was used for a different patch. Send this patch again with a NEW idempotencyKey, on the revision above.";
@@ -5706,6 +5814,24 @@ function mapWriteFailure(err, ctx, info) {
5706
5814
  }
5707
5815
  return null;
5708
5816
  }
5817
+ function mapCreateFailure(err, ctx, idempotencyKey) {
5818
+ if (!(err instanceof StudioApiError)) return null;
5819
+ const body = isRecord(err.body) ? err.body : {};
5820
+ if (err.status === 409 && body.code === "idempotency_mismatch") {
5821
+ return { ok: false, code: "idempotency_mismatch", message: messageOf(body, ctx), hint: CREATE_IDEMPOTENCY_HINT };
5822
+ }
5823
+ if (err.status === 0 || err.status >= 500) {
5824
+ return {
5825
+ ok: false,
5826
+ code: err.status === 0 ? "network_error" : "server_error",
5827
+ status: err.status,
5828
+ message: ctx.client.redact(err.message),
5829
+ idempotencyKey,
5830
+ hint: CREATE_RETRY_HINT
5831
+ };
5832
+ }
5833
+ return null;
5834
+ }
5709
5835
  var studioWorkflowDescribe = defineTool({
5710
5836
  name: "studio_workflow_describe",
5711
5837
  description: "Describe the node vocabulary before authoring a workflow (read-only, free). Returns { tasks: [{ task, label, family, modality, jobKind, runnable, output, inputs: [{ port, wireable, cardinality, binding }], prompt: { needed, required, key } | null, settingCount, modelCount }], inputTypes (what an input node can declare), opTypes (what studio_workflow_apply accepts), limits: { maxPatchOps } }. Settings knobs and the model catalog are large, so they are dropped unless includeSettings / includeModels is true; filter with tasks to keep the result small.",
@@ -5781,22 +5907,25 @@ var studioWorkflowGet = defineTool({
5781
5907
  });
5782
5908
  var studioWorkflowCreate = defineTool({
5783
5909
  name: "studio_workflow_create",
5784
- description: 'Create a new saved workflow by applying ops to an empty document (call studio_workflow_describe first for the task vocabulary and ports). Returns { ok: true, savedId, revision, summary } (the studio_workflow_get summary shape, its projection tells you whether it can run). A bad patch returns { ok: false, code: "invalid_patch", error: { opIndex, code, message } } naming the offending op; a missing credential scope returns { ok: false, code: "forbidden", opIndex, missingScope }. Creating is free; running it with studio_run_workflow (savedId) is what spends money.',
5910
+ description: 'Create a new saved workflow by applying ops to an empty document (call studio_workflow_describe first for the task vocabulary and ports). Returns { ok: true, savedId, revision, summary, idempotencyKey } (the studio_workflow_get summary shape, its projection tells you whether it can run), plus replayed: true when an earlier attempt with the same idempotencyKey had already made it (revision is then its current one). A bad patch returns { ok: false, code: "invalid_patch", error: { opIndex, code, message } } naming the offending op; a missing credential scope returns { ok: false, code: "forbidden", opIndex, missingScope }; "idempotency_mismatch" means that key was used for a different create (send a new one); "network_error" / "server_error" carry the idempotencyKey to retry with, so a retry can never make a second workflow. A key is scoped to its project (the same key on another project makes a new workflow), and a retry after the workflow was deleted creates a new one. Creating is free; running it with studio_run_workflow (savedId) is what spends money.',
5785
5911
  inputSchema: {
5786
5912
  ops: opsSchema,
5787
5913
  label: LabelSchema.optional().describe("Display label of the saved workflow."),
5788
- projectId: z7.string().min(1).optional().describe("Project id from studio_list_projects; omit for the default project.")
5914
+ projectId: z7.string().min(1).optional().describe("Project id from studio_list_projects; omit for the default project."),
5915
+ idempotencyKey: z7.string().min(1).max(200).optional().describe("Omit on a first call (one is generated). After a network_error or server_error, retry with the idempotencyKey that result returned: the first workflow comes back instead of a second one.")
5789
5916
  },
5790
5917
  handler: async (args, ctx) => {
5918
+ const idempotencyKey = args.idempotencyKey ?? randomUUID();
5791
5919
  let res;
5792
5920
  try {
5793
5921
  res = await ctx.client.createWorkflow({
5794
5922
  ops: args.ops,
5923
+ idempotencyKey,
5795
5924
  ...args.label !== void 0 ? { label: args.label } : {},
5796
5925
  ...args.projectId !== void 0 ? { projectId: args.projectId } : {}
5797
5926
  });
5798
5927
  } catch (err) {
5799
- const mapped = mapWriteFailure(err, ctx, {});
5928
+ const mapped = mapCreateFailure(err, ctx, idempotencyKey) ?? mapWriteFailure(err, ctx, {});
5800
5929
  if (mapped) return mapped;
5801
5930
  throw err;
5802
5931
  }
@@ -5809,7 +5938,9 @@ var studioWorkflowCreate = defineTool({
5809
5938
  savedId: res.savedId,
5810
5939
  revision: res.revision,
5811
5940
  ...res.projection ? { projection: res.projection } : {}
5812
- })
5941
+ }),
5942
+ idempotencyKey,
5943
+ ...res.replayed === true ? { replayed: true } : {}
5813
5944
  };
5814
5945
  }
5815
5946
  });
@@ -7073,7 +7204,7 @@ var studioUploadBrandReference = defineTool({
7073
7204
  }
7074
7205
  });
7075
7206
  var workflowDefinitionSchema = WorkflowDefinitionSchema.describe(
7076
- `Inline workflow DAG: { id, label?, params?: [{ name, type: string|number|boolean|json, required?, label?, description?, inputType?, cardinality?: one|many, default? }], nodes: [{ id, task (one of the model tasks listed), model (catalog id, e.g. fal/nano-banana-2-edit), inputs, retry? }] }. Node inputs are bindings: {kind:"literal",value}, {kind:"param",name,wrap?:"array"}, {kind:"ref",node,path:"url",wrap?:"array"} or an ordered {kind:"list",items:[...]} of those. Image-edit nodes take inputImages (an array: one wrapped ref/param, or a list in reference order, scene frame first); image-to-video nodes take inputImageUrl (start frame) and optionally endImageUrl (end frame, on models that accept one), EXCEPT on a keyframes model (fal/flux-3-keyframes-to-video and its -draft tier), which instead takes keyframeImageUrls (an ordered list of up to 10 images) with keyframeFrameIndexes (one strictly increasing frame per image on a fixed 24 fps timeline). Pass one shape or the other, never both. To hold a character's identity through the clip, an image-to-video node on a model with character references (route/kling-o3, kie/kling-o3-image-to-video, fal/kling-o3-pro-reference-to-video) also takes referenceImageUrls (a list of character photos, grouped by character, each character's frontal view first, 2 to 4 images per character, up to 3 characters) with referenceElementIndexes (the 0-based character of each image, ascending without gaps, e.g. [0,0,0,1,1]); they never count as the start or end frame, and they need inputImageUrl.`
7207
+ `Inline workflow DAG: { id, label?, params?: [{ name, type: string|number|boolean|json, required?, label?, description?, inputType?, cardinality?: one|many, default? }], nodes: [{ id, task (one of the model tasks listed), model (catalog id, e.g. fal/nano-banana-2-edit), inputs, retry? }] }. Node inputs are bindings: {kind:"literal",value}, {kind:"param",name,wrap?:"array"}, {kind:"ref",node,path:"url",wrap?:"array"} or an ordered {kind:"list",items:[...]} of those. Image-edit nodes take inputImages (an array: one wrapped ref/param, or a list in reference order, scene frame first); image-to-video nodes take inputImageUrl (start frame) and optionally endImageUrl (end frame, on models that accept one), EXCEPT on a keyframes model (fal/flux-3-keyframes-to-video and its -draft tier), which instead takes keyframeImageUrls (an ordered list of up to 10 images) with keyframeFrameIndexes (one strictly increasing frame per image on a fixed 24 fps timeline). Pass one shape or the other, never both. To hold a character's identity through the clip, an image-to-video node on a model with character references (route/kling-o3, kie/kling-o3-image-to-video, fal/kling-o3-pro-reference-to-video) also takes referenceImageUrls (a list of character photos, grouped by character, each character's frontal view first, 2 to 4 images per character, up to 3 characters) with referenceElementIndexes (the 0-based character of each image, ascending without gaps, e.g. [0,0,0,1,1]); they never count as the start or end frame, and they need inputImageUrl. kie/gemini-omni-flash-1-1-reference-to-video takes the same two fields with 1 to 6 character images in all and no end frame: its start frame goes in as reference image 1, named in the prompt as the exact scene and first frame, because KIE does not lock a first frame in its reference mode.`
7077
7208
  );
7078
7209
  var studioRunWorkflow = defineTool({
7079
7210
  name: "studio_run_workflow",
@@ -7424,7 +7555,7 @@ function registerTools(server, base) {
7424
7555
 
7425
7556
  // src/server.ts
7426
7557
  var SERVER_NAME = "lumitra-studio";
7427
- var SERVER_VERSION = "0.9.0";
7558
+ var SERVER_VERSION = "0.11.0";
7428
7559
  function createStudioMcpServer(opts = {}) {
7429
7560
  const config = opts.config ?? resolveConfig(opts.env ?? process.env);
7430
7561
  const client = new StudioClient(config, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marlinjai/studio-mcp",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "private": false,
5
5
  "description": "Model Context Protocol (MCP) server over the Lumitra Studio HTTP API: generate images, mint characters, run workflows, swap characters into video.",
6
6
  "license": "MIT",