davinci-resolve-mcp 4.19.3 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +1 -1
- package/README.zh-CN.md +2 -2
- package/docs/SKILL.md +6 -3
- package/install.py +1 -1
- package/package.json +1 -1
- package/resolve-advanced/README.md +8 -0
- package/resolve-advanced/server/extract-frames.mjs +6 -2
- package/resolve-advanced/server/ffprobe-media.mjs +2 -0
- package/resolve-advanced/server/index.mjs +16 -7
- package/resolve-advanced/server/offline-ref-db.mjs +11 -3
- package/resolve-advanced/server/qc-sampler.mjs +2 -1
- package/resolve-advanced/server/spawn-guard.mjs +94 -0
- package/resolve-advanced/server/tools/conform.mjs +4 -1
- package/resolve-advanced/server/tools/offline_ref.mjs +0 -1
- package/resolve-advanced/vendor/conform-qc/repair/media-analysis.js +4 -0
- package/src/batch_cli.py +4 -1
- package/src/granular/common.py +1 -1
- package/src/server.py +36 -7
- package/src/utils/destructive_hook.py +7 -2
- package/src/utils/execution_lifecycle.py +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
Release history for the DaVinci Resolve MCP Server. The latest release is summarized in the root README; older entries live here to keep the README focused.
|
|
4
4
|
|
|
5
|
+
## What's New in v5.0.0 — A tool call can no longer run a command or choose the program the server spawns
|
|
6
|
+
|
|
7
|
+
**A breaking security release.** It fixes two reports made through GitHub's private vulnerability reporting: [GHSA-x2fm-g3cm-6x5w](https://github.com/samuelgursky/davinci-resolve-mcp/security/advisories/GHSA-x2fm-g3cm-6x5w), reported by Artur Chlebicki (@Artur12555), and [GHSA-h2fm-rcfg-jch9](https://github.com/samuelgursky/davinci-resolve-mcp/security/advisories/GHSA-h2fm-rcfg-jch9), reported by @3099404236. Thank you both.
|
|
8
|
+
|
|
9
|
+
### Removed (breaking)
|
|
10
|
+
|
|
11
|
+
- **`project_manager apply_spec` no longer runs spec hooks.** A hook is a command line taken from the spec, and the spec comes from the caller (inline, or any file the caller names), so `run_hooks: true` ran caller-chosen commands as the user, e.g. `bash -c '…'`. That broke the v3.0.0 rule that this server does not execute caller-supplied code. `run_hooks: true` is now refused with `SPEC_HOOKS_NOT_RUN` before the spec is read or Resolve is touched. A successful apply lists the hooks it did not run in `hooks_not_run`, so a caller relying on an `after` hook doesn't read success as "the hook ran".
|
|
12
|
+
- **`offline_ref`'s `postgres.pgDumpPath` argument.** It was spawned as given, so a caller could name any executable.
|
|
13
|
+
|
|
14
|
+
### Security
|
|
15
|
+
|
|
16
|
+
- **`apply_spec` is gated.** It was missing from the destructive registry, so safe mode and `logs/security-audit.jsonl` never saw it. It is now registered and rated MEDIUM (it creates projects, bins and timelines and changes settings, but never deletes).
|
|
17
|
+
- **The advanced server refuses a caller-chosen binary at its one entry point.** Tool arguments are `passthrough()`, and helpers take the binary to run as an option, so `conform qc run` forwarded a caller's `ffmpegPath` straight to `spawnSync`. Every tool call is now checked before its handler runs. A string under `ffmpeg`, `ffprobe`, `ffmpegPath`, `ffprobePath`, `pgDumpPath`, `findPath` or `python`, at any depth, returns `BINARY_OVERRIDE_REFUSED`. A source scan in the suite fails if a new option that selects a binary is missing from that list.
|
|
18
|
+
- **The `pg_dump` backup path no longer comes from the database name.** It used to be `/tmp/offline-ref-Sm2Timeline-backup-${database}.sql`, so `../` in the name escaped the temp folder. The name is now reduced to a safe filename, and the backup goes in a fresh private directory.
|
|
19
|
+
- **Option-like media paths are refused.** A path starting with `-`, passed where ffprobe or ffmpeg read their input or output positionally, was parsed as an option. With the guard removed, the test run showed `-report` making ffprobe write a log file. Those paths are now refused (`OPTION_LIKE_PATH_REFUSED`), or made absolute where the server builds the path itself.
|
|
20
|
+
|
|
21
|
+
### Migration
|
|
22
|
+
|
|
23
|
+
- Spec hooks: apply without `run_hooks`, then run the commands yourself. A person at a terminal can still use `davinci-resolve-mcp batch apply <spec> --run-hooks`, which keeps hooks because the person chose the file and typed the flag.
|
|
24
|
+
- `pg_dump` not on PATH: set `RESOLVE_ADVANCED_PG_DUMP` to its absolute path in the advanced server's environment.
|
|
25
|
+
|
|
26
|
+
### Not changed
|
|
27
|
+
|
|
28
|
+
- The Python server's own ffprobe calls (`_probe_media_file`, `_ffprobe_media_summary`, `media_analysis._ffprobe`, `mix_plan.probe_duration`) still pass a caller path positionally. They are the same leading-dash shape and are not covered here.
|
|
29
|
+
- Covered by unit tests and mutation checks only. No Resolve or Postgres server was involved: the `pg_dump` test uses a stand-in script.
|
|
30
|
+
|
|
5
31
|
## What's New in v4.19.3 — Timeline pin verifies the switch; audio-only media analyzes cleanly
|
|
6
32
|
|
|
7
33
|
### Fixed
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
English | [简体中文](README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
[](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
|
|
6
6
|
[](https://www.npmjs.com/package/davinci-resolve-mcp)
|
|
7
7
|
[](docs/reference/api-coverage.md)
|
|
8
8
|
[-blue.svg)](#server-modes)
|
package/README.zh-CN.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 简体中文
|
|
4
4
|
|
|
5
|
-
[](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
|
|
6
6
|
[](https://www.npmjs.com/package/davinci-resolve-mcp)
|
|
7
7
|
[](docs/reference/api-coverage.md)
|
|
8
8
|
[-blue.svg)](#服务器模式)
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](https://www.python.org/downloads/)
|
|
13
13
|
[](https://opensource.org/licenses/MIT)
|
|
14
14
|
|
|
15
|
-
> 本翻译对应
|
|
15
|
+
> 本翻译对应 v5.0.0 版 README。如与英文原版有出入,以 [英文原版](README.md) 为准。
|
|
16
16
|
|
|
17
17
|
一个 Model Context Protocol (MCP) 服务器,让 AI 助手通过官方脚本 API 控制 DaVinci Resolve Studio(达芬奇)。它提供完整的 API 覆盖,外加带护栏的工作流助手,涵盖剪辑、媒体池整理、渲染设置、审阅标记、调色、Fusion、Fairlight、项目生命周期任务、扩展开发,以及不碰源媒体的媒体分析。
|
|
18
18
|
|
package/docs/SKILL.md
CHANGED
|
@@ -937,11 +937,14 @@ Health check and declarative spec (v2.28.0+):
|
|
|
937
937
|
- `diff_to_spec(spec_path | spec)` — preview drift between a declarative spec and
|
|
938
938
|
the live project WITHOUT mutating. Returns `{actions, diff, change_count}`.
|
|
939
939
|
- `plan_spec(spec_path | spec)` — the ordered action list as a dry run.
|
|
940
|
-
- `apply_spec(spec_path | spec, dry_run?,
|
|
940
|
+
- `apply_spec(spec_path | spec, dry_run?, continue_on_error?)` —
|
|
941
941
|
reconcile the project toward the spec. Idempotent (re-runs are no-ops); color/
|
|
942
942
|
HDR settings apply in dependency order; markers added only when absent; explicit
|
|
943
|
-
`settings` override a named `color_preset
|
|
944
|
-
|
|
943
|
+
`settings` override a named `color_preset`. A spec's before/after `hooks` are
|
|
944
|
+
command lines, and the server does not run them: `run_hooks=true` is refused
|
|
945
|
+
with `SPEC_HOOKS_NOT_RUN`, and a successful apply lists the hooks it skipped in
|
|
946
|
+
`hooks_not_run`. Run them yourself, or have the user run
|
|
947
|
+
`davinci-resolve-mcp batch apply <spec> --run-hooks` in a terminal. The spec is YAML or JSON:
|
|
945
948
|
`{project, color_preset?, settings?, timelines:[{name, fps?, settings?, markers?}], hooks?}`.
|
|
946
949
|
Note: `apply_spec` reconciles the **currently open or already-existing** project;
|
|
947
950
|
creating a brand-new project from a spec depends on Resolve's `CreateProject`
|
package/install.py
CHANGED
|
@@ -37,7 +37,7 @@ from src.utils.update_check import (
|
|
|
37
37
|
|
|
38
38
|
# ─── Version ──────────────────────────────────────────────────────────────────
|
|
39
39
|
|
|
40
|
-
VERSION = "
|
|
40
|
+
VERSION = "5.0.0"
|
|
41
41
|
# Only hard floor: mcp[cli] requires Python 3.10+. There is no upper bound —
|
|
42
42
|
# Resolve's scripting bridge loads into newer interpreters on recent builds
|
|
43
43
|
# (Python 3.14 verified against Resolve Studio 20.3.2). Older Resolve builds
|
package/package.json
CHANGED
|
@@ -216,6 +216,14 @@ status + install hints):
|
|
|
216
216
|
Missing features fail with a clear, actionable message rather than crashing; the server logs a one-line
|
|
217
217
|
"needs setup" summary to stderr at startup.
|
|
218
218
|
|
|
219
|
+
> **Choosing binaries is the operator's job, not the caller's.** A tool call cannot name the program
|
|
220
|
+
> the server runs: an argument such as `ffmpegPath`, `ffprobe`, `pgDumpPath`, `findPath` or `python`
|
|
221
|
+
> holding a string is refused before any handler runs (`BINARY_OVERRIDE_REFUSED`). Put the binary on
|
|
222
|
+
> PATH, or set it in the server's environment. For `offline_ref` on a Postgres library, `pg_dump` comes
|
|
223
|
+
> from PATH or `RESOLVE_ADVANCED_PG_DUMP` (the old `postgres.pgDumpPath` argument is gone), and each
|
|
224
|
+
> backup is written to a fresh private directory under the system temp folder. A media path starting
|
|
225
|
+
> with `-` is refused wherever ffprobe or ffmpeg would read it as an option (`OPTION_LIKE_PATH_REFUSED`).
|
|
226
|
+
|
|
219
227
|
> **Pinning the AAF interpreter.** `aaf_probe.py` runs under `AAF_PROBE_PYTHON`, falling back to
|
|
220
228
|
> `PYTHON` and then plain `python3` on PATH. `install.py` sets that pin **only inside the `mcpServers`
|
|
221
229
|
> JSON entry it writes**, so a host that spawns this advanced server some other way must pin it itself —
|
|
@@ -20,6 +20,7 @@ import { spawn, spawnSync } from 'node:child_process';
|
|
|
20
20
|
import fs from 'node:fs';
|
|
21
21
|
import path from 'node:path';
|
|
22
22
|
import { requireFfmpeg } from './capabilities.mjs';
|
|
23
|
+
import { assertNotOption } from './spawn-guard.mjs';
|
|
23
24
|
|
|
24
25
|
// color_transfer values that are DISPLAY-referred (SDR + HDR display). Camera log
|
|
25
26
|
// (SLog3/LogC/RedLog) is NOT in ffmpeg's enum — it shows as 'unknown' → we refuse unless asserted.
|
|
@@ -46,6 +47,7 @@ const DISPLAY_MATRICES = new Set(['bt709', 'smpte170m', 'bt470bg', 'fcc', 'smpte
|
|
|
46
47
|
|
|
47
48
|
/** Probe a media file's video stream: colorspace tags + frame count + fps. */
|
|
48
49
|
export function probeStream(source, { ffprobe = 'ffprobe' } = {}) {
|
|
50
|
+
assertNotOption(source, 'source'); // ffprobe reads its input positionally
|
|
49
51
|
const r = spawnSync(
|
|
50
52
|
ffprobe,
|
|
51
53
|
[
|
|
@@ -140,7 +142,9 @@ function runFfmpegToFile(args, ffmpegPath) {
|
|
|
140
142
|
export async function extractFrames(clips, opts = {}) {
|
|
141
143
|
requireFfmpeg();
|
|
142
144
|
if (!opts.outDir) throw new Error('opts.outDir required');
|
|
143
|
-
|
|
145
|
+
// Absolute, so the output file ffmpeg reads positionally can never start with '-'.
|
|
146
|
+
const outDir = path.resolve(opts.outDir);
|
|
147
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
144
148
|
const ffmpeg = opts.ffmpeg || 'ffmpeg';
|
|
145
149
|
const ffprobe = opts.ffprobe || 'ffprobe';
|
|
146
150
|
const frames = {};
|
|
@@ -169,7 +173,7 @@ export async function extractFrames(clips, opts = {}) {
|
|
|
169
173
|
skipped.push({ id: c.id, reason: e.message });
|
|
170
174
|
continue;
|
|
171
175
|
}
|
|
172
|
-
const outPng = path.join(
|
|
176
|
+
const outPng = path.join(outDir, `${c.id}.png`);
|
|
173
177
|
const args = ['-v', 'error', '-i', src, '-vf', `select=eq(n\\,${frameIdx})`, '-vframes', '1', '-y', outPng];
|
|
174
178
|
try {
|
|
175
179
|
await runFfmpegToFile(args, ffmpeg);
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { spawnSync } from 'node:child_process';
|
|
7
7
|
import { requireFfmpeg } from './capabilities.mjs';
|
|
8
|
+
import { assertNotOption } from './spawn-guard.mjs';
|
|
8
9
|
|
|
9
10
|
/** Parse an "a/b" rational string → number (0 on divide-by-zero). */
|
|
10
11
|
export function ratio(s) {
|
|
@@ -21,6 +22,7 @@ export function ratio(s) {
|
|
|
21
22
|
*/
|
|
22
23
|
export function probeMedia(file, opts = {}) {
|
|
23
24
|
requireFfmpeg();
|
|
25
|
+
assertNotOption(file, 'file'); // ffprobe reads its input positionally
|
|
24
26
|
const ffprobe = opts.ffprobe || 'ffprobe';
|
|
25
27
|
const r = spawnSync(ffprobe, ['-v', 'error', '-show_streams', '-show_format', '-of', 'json', file], {
|
|
26
28
|
encoding: 'utf8',
|
|
@@ -25,6 +25,7 @@ for (const m of ['log', 'info', 'debug']) {
|
|
|
25
25
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
26
26
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
27
27
|
import { z } from 'zod';
|
|
28
|
+
import { assertNoBinaryOverrides } from './spawn-guard.mjs';
|
|
28
29
|
|
|
29
30
|
import { drpTool } from './tools/drp.mjs';
|
|
30
31
|
import { drtTool } from './tools/drt.mjs';
|
|
@@ -75,6 +76,20 @@ const toError = (err) => ({
|
|
|
75
76
|
content: [{ type: 'text', text: JSON.stringify({ error: err?.message || String(err) }, null, 2) }],
|
|
76
77
|
});
|
|
77
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Run one tool call: the single path every MCP request takes into a handler.
|
|
81
|
+
* Exported so the trust boundary is testable without a stdio transport.
|
|
82
|
+
*/
|
|
83
|
+
export async function callTool(tool, { action, args }) {
|
|
84
|
+
try {
|
|
85
|
+
// The caller chooses data, never the program the server spawns.
|
|
86
|
+
assertNoBinaryOverrides(args || {});
|
|
87
|
+
return toContent(await tool.handler({ action, args: args || {} }));
|
|
88
|
+
} catch (err) {
|
|
89
|
+
return toError(err);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
78
93
|
export async function startServer() {
|
|
79
94
|
const server = new McpServer({ name: NAME, version: VERSION }, { capabilities: { tools: {} } });
|
|
80
95
|
|
|
@@ -88,13 +103,7 @@ export async function startServer() {
|
|
|
88
103
|
args: z.object({}).passthrough().optional().describe('Action arguments'),
|
|
89
104
|
},
|
|
90
105
|
},
|
|
91
|
-
async ({ action, args }) => {
|
|
92
|
-
try {
|
|
93
|
-
return toContent(await tool.handler({ action, args: args || {} }));
|
|
94
|
-
} catch (err) {
|
|
95
|
-
return toError(err);
|
|
96
|
-
}
|
|
97
|
-
},
|
|
106
|
+
async ({ action, args }) => callTool(tool, { action, args }),
|
|
98
107
|
);
|
|
99
108
|
}
|
|
100
109
|
|
|
@@ -32,6 +32,7 @@ import { createRequire } from 'node:module';
|
|
|
32
32
|
|
|
33
33
|
const require = createRequire(import.meta.url);
|
|
34
34
|
import { requireBetterSqlite3 } from './capabilities.mjs';
|
|
35
|
+
import { binaryFromEnv } from './spawn-guard.mjs';
|
|
35
36
|
|
|
36
37
|
const DISK_DB_ROOT = path.join(os.homedir(), 'Library/Application Support/Blackmagic Design/DaVinci Resolve/Resolve Disk Database/Resolve Projects');
|
|
37
38
|
// Modern Studio installs keep the local library under "Resolve Project
|
|
@@ -333,8 +334,15 @@ async function pgSelectTimeline(client, { timelineId, timelineName }) {
|
|
|
333
334
|
function pgBackup(pg) {
|
|
334
335
|
if (pg && typeof pg.__backupFn === 'function') return pg.__backupFn();
|
|
335
336
|
const cfg = pgConfig(pg);
|
|
336
|
-
|
|
337
|
-
|
|
337
|
+
// The database name is caller data, so it never shapes the path: it is
|
|
338
|
+
// reduced to a safe filename, and the file goes in a fresh private directory
|
|
339
|
+
// rather than a predictable name in a shared tmp (GHSA-h2fm-rcfg-jch9).
|
|
340
|
+
const safeName = String(cfg.database).replace(/[^A-Za-z0-9_-]/g, '_').slice(0, 64) || 'database';
|
|
341
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'offline-ref-backup-'));
|
|
342
|
+
const out = path.join(dir, `Sm2Timeline-${safeName}.sql`);
|
|
343
|
+
// The operator picks pg_dump (PATH or RESOLVE_ADVANCED_PG_DUMP); a tool call
|
|
344
|
+
// cannot. postgres.pgDumpPath used to be accepted here and was spawned as given.
|
|
345
|
+
const dump = binaryFromEnv('RESOLVE_ADVANCED_PG_DUMP', 'pg_dump');
|
|
338
346
|
const env = { ...process.env };
|
|
339
347
|
if (cfg.password != null) env.PGPASSWORD = String(cfg.password);
|
|
340
348
|
const r = require('node:child_process').spawnSync(
|
|
@@ -344,7 +352,7 @@ function pgBackup(pg) {
|
|
|
344
352
|
);
|
|
345
353
|
if (r.status !== 0) {
|
|
346
354
|
throw new Error(
|
|
347
|
-
`pg_dump backup failed (refusing to write without a backup): ${(r.stderr || r.error?.message || 'unknown').toString().slice(-300)}.
|
|
355
|
+
`pg_dump backup failed (refusing to write without a backup): ${(r.stderr || r.error?.message || 'unknown').toString().slice(-300)}. If pg_dump isn't on PATH, set RESOLVE_ADVANCED_PG_DUMP to its absolute path in the server environment.`,
|
|
348
356
|
);
|
|
349
357
|
}
|
|
350
358
|
return out;
|
|
@@ -37,7 +37,8 @@ export function makeSamplers(opts = {}) {
|
|
|
37
37
|
const DW = opts.decodeW || 1200;
|
|
38
38
|
const DH = opts.decodeH || 720;
|
|
39
39
|
const fps = opts.fps || 24;
|
|
40
|
-
|
|
40
|
+
// Absolute, so the output path ffmpeg reads positionally can never start with '-'.
|
|
41
|
+
const tmp = path.resolve(opts.tmpDir || fs.mkdtempSync(path.join(os.tmpdir(), 'qc-sample-')));
|
|
41
42
|
const mask = metrics.buildBurnInMask(DW, DH, opts.burnInRegions);
|
|
42
43
|
let n = 0;
|
|
43
44
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* spawn-guard.mjs — what a tool caller may and may not choose about a child process.
|
|
3
|
+
*
|
|
4
|
+
* A caller picks DATA: which media file to probe, which database to back up.
|
|
5
|
+
* A caller never picks the PROGRAM. Several helpers take the binary to run as
|
|
6
|
+
* an option (`ffmpegPath`, `opts.ffprobe`, `pg.pgDumpPath`, …) so tests and the
|
|
7
|
+
* operator can point them at a specific install, and because tool arguments
|
|
8
|
+
* are `passthrough()`, any handler that forwarded its arguments wholesale let a
|
|
9
|
+
* prompt-injected agent name an arbitrary executable (GHSA-h2fm-rcfg-jch9).
|
|
10
|
+
*
|
|
11
|
+
* Two rules, enforced here:
|
|
12
|
+
*
|
|
13
|
+
* 1. `assertNoBinaryOverrides(args)` runs at the tool dispatcher, before any
|
|
14
|
+
* handler, and refuses a string under any binary-selecting key at any
|
|
15
|
+
* depth. The operator selects binaries through PATH or the environment
|
|
16
|
+
* (`binaryFromEnv`). `test/spawn-guard.test.mjs` scans the source for every
|
|
17
|
+
* option that falls back to a bare binary name, so a new one that is not in
|
|
18
|
+
* BINARY_OVERRIDE_KEYS fails the suite rather than reopening the hole.
|
|
19
|
+
*
|
|
20
|
+
* 2. `assertNotOption(value)` refuses a caller path that a child would parse
|
|
21
|
+
* as an option. A file named `-report` handed to ffprobe positionally is an
|
|
22
|
+
* option, not a file. Apply it wherever a caller path lands in a positional
|
|
23
|
+
* slot of an argv.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** Option names that select which executable a helper spawns. */
|
|
27
|
+
export const BINARY_OVERRIDE_KEYS = Object.freeze([
|
|
28
|
+
'ffmpeg',
|
|
29
|
+
'ffprobe',
|
|
30
|
+
'ffmpegPath',
|
|
31
|
+
'ffprobePath',
|
|
32
|
+
'pgDumpPath',
|
|
33
|
+
'findPath',
|
|
34
|
+
'python',
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
const KEY_SET = new Set(BINARY_OVERRIDE_KEYS);
|
|
38
|
+
const MAX_DEPTH = 64;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Throw if `args` carries a caller-chosen executable anywhere in its tree.
|
|
42
|
+
*
|
|
43
|
+
* Only a STRING under one of the keys is refused: that is the shape a binary
|
|
44
|
+
* path takes. An object under `ffprobe` (a probe result echoed back by a
|
|
45
|
+
* caller) is data and passes.
|
|
46
|
+
*/
|
|
47
|
+
export function assertNoBinaryOverrides(args, where = 'args') {
|
|
48
|
+
const visit = (value, trail, depth) => {
|
|
49
|
+
if (depth > MAX_DEPTH || value === null || typeof value !== 'object') return;
|
|
50
|
+
if (Array.isArray(value)) {
|
|
51
|
+
value.forEach((item, index) => visit(item, `${trail}[${index}]`, depth + 1));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
for (const [key, child] of Object.entries(value)) {
|
|
55
|
+
const here = `${trail}.${key}`;
|
|
56
|
+
if (KEY_SET.has(key) && typeof child === 'string') {
|
|
57
|
+
const error = new Error(
|
|
58
|
+
`${here}: a tool call cannot choose which program the server runs. ` +
|
|
59
|
+
'Put the binary on PATH, or set it in the server environment ' +
|
|
60
|
+
'(RESOLVE_ADVANCED_PG_DUMP for pg_dump), then retry without this key.',
|
|
61
|
+
);
|
|
62
|
+
error.code = 'BINARY_OVERRIDE_REFUSED';
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
visit(child, here, depth + 1);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
visit(args, where, 0);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Throw if a caller-supplied path would be parsed as an option by the child.
|
|
73
|
+
* Returns the value unchanged so it can wrap an argv element inline.
|
|
74
|
+
*/
|
|
75
|
+
export function assertNotOption(value, label = 'path') {
|
|
76
|
+
if (typeof value !== 'string' || !value.length) {
|
|
77
|
+
throw new Error(`${label} must be a non-empty string`);
|
|
78
|
+
}
|
|
79
|
+
if (value.startsWith('-')) {
|
|
80
|
+
const error = new Error(
|
|
81
|
+
`${label} '${value}' starts with '-', so the program would read it as an option. ` +
|
|
82
|
+
'Pass it as an absolute path or prefix it with ./',
|
|
83
|
+
);
|
|
84
|
+
error.code = 'OPTION_LIKE_PATH_REFUSED';
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The operator's choice of binary from the environment, else the bare name (PATH). */
|
|
91
|
+
export function binaryFromEnv(envName, fallback) {
|
|
92
|
+
const chosen = process.env[envName];
|
|
93
|
+
return typeof chosen === 'string' && chosen.trim() ? chosen.trim() : fallback;
|
|
94
|
+
}
|
|
@@ -298,7 +298,10 @@ export const conformTool = {
|
|
|
298
298
|
const { makeSamplers } = await import('../qc-sampler.mjs');
|
|
299
299
|
const need = ['lineageDb', 'snapshotId', 'referenceMovie', 'seqW', 'seqH', 'hrW', 'hrH'];
|
|
300
300
|
for (const k of need) if (a[k] == null) throw new Error(`conform.qc run needs ${k}`);
|
|
301
|
-
|
|
301
|
+
// Never hand the raw tool arguments to a helper that spawns: makeSamplers
|
|
302
|
+
// reads opts.ffmpegPath as the program to run (GHSA-h2fm-rcfg-jch9).
|
|
303
|
+
const { ffmpegPath: _callerFfmpeg, ...samplerOpts } = a;
|
|
304
|
+
const s = makeSamplers(samplerOpts);
|
|
302
305
|
// basic satisfiability: a sampled-null conform = source can't deliver → handled as turnover upstream
|
|
303
306
|
const satisfiability = (cut) => {
|
|
304
307
|
const src = (a.mediaMap && a.mediaMap[cut.source_basename]) || cut.source_path;
|
|
@@ -49,7 +49,6 @@ const pgSchema = z
|
|
|
49
49
|
password: z.string().optional().describe('NEVER hardcoded — pass it (Resolve default "DaVinci") or set PGPASSWORD'),
|
|
50
50
|
database: z.string().optional().describe('Postgres database name (or DbName)'),
|
|
51
51
|
DbName: z.string().optional().describe('Resolve DbName (alias for database)'),
|
|
52
|
-
pgDumpPath: z.string().optional().describe('Absolute path to pg_dump if not on PATH'),
|
|
53
52
|
})
|
|
54
53
|
.optional()
|
|
55
54
|
.describe('Supply to target a PostgreSQL studio database instead of a SQLite disk DB');
|
|
@@ -101,6 +101,10 @@ const FFPROBE_ARGS = [
|
|
|
101
101
|
|
|
102
102
|
/** Probe one file via ffprobe. Returns the normalized record (ok:false on failure). */
|
|
103
103
|
function probeMedia(path, { ffprobePath = 'ffprobe' } = {}) {
|
|
104
|
+
// ffprobe reads its input positionally: a path starting with '-' is an option.
|
|
105
|
+
if (typeof path !== 'string' || !path.length || path.startsWith('-')) {
|
|
106
|
+
return { path, ok: false, error: `refused: '${path}' would be read by ffprobe as an option; pass an absolute path` };
|
|
107
|
+
}
|
|
104
108
|
const r = spawnSync(ffprobePath, [...FFPROBE_ARGS, path], { encoding: 'utf8', maxBuffer: 8 * 1024 * 1024 });
|
|
105
109
|
if (r.status !== 0) return { path, ok: false, error: (r.stderr || 'ffprobe failed').slice(-200) };
|
|
106
110
|
return parseFfprobe(r.stdout, path);
|
package/src/batch_cli.py
CHANGED
|
@@ -329,7 +329,10 @@ def _run_spec_action(action: str, params: Dict[str, Any]):
|
|
|
329
329
|
r = get_resolve()
|
|
330
330
|
if r is None:
|
|
331
331
|
return None
|
|
332
|
-
|
|
332
|
+
# The terminal CLI is the one place hooks may run: the person at the
|
|
333
|
+
# keyboard chose the spec file and typed --run-hooks. MCP calls never pass
|
|
334
|
+
# allow_hooks, so the server itself does not run them.
|
|
335
|
+
return _spec_action(r, r.GetProjectManager(), action, params, allow_hooks=True)
|
|
333
336
|
|
|
334
337
|
|
|
335
338
|
def _emit_spec_result(result, *, json_mode: bool) -> int:
|
package/src/granular/common.py
CHANGED
|
@@ -93,7 +93,7 @@ if not logging.getLogger().handlers:
|
|
|
93
93
|
handlers=[logging.StreamHandler()],
|
|
94
94
|
)
|
|
95
95
|
|
|
96
|
-
VERSION = "
|
|
96
|
+
VERSION = "5.0.0"
|
|
97
97
|
logger = logging.getLogger("davinci-resolve-mcp")
|
|
98
98
|
logger.info(f"Starting DaVinci Resolve MCP Server v{VERSION}")
|
|
99
99
|
logger.info(f"Detected platform: {get_platform()}")
|
package/src/server.py
CHANGED
|
@@ -11,7 +11,7 @@ Usage:
|
|
|
11
11
|
python src/server.py --full # Start the 377-tool granular server instead
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
VERSION = "
|
|
14
|
+
VERSION = "5.0.0"
|
|
15
15
|
|
|
16
16
|
import base64
|
|
17
17
|
import os
|
|
@@ -21145,8 +21145,29 @@ def _make_spec_hook_runner(timeout: float = 120.0):
|
|
|
21145
21145
|
return _run
|
|
21146
21146
|
|
|
21147
21147
|
|
|
21148
|
-
|
|
21149
|
-
|
|
21148
|
+
#: Why an MCP call cannot run a spec's hooks. A hook is a command line taken
|
|
21149
|
+
#: from the spec, and the spec arrives from the caller (inline, or a file the
|
|
21150
|
+
#: caller names), so running it is executing caller-supplied code: the policy
|
|
21151
|
+
#: this server has kept since v3.0.0 (GHSA-x2fm-g3cm-6x5w).
|
|
21152
|
+
_SPEC_HOOKS_REFUSAL = (
|
|
21153
|
+
"project_manager.apply_spec does not run spec hooks: a hook is a command "
|
|
21154
|
+
"line from the spec, and this server does not execute caller-supplied code. "
|
|
21155
|
+
"Apply the spec without run_hooks and run the hook commands yourself, or run "
|
|
21156
|
+
"`davinci-resolve-mcp batch apply <spec> --run-hooks` from your own terminal."
|
|
21157
|
+
)
|
|
21158
|
+
|
|
21159
|
+
|
|
21160
|
+
def _spec_action(r, pm, action: str, p: Dict[str, Any], *, allow_hooks: bool = False) -> Dict[str, Any]:
|
|
21161
|
+
"""plan_spec / apply_spec / diff_to_spec — declarative project reconcile.
|
|
21162
|
+
|
|
21163
|
+
`allow_hooks` is True only for the terminal batch CLI, where the person at
|
|
21164
|
+
the keyboard typed `--run-hooks` for a spec file they chose. Every MCP call
|
|
21165
|
+
reaches this with the default and cannot run a hook.
|
|
21166
|
+
"""
|
|
21167
|
+
if action == "apply_spec" and _coerce_bool(p.get("run_hooks"), False) and not allow_hooks:
|
|
21168
|
+
# Refuse before the spec is read or Resolve is touched, so a refused
|
|
21169
|
+
# call has no partial effect.
|
|
21170
|
+
return _err(_SPEC_HOOKS_REFUSAL, code="SPEC_HOOKS_NOT_RUN", category="unsupported")
|
|
21150
21171
|
spec_path = p.get("spec_path") or p.get("path")
|
|
21151
21172
|
try:
|
|
21152
21173
|
if spec_path:
|
|
@@ -21166,7 +21187,7 @@ def _spec_action(r, pm, action: str, p: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
21166
21187
|
return _ok(project=spec.project,
|
|
21167
21188
|
**_project_spec.apply_spec(spec, executor, dry_run=True))
|
|
21168
21189
|
# apply_spec
|
|
21169
|
-
run_hooks = _coerce_bool(p.get("run_hooks"), False)
|
|
21190
|
+
run_hooks = allow_hooks and _coerce_bool(p.get("run_hooks"), False)
|
|
21170
21191
|
try:
|
|
21171
21192
|
result = _project_spec.apply_spec(
|
|
21172
21193
|
spec, executor,
|
|
@@ -21178,6 +21199,12 @@ def _spec_action(r, pm, action: str, p: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
21178
21199
|
except _project_spec.SpecError as exc:
|
|
21179
21200
|
return _err(str(exc), code="SPEC_APPLY_FAILED",
|
|
21180
21201
|
category="batch_partial", state=exc.state)
|
|
21202
|
+
if spec.hooks and not run_hooks:
|
|
21203
|
+
# Say so: a caller relying on an `after` hook must not read success as
|
|
21204
|
+
# "the hook ran".
|
|
21205
|
+
result["hooks_not_run"] = [
|
|
21206
|
+
{"when": h.when, "name": h.name, "command": h.command} for h in spec.hooks
|
|
21207
|
+
]
|
|
21181
21208
|
return _ok(**result) if result.get("success") else {"success": False, **result}
|
|
21182
21209
|
|
|
21183
21210
|
|
|
@@ -21435,10 +21462,12 @@ def project_manager(action: str, params: Optional[Dict[str, Any]] = None) -> Dic
|
|
|
21435
21462
|
declarative spec WITHOUT mutating. Spec is YAML/JSON: {project, color_preset?, settings?,
|
|
21436
21463
|
timelines:[{name,fps?,settings?,markers?}], hooks?}.
|
|
21437
21464
|
plan_spec(spec_path|spec) -> {dry_run, actions, diff, change_count} — same as apply with dry_run.
|
|
21438
|
-
apply_spec(spec_path|spec, dry_run?,
|
|
21465
|
+
apply_spec(spec_path|spec, dry_run?, continue_on_error?) -> {success, applied, failures, hooks_not_run?}
|
|
21439
21466
|
Reconcile the project toward the spec (idempotent: re-runs are no-ops). Color/HDR
|
|
21440
|
-
settings are applied in dependency order; markers only added if absent.
|
|
21441
|
-
|
|
21467
|
+
settings are applied in dependency order; markers only added if absent. Spec hooks
|
|
21468
|
+
never run from an MCP call: run_hooks=true is refused (SPEC_HOOKS_NOT_RUN), and a
|
|
21469
|
+
spec's hooks come back in hooks_not_run. Run them yourself, or use
|
|
21470
|
+
`davinci-resolve-mcp batch apply <spec> --run-hooks` in a terminal.
|
|
21442
21471
|
"""
|
|
21443
21472
|
p = _params(params)
|
|
21444
21473
|
r = get_resolve()
|
|
@@ -104,8 +104,12 @@ DESTRUCTIVE_ACTIONS_BY_TOOL: Dict[str, FrozenSet[str]] = {
|
|
|
104
104
|
"delete_by_color",
|
|
105
105
|
"delete_by_custom_data",
|
|
106
106
|
}),
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
# apply_spec creates projects, bins and timelines and changes settings.
|
|
108
|
+
# It was missing here, so safe mode and the audit log never saw it, while
|
|
109
|
+
# it could also run shell hooks from the spec (GHSA-x2fm-g3cm-6x5w). The
|
|
110
|
+
# hooks no longer run from an MCP call; this entry makes the rest gated.
|
|
111
|
+
"project_manager": frozenset({"apply_spec", "archive", "delete",
|
|
112
|
+
"safe_project_archive", "safe_project_delete"}),
|
|
109
113
|
"project_settings": frozenset({"delete_color_group"}),
|
|
110
114
|
"render": frozenset({"delete_all_jobs", "delete_job", "delete_preset"}),
|
|
111
115
|
"render_presets": frozenset({"delete_burnin"}),
|
|
@@ -384,6 +388,7 @@ NATIVE_DRY_RUN_ACTIONS: frozenset = frozenset({
|
|
|
384
388
|
("script_plugin", "safe_remove_extension"),
|
|
385
389
|
("project_manager", "safe_project_delete"),
|
|
386
390
|
("project_manager", "safe_project_archive"),
|
|
391
|
+
("project_manager", "apply_spec"),
|
|
387
392
|
("lut", "attenuate"),
|
|
388
393
|
("lut", "install"),
|
|
389
394
|
("lut", "remove"),
|
|
@@ -289,6 +289,12 @@ class RiskClassificationHook(LifecycleHook):
|
|
|
289
289
|
# wrappers refuse those unless acknowledge_trap. See archive_guard.py.
|
|
290
290
|
("project_manager", "archive"),
|
|
291
291
|
("project_manager", "safe_project_archive"),
|
|
292
|
+
# Declarative project reconcile: creates the project, bins, timelines
|
|
293
|
+
# and markers the spec names, and changes project/timeline settings to
|
|
294
|
+
# match. Additive and idempotent (it never deletes), but it does alter
|
|
295
|
+
# existing settings. Spec hooks never run from an MCP call
|
|
296
|
+
# (GHSA-x2fm-g3cm-6x5w); a request for them is refused up front.
|
|
297
|
+
("project_manager", "apply_spec"),
|
|
292
298
|
# Script execution priority. App-wide, no getter on any build, and
|
|
293
299
|
# before 21.1 it cannot be lowered again within the session; on 21.1
|
|
294
300
|
# SetHighPriority(False) restores normal (reported, issue #207).
|