davinci-resolve-mcp 5.2.4 → 5.2.6
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 +29 -0
- package/README.md +1 -1
- package/README.zh-CN.md +2 -2
- package/install.py +1 -1
- package/package.json +1 -1
- package/src/granular/common.py +1 -1
- package/src/granular/resolve_control.py +23 -6
- package/src/server.py +14 -5
- package/src/utils/preset_files.py +34 -0
- package/src/utils/probe_catalogue.py +5 -3
- package/src/utils/resolve_bridge_client.py +13 -2
- package/src/utils/resolve_bridge_ops.py +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,35 @@
|
|
|
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.2.6 — Preset exports report the file Resolve writes
|
|
6
|
+
|
|
7
|
+
From #362 by @Ghoul0718.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **Render and burn-in preset exports named the wrong file.** `ExportRenderPreset(presetName, exportPath)` and `ExportBurnInPreset` treat `exportPath` as a folder: Resolve creates it and writes `<presetName>.xml` inside, so a path ending in `.xml` becomes a folder of that name (measured on free 21.0.4.5, macOS). The tools echoed the path back as if it were the file, and the import tools could not read it. `export_render_preset` and `export_burn_in_preset` now return `export_file`, and `render_presets` `export_render` / `export_burnin` return `file`: the `.xml` to give the matching import. A failed export returns no file. The `projectlevel.export_burn_in_preset` probe checks the written `.xml` instead of the folder.
|
|
12
|
+
- On landing, the helper was made to check what is on disk: if a build writes the exact path it is given, that path is reported instead. Only the folder behaviour has been measured.
|
|
13
|
+
|
|
14
|
+
### Not verified here
|
|
15
|
+
|
|
16
|
+
- The folder behaviour is the contributor's measurement on free 21.0.4.5. This machine runs Studio 19.1.3.7 and did not measure it. `ExportLayoutPreset` and `ExportUserPreferencesPreset` wrote the exact file on the same build and are unchanged.
|
|
17
|
+
|
|
18
|
+
## What's New in v5.2.5 — The bridge keeps number keys in settings dicts
|
|
19
|
+
|
|
20
|
+
From #361 by @Ghoul0718.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- **Over the in-app bridge, settings dicts keyed by Resolve's constants reached Resolve with string keys.** The constants are numbers (`resolve.AUDIO_SYNC_MODE` is a float on 21.0.4.5), and JSON object keys are always strings, so `{AUDIO_SYNC_MODE: AUDIO_SYNC_WAVEFORM}` arrived keyed by `"1.0"`. Resolve ignores keys it does not know: `MediaPool.AutoSyncAudio` returned False and linked nothing. The client now sends a dict whose keys are not all strings as key-value pairs, and the bridge rebuilds it with the original keys. Dicts with only string keys go on the wire unchanged. `CreateSubtitlesFromAudio` and the cloud project calls take the same kind of dict.
|
|
25
|
+
|
|
26
|
+
### Upgrading
|
|
27
|
+
|
|
28
|
+
- The bridge inside Resolve is a copy made at install time. Reinstall it (or reinstall, then call the bridge's `reload`) for this fix to take effect. An older bridge given the new encoding passes the dict through unchanged, so those calls behave as before rather than worse.
|
|
29
|
+
|
|
30
|
+
### Verified
|
|
31
|
+
|
|
32
|
+
- The contributor's live run on free 21.0.4.5 (macOS): `AutoSyncAudio` returned False with an empty `Synced Audio` on the previous release and True with the audio linked on this one. Not rerun on this machine.
|
|
33
|
+
|
|
5
34
|
## What's New in v5.2.4 — The round-trip probe leaves the current timeline alone
|
|
6
35
|
|
|
7
36
|
From #364 by @Wintch.
|
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
|
-
> 本翻译对应 v5.2.
|
|
15
|
+
> 本翻译对应 v5.2.6 版 README。如与英文原版有出入,以 [英文原版](README.md) 为准。
|
|
16
16
|
|
|
17
17
|
一个 Model Context Protocol (MCP) 服务器,让 AI 助手通过官方脚本 API 控制 DaVinci Resolve Studio(达芬奇)。它提供完整的 API 覆盖,外加带护栏的工作流助手,涵盖剪辑、媒体池整理、渲染设置、审阅标记、调色、Fusion、Fairlight、项目生命周期任务、扩展开发,以及不碰源媒体的媒体分析。
|
|
18
18
|
|
package/install.py
CHANGED
|
@@ -37,7 +37,7 @@ from src.utils.update_check import (
|
|
|
37
37
|
|
|
38
38
|
# ─── Version ──────────────────────────────────────────────────────────────────
|
|
39
39
|
|
|
40
|
-
VERSION = "5.2.
|
|
40
|
+
VERSION = "5.2.6"
|
|
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
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 = "5.2.
|
|
96
|
+
VERSION = "5.2.6"
|
|
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()}")
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from src.granular.common import * # noqa: F401,F403
|
|
4
4
|
import os
|
|
5
5
|
from src.utils import typed_api_search
|
|
6
|
+
from src.utils.preset_files import preset_export_file
|
|
6
7
|
from src.utils.app_control import set_high_priority as set_resolve_high_priority
|
|
7
8
|
|
|
8
9
|
resolve = ResolveProxy()
|
|
@@ -501,17 +502,25 @@ def import_render_preset(preset_path: str) -> Dict[str, Any]:
|
|
|
501
502
|
|
|
502
503
|
@mcp.tool()
|
|
503
504
|
def export_render_preset(preset_name: str, export_path: str) -> Dict[str, Any]:
|
|
504
|
-
"""Export a render preset
|
|
505
|
+
"""Export a render preset as an .xml file inside a folder.
|
|
506
|
+
|
|
507
|
+
Resolve treats ``export_path`` as a folder: it creates the folder if needed
|
|
508
|
+
and writes ``<preset_name>.xml`` inside it (measured on 21.0.4.5). A path
|
|
509
|
+
ending in ``.xml`` becomes a folder of that name. On success the returned
|
|
510
|
+
``export_file`` is the file to pass to the matching import tool.
|
|
505
511
|
|
|
506
512
|
Args:
|
|
507
513
|
preset_name: Name of the render preset to export.
|
|
508
|
-
export_path: Absolute path
|
|
514
|
+
export_path: Absolute path of the folder the preset file is written into.
|
|
509
515
|
"""
|
|
510
516
|
resolve = get_resolve()
|
|
511
517
|
if resolve is None:
|
|
512
518
|
return {"error": "Not connected to DaVinci Resolve"}
|
|
513
519
|
result = resolve.ExportRenderPreset(preset_name, export_path)
|
|
514
|
-
|
|
520
|
+
out = {"success": bool(result), "preset_name": preset_name, "export_path": export_path}
|
|
521
|
+
if result:
|
|
522
|
+
out["export_file"] = preset_export_file(export_path, preset_name)
|
|
523
|
+
return out
|
|
515
524
|
|
|
516
525
|
|
|
517
526
|
@mcp.tool()
|
|
@@ -530,17 +539,25 @@ def import_burn_in_preset(preset_path: str) -> Dict[str, Any]:
|
|
|
530
539
|
|
|
531
540
|
@mcp.tool()
|
|
532
541
|
def export_burn_in_preset(preset_name: str, export_path: str) -> Dict[str, Any]:
|
|
533
|
-
"""Export a burn-in preset
|
|
542
|
+
"""Export a burn-in preset as an .xml file inside a folder.
|
|
543
|
+
|
|
544
|
+
Resolve treats ``export_path`` as a folder: it creates the folder if needed
|
|
545
|
+
and writes ``<preset_name>.xml`` inside it (measured on 21.0.4.5). A path
|
|
546
|
+
ending in ``.xml`` becomes a folder of that name. On success the returned
|
|
547
|
+
``export_file`` is the file to pass to the matching import tool.
|
|
534
548
|
|
|
535
549
|
Args:
|
|
536
550
|
preset_name: Name of the burn-in preset to export.
|
|
537
|
-
export_path: Absolute path
|
|
551
|
+
export_path: Absolute path of the folder the preset file is written into.
|
|
538
552
|
"""
|
|
539
553
|
resolve = get_resolve()
|
|
540
554
|
if resolve is None:
|
|
541
555
|
return {"error": "Not connected to DaVinci Resolve"}
|
|
542
556
|
result = resolve.ExportBurnInPreset(preset_name, export_path)
|
|
543
|
-
|
|
557
|
+
out = {"success": bool(result), "preset_name": preset_name, "export_path": export_path}
|
|
558
|
+
if result:
|
|
559
|
+
out["export_file"] = preset_export_file(export_path, preset_name)
|
|
560
|
+
return out
|
|
544
561
|
|
|
545
562
|
|
|
546
563
|
@mcp.tool()
|
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 = "5.2.
|
|
14
|
+
VERSION = "5.2.6"
|
|
15
15
|
|
|
16
16
|
import base64
|
|
17
17
|
import os
|
|
@@ -63,6 +63,7 @@ from src.utils.film_cues import export_cue_sheet as _export_film_cue_sheet
|
|
|
63
63
|
# Platform-specific Resolve paths
|
|
64
64
|
from src.utils.cdl import normalize_cdl_payload
|
|
65
65
|
from src.utils.media_paths import media_exists as _media_exists
|
|
66
|
+
from src.utils.preset_files import preset_export_file as _preset_export_file
|
|
66
67
|
from src.utils import archive_guard
|
|
67
68
|
from src.utils import subtitle_append_guard
|
|
68
69
|
from src.utils import typed_api_search
|
|
@@ -20343,9 +20344,13 @@ def render_presets(action: str, params: Optional[Dict[str, Any]] = None) -> Dict
|
|
|
20343
20344
|
|
|
20344
20345
|
Actions:
|
|
20345
20346
|
import_render(path) -> {success}
|
|
20346
|
-
export_render(name, path) -> {success}
|
|
20347
|
+
export_render(name, path) -> {success, file}
|
|
20347
20348
|
import_burnin(path) -> {success}
|
|
20348
|
-
export_burnin(name, path) -> {success}
|
|
20349
|
+
export_burnin(name, path) -> {success, file}
|
|
20350
|
+
Resolve treats an export `path` as a FOLDER: it creates it and writes
|
|
20351
|
+
`<name>.xml` inside (a path ending in .xml becomes a folder of that
|
|
20352
|
+
name). On success `file` is that .xml, the path to give import_render /
|
|
20353
|
+
import_burnin.
|
|
20349
20354
|
list_burnin() -> {presets} — Resolve 21.0.4+; burn-in preset names usable
|
|
20350
20355
|
with the render tool's DataBurnIn setting and load_burnin_preset on
|
|
20351
20356
|
project_settings / timeline_item
|
|
@@ -20359,11 +20364,15 @@ def render_presets(action: str, params: Optional[Dict[str, Any]] = None) -> Dict
|
|
|
20359
20364
|
if action == "import_render":
|
|
20360
20365
|
return {"success": bool(r.ImportRenderPreset(p["path"]))}
|
|
20361
20366
|
elif action == "export_render":
|
|
20362
|
-
|
|
20367
|
+
if not r.ExportRenderPreset(p["name"], p["path"]):
|
|
20368
|
+
return {"success": False}
|
|
20369
|
+
return {"success": True, "file": _preset_export_file(p["path"], p["name"])}
|
|
20363
20370
|
elif action == "import_burnin":
|
|
20364
20371
|
return {"success": bool(r.ImportBurnInPreset(p["path"]))}
|
|
20365
20372
|
elif action == "export_burnin":
|
|
20366
|
-
|
|
20373
|
+
if not r.ExportBurnInPreset(p["name"], p["path"]):
|
|
20374
|
+
return {"success": False}
|
|
20375
|
+
return {"success": True, "file": _preset_export_file(p["path"], p["name"])}
|
|
20367
20376
|
elif action == "list_burnin":
|
|
20368
20377
|
missing = _requires_method(r, "GetBurnInPresetList", "21.0.4")
|
|
20369
20378
|
if missing:
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Where Resolve writes an exported render or burn-in preset.
|
|
2
|
+
|
|
3
|
+
``ExportRenderPreset(presetName, exportPath)`` and
|
|
4
|
+
``ExportBurnInPreset(presetName, exportPath)`` treat ``exportPath`` as a
|
|
5
|
+
folder, not a file. Resolve creates the folder if needed and writes
|
|
6
|
+
``<presetName>.xml`` inside it. Measured on free 21.0.4.5 (macOS) through the
|
|
7
|
+
in-app bridge:
|
|
8
|
+
|
|
9
|
+
- ``/tmp/a/My.xml`` became the folder ``/tmp/a/My.xml/`` holding ``My.xml``
|
|
10
|
+
- ``/tmp/b/other.xml`` became the folder ``/tmp/b/other.xml/`` holding ``My.xml``
|
|
11
|
+
- ``/tmp/c`` (an existing folder) received ``/tmp/c/My.xml``
|
|
12
|
+
|
|
13
|
+
The import calls take the file itself, so a caller needs the real file path to
|
|
14
|
+
round-trip a preset.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import os
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def preset_export_file(export_path: str, preset_name: str) -> str:
|
|
23
|
+
"""The file Resolve writes when it exports ``preset_name`` to ``export_path``.
|
|
24
|
+
|
|
25
|
+
The folder behaviour above is one build's measurement. If ``export_path``
|
|
26
|
+
is itself a file after the export and ``<export_path>/<preset_name>.xml``
|
|
27
|
+
is not, the build wrote the exact path it was given, so that path is the
|
|
28
|
+
file. Otherwise, including before anything exists, the answer is the
|
|
29
|
+
measured one.
|
|
30
|
+
"""
|
|
31
|
+
inside = os.path.join(export_path, f"{preset_name}.xml")
|
|
32
|
+
if os.path.isfile(export_path) and not os.path.isfile(inside):
|
|
33
|
+
return export_path
|
|
34
|
+
return inside
|
|
@@ -780,9 +780,11 @@ def _probe_projectlevel_render_preset(ctx):
|
|
|
780
780
|
|
|
781
781
|
@probe("projectlevel.export_burn_in_preset", "projectlevel", timeout=120, destructive=True)
|
|
782
782
|
def _probe_projectlevel_burnin(ctx):
|
|
783
|
-
path
|
|
784
|
-
|
|
785
|
-
|
|
783
|
+
# Resolve treats the export path as a folder and writes <name>.xml inside it.
|
|
784
|
+
folder = ctx.work / "burnin"
|
|
785
|
+
ok = ctx.resolve.ExportBurnInPreset("Default", str(folder))
|
|
786
|
+
written = folder / "Default.xml"
|
|
787
|
+
return combine(ok, written.is_file() and written.stat().st_size > 0)
|
|
786
788
|
|
|
787
789
|
|
|
788
790
|
@probe("projectlevel.archive_project", "projectlevel", timeout=600, destructive=True,
|
|
@@ -290,11 +290,22 @@ class BridgeTransport:
|
|
|
290
290
|
|
|
291
291
|
|
|
292
292
|
def _encode_argument(value: Any) -> Any:
|
|
293
|
-
"""Send a proxy back as the handle it stands for.
|
|
293
|
+
"""Send a proxy back as the handle it stands for.
|
|
294
|
+
|
|
295
|
+
A dict whose keys are not all strings goes as ``{"__pairs__": [[k, v], ...]}``.
|
|
296
|
+
JSON object keys are always strings, so ``{resolve.AUDIO_SYNC_MODE: ...}``
|
|
297
|
+
would otherwise reach Resolve keyed by ``"1.0"`` instead of the constant, and
|
|
298
|
+
Resolve ignores keys it does not recognise (AutoSyncAudio returned False on
|
|
299
|
+
21.0.4.5 for exactly this reason). The bridge rebuilds the dict with the
|
|
300
|
+
original keys. A dict that itself has a ``"__pairs__"`` key goes the same way,
|
|
301
|
+
so the marker is never ambiguous on the wire.
|
|
302
|
+
"""
|
|
294
303
|
if isinstance(value, BridgeProxy):
|
|
295
304
|
return {"__handle__": value._handle}
|
|
296
305
|
if isinstance(value, dict):
|
|
297
|
-
|
|
306
|
+
if "__pairs__" not in value and all(isinstance(k, str) for k in value):
|
|
307
|
+
return {k: _encode_argument(v) for k, v in value.items()}
|
|
308
|
+
return {"__pairs__": [[k, _encode_argument(v)] for k, v in value.items()]}
|
|
298
309
|
if isinstance(value, (list, tuple)):
|
|
299
310
|
return [_encode_argument(v) for v in value]
|
|
300
311
|
return value
|
|
@@ -593,11 +593,27 @@ class ResolveOperations:
|
|
|
593
593
|
handle = value.get("__handle__")
|
|
594
594
|
if handle is not None:
|
|
595
595
|
return self._resolve_target(handle)
|
|
596
|
+
if "__pairs__" in value:
|
|
597
|
+
# A dict with non-string keys (see the client's _encode_argument).
|
|
598
|
+
pairs = value["__pairs__"]
|
|
599
|
+
if len(value) != 1 or not isinstance(pairs, list):
|
|
600
|
+
raise OperationError("invalid_arguments", "__pairs__ must be the only key and hold a list")
|
|
601
|
+
return {self._decode_key(pair): self._decode(pair[1]) for pair in pairs}
|
|
596
602
|
return {k: self._decode(v) for k, v in value.items()}
|
|
597
603
|
if isinstance(value, list):
|
|
598
604
|
return [self._decode(v) for v in value]
|
|
599
605
|
return value
|
|
600
606
|
|
|
607
|
+
@staticmethod
|
|
608
|
+
def _decode_key(pair: Any) -> Any:
|
|
609
|
+
"""The key of one ``[key, value]`` pair; only JSON scalars can be dict keys."""
|
|
610
|
+
if not (isinstance(pair, list) and len(pair) == 2):
|
|
611
|
+
raise OperationError("invalid_arguments", "a __pairs__ entry must be [key, value]")
|
|
612
|
+
key = pair[0]
|
|
613
|
+
if not (key is None or isinstance(key, (bool, int, float, str))):
|
|
614
|
+
raise OperationError("invalid_arguments", "a __pairs__ key must be a number, string, bool or null")
|
|
615
|
+
return key
|
|
616
|
+
|
|
601
617
|
def op_call(self, arguments: Dict[str, Any]) -> Any:
|
|
602
618
|
"""Invoke one method on a live Resolve object. See the module docstring.
|
|
603
619
|
|