davinci-resolve-mcp 5.2.7 → 5.2.9

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 CHANGED
@@ -2,6 +2,45 @@
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.9 — Bad track indexes and misplaced arguments are refused, not dropped
6
+
7
+ From #370 and #372 by @willturner-maker, plus a Traditional Chinese README from #369 by @monarchsofchaos004-gif.
8
+
9
+ ### Fixed
10
+
11
+ - **A `clip_infos` `track_index` that names no track landed on track 1 (#370).** Resolve places a clipInfo whose `trackIndex` is 0, past the track count, or not an int (`"2"`) on track 1 and returns the new items, so the read-back reported the wrong-track placement as verified. Rows are now checked before anything reaches `AppendToTimeline`, in both servers. `track_index` must be a 1-based integer; a digit string is coerced. It must name an existing track of the row's `media_type`, or either type when none is set. `media_type` must be 1 or 2. Refusals carry `INVALID_TRACK_INDEX`, `TRACK_INDEX_OUT_OF_RANGE` (with the timeline's track counts) or `INVALID_MEDIA_TYPE`, and one bad row refuses the batch. `create_timeline_from_clips` validates every row before the timeline exists and adds the tracks the rows name.
12
+ - **Arguments passed beside `action` were dropped (#372).** FastMCP ignores arguments the tool's signature does not name, so `timeline(action="get_name", timeline_name="vB")` ran on the current timeline with success and no `ignored_params`. Such calls are now refused before the tool runs, with `isError: true`, code `UNKNOWN_ARGUMENTS` and, for the compound tools, the corrected `params`. Applies to every tool in both servers.
13
+
14
+ ### Added
15
+
16
+ - **`README.zh-TW.md`**, a Traditional Chinese (Taiwan) translation (#369). Its version badge and `本翻譯對應` line are part of every release bump, enforced by `test_release_surface_drift`.
17
+
18
+ ### Not changed
19
+
20
+ - **#371** (probe cost per item up in 5.1.0): the probe makes the same 14 Resolve calls per item in v4.19.3, v5.1.0 and this release, and the server's own time is about 0.013 ms per item, so the measured change is Resolve's response time, not the server.
21
+
22
+ ### Not verified here
23
+
24
+ - Offline tests only. The reports were measured on Studio 21.2.0.6; this machine runs Studio 19.1.3.7, and no live Resolve run was made for this release.
25
+
26
+ ## What's New in v5.2.8 — Three calls stop answering success while dropping the request
27
+
28
+ From #365, #366 and #368 by @willturner-maker.
29
+
30
+ ### Fixed
31
+
32
+ - **`record_frame_mode` beside `clip_infos` was dropped (#365).** `media_pool` `append_to_timeline` and `create_timeline_from_clips` read the mode only from each row, so `record_frame_mode: "absolute"` passed at the top level was ignored and an absolute frame landed start-relative with `success: true`. The top-level mode now applies to every row that sets none of its own. A row's own mode still wins, and an absolute frame before the timeline start is refused, as it already was per row.
33
+ - **`timeline.duplicate` archived the source timeline (#366).** Version-on-mutate archived the untouched source before every duplicate, leaving `_archived_vNN` siblings that read as evidence of an edit. Duplicate stays registered, so safe mode and the audit log still apply, but it no longer archives. `_versioning.skipped_reason` is `source_timeline_unchanged`.
34
+ - **`render.set_settings` took a `TargetDir` that does not exist (#368).** Resolve accepts it there and refuses only at `add_job` or render start. `set_settings` and the granular `set_render_settings` now refuse it before anything is sent, with code `TARGET_DIR_NOT_FOUND`.
35
+
36
+ ### Not changed
37
+
38
+ - **#367** (`get_clips_linked` ignoring `timeline_id`) does not reproduce against the compound tool: the pin switches, the item is found on the pinned timeline and the current timeline is restored. A regression test now covers it.
39
+
40
+ ### Not verified here
41
+
42
+ - Offline tests only. The reports were measured on Studio 21.2.0.6; this machine runs Studio 19.1.3.7, and no live Resolve run was made for this release.
43
+
5
44
  ## What's New in v5.2.7 — Preset and media rows live-tested with fixtures
6
45
 
7
46
  From #363 by @Ghoul0718. No server behaviour changes.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # DaVinci Resolve MCP Server
2
2
 
3
- English | [简体中文](README.zh-CN.md)
3
+ English | [简体中文](README.zh-CN.md) | [繁體中文](README.zh-TW.md)
4
4
 
5
- [![Version](https://img.shields.io/badge/version-5.2.7-blue.svg)](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
5
+ [![Version](https://img.shields.io/badge/version-5.2.9-blue.svg)](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
6
6
  [![npm](https://img.shields.io/npm/v/davinci-resolve-mcp.svg?label=npm&color=CB3837)](https://www.npmjs.com/package/davinci-resolve-mcp)
7
7
  [![API Coverage](https://img.shields.io/badge/API%20Coverage-100%25-brightgreen.svg)](docs/reference/api-coverage.md)
8
8
  [![Tools](https://img.shields.io/badge/MCP%20Tools-37%20(390%20full)-blue.svg)](#server-modes)
package/README.zh-CN.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # DaVinci Resolve MCP 服务器
2
2
 
3
- [English](README.md) | 简体中文
3
+ [English](README.md) | 简体中文 | [繁體中文](README.zh-TW.md)
4
4
 
5
- [![Version](https://img.shields.io/badge/version-5.2.7-blue.svg)](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
5
+ [![Version](https://img.shields.io/badge/version-5.2.9-blue.svg)](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
6
6
  [![npm](https://img.shields.io/npm/v/davinci-resolve-mcp.svg?label=npm&color=CB3837)](https://www.npmjs.com/package/davinci-resolve-mcp)
7
7
  [![API Coverage](https://img.shields.io/badge/API%20Coverage-100%25-brightgreen.svg)](docs/reference/api-coverage.md)
8
8
  [![Tools](https://img.shields.io/badge/MCP%20Tools-37%20(390%20full)-blue.svg)](#服务器模式)
@@ -12,7 +12,7 @@
12
12
  [![Python](https://img.shields.io/badge/python-3.10+-green.svg)](https://www.python.org/downloads/)
13
13
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
14
14
 
15
- > 本翻译对应 v5.2.7 版 README。如与英文原版有出入,以 [英文原版](README.md) 为准。
15
+ > 本翻译对应 v5.2.9 版 README。如与英文原版有出入,以 [英文原版](README.md) 为准。
16
16
 
17
17
  一个 Model Context Protocol (MCP) 服务器,让 AI 助手通过官方脚本 API 控制 DaVinci Resolve Studio(达芬奇)。它提供完整的 API 覆盖,外加带护栏的工作流助手,涵盖剪辑、媒体池整理、渲染设置、审阅标记、调色、Fusion、Fairlight、项目生命周期任务、扩展开发,以及不碰源媒体的媒体分析。
18
18
 
@@ -0,0 +1,423 @@
1
+ # DaVinci Resolve MCP 伺服器
2
+
3
+ [English](README.md) | [简体中文](README.zh-CN.md) | 繁體中文
4
+
5
+ [![Version](https://img.shields.io/badge/version-5.2.9-blue.svg)](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
6
+ [![npm](https://img.shields.io/npm/v/davinci-resolve-mcp.svg?label=npm&color=CB3837)](https://www.npmjs.com/package/davinci-resolve-mcp)
7
+ [![API Coverage](https://img.shields.io/badge/API%20Coverage-100%25-brightgreen.svg)](docs/reference/api-coverage.md)
8
+ [![Tools](https://img.shields.io/badge/MCP%20Tools-37%20(390%20full)-blue.svg)](#伺服器模式)
9
+ [![Advanced](https://img.shields.io/badge/Advanced%20(offline)-18%20tools-blueviolet.svg)](#伺服器模式)
10
+ [![Tested](https://img.shields.io/badge/Live%20Tested-93.6%25-green.svg)](docs/reference/api-coverage.md#test-results)
11
+ [![DaVinci Resolve](https://img.shields.io/badge/DaVinci%20Resolve-18.5+-darkred.svg)](https://www.blackmagicdesign.com/products/davinciresolve)
12
+ [![Python](https://img.shields.io/badge/python-3.10+-green.svg)](https://www.python.org/downloads/)
13
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
14
+
15
+ > 本翻譯對應 v5.2.9 版 README。如與英文原版有出入,以[英文原版](README.md)為準。
16
+
17
+ 一個 Model Context Protocol(MCP)伺服器,讓 AI 助理透過官方腳本 API 控制 DaVinci Resolve Studio。它提供完整的 API 覆蓋,並附上有防護機制的工作流程輔助工具,涵蓋剪輯、媒體池整理、算圖輸出設定、審閱標記、調色、Fusion、Fairlight、專案生命週期作業、擴充功能開發,以及不更動原始素材的媒體分析。
18
+
19
+ [![本機控制面板](https://raw.githubusercontent.com/samuelgursky/davinci-resolve-mcp/main/docs/images/control-panel/01-overview.png)](docs/guides/control-panel.md)
20
+
21
+ 伺服器內建一個本機瀏覽器控制面板,可用來查看 Resolve 狀態、執行不更動原始素材的分析、深入檢視已分析的片段與鏡頭,以及直接在畫面上編輯分析結果。完整導覽請見[控制面板指南](docs/guides/control-panel.md)。
22
+
23
+ ## 快速開始
24
+
25
+ ```bash
26
+ npx davinci-resolve-mcp setup
27
+ ```
28
+
29
+ 連線之前,請先開啟 DaVinci Resolve Studio,把 **Preferences > General > External scripting using** 設為 **Local**。(**免費版**設定這個偏好沒有用,請見下方[免費版](#免費版應用程式內橋接)。)npm 啟動器會在你的使用者應用程式資料目錄下安裝一份受管理的副本,再執行通用的 Python 安裝程式。安裝程式會建立虛擬環境、偵測 Resolve 路徑,並可自動設定 Claude Desktop、Claude Code、Cursor、VS Code、Windsurf、Zed、Continue、Cline、Roo Code、OpenCode、Codex CLI 與 JetBrains 系列 IDE。
30
+
31
+ 從原始碼安裝:
32
+
33
+ ```bash
34
+ git clone https://github.com/samuelgursky/davinci-resolve-mcp.git
35
+ cd davinci-resolve-mcp
36
+ python install.py
37
+ ```
38
+
39
+ 各平台路徑、各用戶端的設定方式與手動設定,請見[安裝與設定](docs/install.md)。
40
+
41
+ 安裝程式與伺服器會到 GitHub 最新的 release 檢查 MCP 是否有更新。檢查採盡力而為並有頻率限制;伺服器絕不會為了跳出提示而卡住 MCP 啟動。安裝程式可以提示、稍後再提醒、略過某個版本、停用檢查,或對乾淨的 git 工作目錄啟用可選的安全自動更新。
42
+
43
+ ## 免費版(應用程式內橋接)
44
+
45
+ Blackmagic 把*外部*腳本限定給 Studio 使用:在免費版上,不論偏好設定怎麼設,
46
+ `scriptapp("Resolve")` 都會拒絕外部程序。到 Resolve 21.0.x 為止,**Workspace ▸ Scripts**
47
+ 選單沒有這項限制——從這裡啟動的腳本會拿到執行中的 `resolve` 物件(在免費版 21.0.3.7 上實測)——
48
+ 因此伺服器可以透過一支在 Resolve *內部*執行的小腳本連到免費版,由它經過一個需要驗證的本機迴路(loopback)
49
+ 監聽埠把 `resolve` 物件轉出來。**Resolve 21.1 已把 Python 腳本改成 Studio 限定。**
50
+ 在免費版 21.1 上,Scripts 選單完全不再列出 `.py` 檔(#203 回報於 Fedora 44;同一個資料夾裡的
51
+ Lua 腳本仍正常列出)。Console 是否仍能執行 Python 尚未確認,在實測之前,請把這個橋接視為 21.0.x 專用的路徑。
52
+
53
+ ```bash
54
+ python scripts/install_resolve_bridge.py
55
+ # 重新啟動 Resolve,開啟一個專案,然後:Workspace > Scripts > resolve_bridge
56
+ ```
57
+
58
+ 安裝程式與 MCP 用戶端預設使用 `~/.config/davinci-resolve-mcp/bridge.json`。
59
+ 若要把需要驗證的橋接設定檔放在別處,請在執行安裝程式時以及 MCP 用戶端的環境中設定
60
+ `DAVINCI_RESOLVE_BRIDGE_CONFIG`,兩邊都會使用該路徑。
61
+
62
+ 監聽埠啟動後,只要外部腳本無法使用,就會**自動**改走橋接,不需要設定任何環境變數。
63
+ 設定 `DAVINCI_RESOLVE_BRIDGE=1` 則會*強制*使用橋接:它會成為唯一嘗試的傳輸方式,
64
+ 所以橋接沒有回應時會回報它自己的錯誤,而不會默默退回其他傳輸方式。當你打算就靠橋接這條路時再使用它。
65
+
66
+ 在 **macOS** 上,Resolve 只會在兩個地方找 Python 3:先看 `PYTHON3HOME` 環境變數,
67
+ 再看 `/usr/local/bin/python3`。Homebrew、pyenv、uv 與 conda 都不會裝在這兩處,
68
+ 所以腳本會默默地一直不出現在選單裡。python.org 的安裝版可以用,因為它的安裝程式會建立
69
+ `/usr/local/bin/python3`——但你不必另外安裝:讓 Resolve 指向你現有的直譯器即可,不需要 `sudo`。
70
+
71
+ ```bash
72
+ launchctl setenv PYTHON3HOME "$(python3 -c 'import sys; print(sys.prefix)')"
73
+ ```
74
+
75
+ 請用 `launchctl setenv`,不要用 `export`——Resolve 是從 Dock 啟動的,看不到你 shell 的環境變數。
76
+ 設定完請重新啟動 Resolve。安裝時會一併放入一支 Lua 測試腳本,方便你分辨是「沒偵測到 Python」還是資料夾放錯。
77
+
78
+ 有兩個常踩的地方(#182)。該前綴路徑底下必須**同時**有 `lib/libpython3.X.dylib`
79
+ 與 `bin/python3`,而且名稱必須正好是這個**不含版本號**的名字——Homebrew 的 framework 版本
80
+ 常常只附 `bin/python3.13`,對 Resolve 來說只算半個 Python,現在安裝程式的事前檢查會明確指出這點,
81
+ 而不是回報這是可用的前綴路徑。另外,`launchctl setenv` **重新開機後就會失效**;
82
+ 如果幾週後腳本沒有任何錯誤就不再出現在選單,原因就在這裡。若要永久生效,請把直譯器放到 Resolve
83
+ 本來就會找的位置(這個做法需要 `sudo`,並請確認 `/usr/local/bin` 在 `PATH` 中沒有排在你平常用的 Python 前面):
84
+
85
+ ```bash
86
+ sudo ln -s "$(command -v python3)" /usr/local/bin/python3
87
+ ```
88
+
89
+ 已在免費版 21.0.3.7 與 Studio 19.1.3.7(皆為 macOS)上驗證。v2.70.1 新增的 Windows 路徑(issue #106)
90
+ 發佈時尚未驗證;之後免費版 21.0.1.11(issue #109)與免費版 21.0.3.7(issue #112)的回報顯示,
91
+ 在 Windows 11 上,橋接從 `%PROGRAMDATA%` 與 `%APPDATA%` **兩處**都能安裝、列出並提供服務,
92
+ 所以這些路徑現在是已確認而非推測。Linux 也已確認:免費版 20.3.2.9 的一則回報(issue #129,Fedora 43)
93
+ 顯示橋接安裝到 `~/.local/share/DaVinciResolve/Fusion/Scripts/Utility`,搭配系統 Python 正常列出
94
+ (Linux 沒有上述的偵測問題),並且端對端正常運作。現在沒有任何平台是建立在推測上:macOS 為直接驗證,
95
+ Windows 與 Linux 依據使用者回報。
96
+
97
+ 注意,橋接在提供服務期間會一直佔用它的連接埠。v2.70.3 之前,Windows 上的橋接可能在 Resolve
98
+ 關閉後仍未結束,擋住下一次工作階段的監聽埠;如果你用的是較舊的版本且橋接沒有回應,
99
+ 請檢查是否有殘留的 `fuscript.exe` 還佔著該連接埠。
100
+
101
+ 這是官方文件記載的應用程式內路徑,不是規避授權,但 Blackmagic 有可能關閉它——請把它視為
102
+ 「在被關閉之前都會支援」的等級。僅限本機迴路、請求以 HMAC 簽章、nonce 只能使用一次。
103
+
104
+ ## 本機控制面板
105
+
106
+ 在儲存庫根目錄啟動單人使用的本機控制面板:
107
+
108
+ ```bash
109
+ venv/bin/python -m src.control_panel
110
+ ```
111
+
112
+ 這個指令會啟動一個只聽本機迴路的伺服器,並在瀏覽器中開啟控制面板,網址會帶著每次啟動各自產生的存取權杖(`http://127.0.0.1:8765/#token=…`)——請使用這個完整網址;沒有權杖的請求會被面板拒絕。若要讓 AI 程式助理代勞,可以這樣說:**「Open the Resolve MCP control panel for this repo.」**(幫這個儲存庫開啟 Resolve MCP 控制面板)。除非你的 Python 環境已經啟用,否則 AI 助理應使用 `venv/bin/python -m src.control_panel`。保存下來的分析工作在每一段成功完成後會自動更新本機搜尋索引;手動的 Build Index 動作是用來從既有報告重建索引。
113
+
114
+ ## 伺服器模式
115
+
116
+ | 模式 | 進入點 | 工具數 | 適合對象 |
117
+ |------|--------|--------|----------|
118
+ | 複合(Compound) | `src/server.py` | 37 | 多數 AI 助理的預設模式。相關的 Resolve 操作以 action 參數歸在同一個工具底下,減少上下文用量。 |
119
+ | 完整/細粒度(Full / granular) | `src/server.py --full` 或 `src/resolve_mcp_server.py` | 390 | 想要每個 Resolve API 方法各對應一個 MCP 工具的進階使用者。 |
120
+
121
+ 除非你確實需要「一個方法一個工具」的細粒度介面,否則建議使用複合伺服器。
122
+
123
+ ### Advanced 伺服器——超出腳本 API 的部分(選用,Node)
124
+
125
+ 同一個套件還附帶第二個選用的 MCP 伺服器:**`davinci-resolve-advanced-mcp`**(執行檔
126
+ `bin/davinci-resolve-advanced-mcp.mjs`)。Python 伺服器是透過官方認可的腳本 API 操作*執行中*的 Resolve,
127
+ 而 Advanced 伺服器做的是 API **做不到**的事——它讀取與編輯 Resolve 的**檔案**(`.drp` / `.drt` / `.drx`),
128
+ 並在**不需要開啟 Resolve** 的情況下套用資料庫/XML 層級的變更,所以在雲端*或*本機都能執行。共 18 個工具:
129
+ `drp`、`drt`、`drx`(逐片段的調色編解碼器,**另含一套確定性、可離線使用的調色/QC 功能**——同機內與跨機的膚色比對
130
+ (v2 膚色線指標)+B-roll+中性色塊白平衡比對、比對參考畫面、飽和度/黑位平衡、對比正規化、ASC CDL 匯入、
131
+ 無損調色轉移+整季風格製作、掛載具名 LUT、示波器讀值+意圖標籤、調色驗證、以顯示為準的影格擷取、播出規範 QC)、`offline_ref`、
132
+ `conform`(以影格為準的套片/重新連結 QC+來源脈絡)、`color_trace`(在重新套片後延續調色)、
133
+ `fusion`、`audio_plan`、`fairlight`(匯流排路由)、`audio`、`project_read`、`project_db`、`pipeline`
134
+ (**以資料庫為準的流程**:把 YAML 專案規格編譯成標準的 SQLite 資料庫,再以關卡、來源紀錄,以及意圖↔實際的偏移偵測來執行各階段)、
135
+ `capabilities`、`deliverable`(交付物 QC/規範檢查)、`media`(媒體前端/AE 匯入)、`editorial`(剪輯完整性/變更清單)、
136
+ `provenance`(來源紀錄/稽核/單集報告)。它也可以**當作函式庫**使用(可匯入的引擎 API),不只能以伺服器方式啟動。
137
+
138
+ DRX 調色寫入已**針對 Resolve Studio 實機校準**:調色參數預設使用 Resolve 畫面上面板的單位
139
+ (`space: 'ui' | 'drx'`),結構性寫入(窗口、限定器、HDR 區域、HSL 曲線、ColorSlice、模糊/鍵控/動態效果)
140
+ 都經過面板讀回驗證——各控制項的狀態見 `resolve-advanced/vendor/drx-parameters/CALIBRATION-STATUS.md`。
141
+ 它也補上一個原本只能在介面上做的功能:**以程式執行「Cleanup Node Graph」**(單一片段用 `drx` `relayout`,
142
+ 整個專案用 `project_db` `relayout_node_graphs`)——節點排版整理好,調色內容逐位元組保留。
143
+
144
+ 與即時伺服器一起加入設定(兩者都包含在同一次 `npm install` 中):
145
+
146
+ ```json
147
+ {
148
+ "mcpServers": {
149
+ "davinci-resolve": { "command": "<python>", "args": ["<path>/src/server.py"] },
150
+ "davinci-resolve-advanced": { "command": "node", "args": ["<path>/bin/davinci-resolve-advanced-mcp.mjs"] }
151
+ }
152
+ }
153
+ ```
154
+
155
+ `install.py` 會印出這兩個項目。核心是純 JS/MIT 授權,不需要原生模組;少數功能需要使用者自行安裝的工具
156
+ (`audio` 需要 ffmpeg,部分路徑需要 `sharp`/`better-sqlite3`)——呼叫 `capabilities` 工具可查看即時狀態與安裝提示。
157
+
158
+ 與 Python 伺服器不同,這一個有 Node 相依套件。`npx davinci-resolve-mcp setup` 會把它們安裝到受管理的安裝目錄
159
+ (在 `resolve-advanced/` 底下執行 `npm install --omit=dev --omit=optional`),裝好之後才註冊執行檔。
160
+ 如果無法安裝——離線,或沒有 npm——setup 會改為 Advanced 伺服器註冊一個 `npx` 指令,所以它寫入的項目一定能啟動。
161
+ 若要修復既有安裝而不重跑 setup:`npx davinci-resolve-mcp sync`。
162
+
163
+ ### Bradford Post Assistant——受管理的應用程式(封閉測試中)
164
+
165
+ 維護者也在這個開源基礎上打造了 **Bradford Post Assistant** 桌面應用程式。MCP 伺服器讓 AI
166
+ 助理有了「手」,Post Assistant 則是圍繞這些工具的工作副駕駛——一個在本機執行的後製 AI 助理,客戶素材永遠不會離開工作站:
167
+
168
+ - **後製副駕駛**——一個在 DaVinci Resolve 旁邊執行的桌面應用程式,即時觀察工作階段(時間軸、調色與影格,
169
+ 不只是 API 呼叫),內建 AI 助理與代理執行環境、本機媒體分析(逐字稿、影格分析、剪輯判讀),以及應用程式內的套片 QC。
170
+ - **記憶**——持久保存、加密存放在本機的助理記憶,加上從你流程中解出的事實所學到的跨集經驗
171
+ (整季風格偏移、各攝影機的校正預設值、代表畫面庫、套片路徑對照重用),累積過程由它替你管理,並有經審閱的洞察流程。
172
+ - **自成一體的設計**——Post Assistant 會自己把一切接好:用這個 MCP 控制 Resolve、用 Bradford API
173
+ 提供延伸服務,以及你選擇的 LLM 供應商。不必手動設定、不必管理額外的用戶端,應用程式(及其內建的 MCP)
174
+ 會以有簽章的自動更新保持最新。
175
+ - **延伸的專業工具組**——在進行中的專案上做精細調色修正、22 個以上的自適應調色系列、精選風格庫、
176
+ 交付規格驗證、剪輯節奏/清理分析、以自然語言下達的調色指示,以及 Fusion 合成製作——透過受管理的 Bradford API 提供。
177
+ - **製作流程**——把基本工具組合成完整、實際可用的流程(交片 → 套片 → QC → 交付、整季風格延續、單集報告),
178
+ 並具備面對客戶的工作室所期望的防護與核准機制。
179
+
180
+ 目前處於**封閉測試**階段——可到
181
+ [bradfordoperations.com/software/post-assistant](https://www.bradfordoperations.com/software/post-assistant) 申請使用。
182
+ 開源伺服器本身即完整且功能齊全。
183
+
184
+ ## 你可以做什麼
185
+
186
+ 若要為畫面配樂,[Resolve / Live 影片工作流程](docs/guides/film-workflow.md)
187
+ 提供畫面/cue 基準、變更報告、經驗證的新音軌分軌回傳,以及有證據支持的交接事前檢查。
188
+ 它會保留原始素材,並明確回報缺少的校準或交付證據。
189
+
190
+ ```text
191
+ "List all projects and open the one called 'My Film'"
192
+ "Create a timeline called 'Assembly Cut' from all clips in the current bin"
193
+ "Build a multicam prep timeline from selected camera angles and preserve source media"
194
+ "Detect 2-pops or slate claps and suggest record offsets for sync prep"
195
+ "Publish analysis summaries, keywords, people, and slate hints into Resolve clip metadata"
196
+ "Probe this timeline for gaps, overlaps, missing media, and source frame ranges"
197
+ "Safely import this image sequence, organize it into bins, and normalize clip metadata"
198
+ "Build a ProRes 422 HQ render plan, validate the settings, and queue the job"
199
+ "Copy review markers from the timeline to the selected clip and export a review report"
200
+ "Snapshot this clip's grade, validate a CDL update, and export a temp LUT"
201
+ "Create a Fusion TextPlus overlay on the selected clip and verify graph connections"
202
+ "Report audio channel mappings, voice isolation availability, and subtitle support"
203
+ "Install this MCP-marked DCTL or script, classify refresh/restart needs, then remove it"
204
+ ```
205
+
206
+ ## 核心功能
207
+
208
+ | 領域 | 複合伺服器支援的功能 |
209
+ |------|----------------------|
210
+ | 應用程式與專案控制 | 啟動/重新連線、切換頁面、專案增刪查改、專案資料夾、資料庫、雲端專案包裝、設定、預設集、封存 |
211
+ | 媒體池與匯入 | 安全匯入、影像序列、多機位準備時間軸、素材夾整理、中繼資料正規化、中繼資料欄位清單、入出點、註記、重新連結/代理/全解析度防護 |
212
+ | 媒體分析 | 不更動原始素材的檔案/片段/素材夾/專案分析、2-pop/打板聲同步事件偵測、預設寫回 Resolve 中繼資料與媒體池標記、保存分析產物、重用既有報告、host_chat_paths 視覺分析(每個片段以 `commit_vision` 完成,適用任何支援視覺的 MCP 用戶端)並可選擇不使用、逐字稿並可選擇不使用 |
213
+ | 時間軸剪輯與套片 | 軌道/項目探查、標題文字鍵值掃描/寫入、複製/移動/複製一份輔助工具、波紋插入、範圍操作、空隙/重疊、來源範圍、經檢查的交換格式匯出/匯入 |
214
+ | 審閱註記 | 時間軸/項目/片段標記、自訂資料、旗標、片段顏色、複製/移動/同步清理、審閱報告、標記縮圖審閱 |
215
+ | 調色 | 節點圖探查、CDL 驗證、調色複製、DRX/LUT 輔助工具、版本、Gallery 靜態畫面、調色群組 |
216
+ | Fusion | 時間軸項目合成、安全建立工具、輸入值寫入、連接埠檢查、經驗證的連線、限定範圍的批次寫入 |
217
+ | 音訊與 Fairlight | 軌道/項目探查、來源對應、有防護的音訊屬性寫入、人聲分離、自動同步規劃、逐字稿/字幕探查 |
218
+ | 算圖與交付 | 格式/編解碼器矩陣探查、算圖設定驗證、佇列工作生命週期檢查、有防護的 Quick Export |
219
+ | 擴充功能開發 | Fuse、DCTL、ACES DCTL,以及 Resolve 頁面 Lua/Python 腳本的生命週期輔助工具,並以 MCP 標記安全安裝/移除 |
220
+ | 專業指引 | 內附的剪輯、調色、音訊與工作流程指引,以文字形式透過 MCP 提供——有索引、可搜尋,任何用戶端都能讀取,不限本機有這個儲存庫的用戶端 |
221
+
222
+ ### 操作信封(operation envelope)
223
+
224
+ 每個複合工具的回傳都會在內容旁附上一個 `_operation` 區塊,讓 AI 助理讀同一種結構,
225
+ 而不必每個工具各讀不同的鍵:`status`(`success` / `partial` / `blocked` / `failed`)、
226
+ `verification`(其中 `contradiction` 另外區分——Resolve 回報成功,但讀回結果不一致)、
227
+ `changes`(語意上的差異)、`warnings`,以及 `execution_id`。
228
+
229
+ 有兩種「沒有」是有意義且刻意的。`verification.status: "unverified"` 代表*沒有回報任何證據*,
230
+ 不是「檢查過、沒問題」。少了 `changes` 代表這個動作沒有回報差異,不是什麼都沒變——
231
+ 在那裡放一個空的 `{}`,等於對一個根本沒宣告差異的編輯給出自信但錯誤的答案。
232
+
233
+ 這個信封放在自己的命名空間裡,而不是併入最上層,因為 `status`、`operation`、`warnings`、`result`
234
+ 與 `changes` 在這裡本來就都是領域用的鍵;攤平的話會改寫背景工作的 `status: "done"` 以及確認關卡的
235
+ `status: "confirmation_required"`。`setup(action="set_defaults", params={"result_envelope": "pure" | "legacy"})`
236
+ 可以改變結構,單次呼叫用 `params={"envelope": ...}`,整個程序用 `RESOLVE_MCP_RESULT_ENVELOPE`。
237
+
238
+ ### AI 助理執行軌跡(「剪輯師為什麼這樣做?」)
239
+
240
+ 多步驟的 AI 操作會跨工具呼叫串成統一的執行軌跡。每條軌跡會彙總工具耗時(`duration_ms`)、呼叫次數、
241
+ 累計的語意差異(`items_deleted`、`items_added`)以及讀回驗證。AI 助理與剪輯師可以透過 `resolve_control` 檢視工作流程:
242
+ `get_execution_trace(execution_id?)`、`list_recent_executions()`,或以 `begin_execution(request="...")` /
243
+ `end_execution()` 開啟一段限定範圍的執行。
244
+ `export_execution_report(execution_id?, format="markdown"|"json")` 會寫出一份可供審閱的稽核產物,內容是同樣的摘要,
245
+ 預設寫到 `logs/execution-reports/<execution_id>.md`。改用 `path` 可以寫到任何你想要的位置——例如寫在某次套片旁、
246
+ 標有日期的 TransferFiles 資料夾裡——並會建立所需的目錄,所以送出前請先確認路徑。
247
+ 沒有 `overwrite: true` 時,絕不會覆蓋既有檔案。
248
+ `inspect_operation(tool?, target_action?, target_params?)` 會在執行前評估事前風險等級(`low`、`medium`、`high`、`critical`)、
249
+ 破壞性的可能,以及影響範圍(`item`、`track`、`timeline`、`project`、`system`);
250
+ `list_lifecycle_hooks()` 則可檢視目前生效的執行攔截器。
251
+
252
+ 它是依動作名稱做的經驗判斷,不是模擬——它從不碰專案,也不驗證你的參數,所以 `recognised: false`
253
+ 代表那些等級只是預設值而不是判斷結果,`snapshot_available: null` 代表尚未判定能否還原,而不是不能還原。
254
+ 內建的每個掛勾都只負責觀察;沒有任何一個會取代工具的結果,所以 `dry_run` 一定會送到真正的處理程式,
255
+ 也不會替本來沒有預覽功能的動作憑空產生預覽。
256
+
257
+ 一次完全沒有驗證任何東西的執行,報告會寫 **「not established — no checks recorded」**(尚未確立——沒有記錄任何檢查),
258
+ 而不是「passed」。沒有證據代表問題仍然未解,而稽核文件最不該讓讀者把它讀成一切正常。
259
+
260
+ 軌跡存放在一個 100 筆的記憶體環狀緩衝區,並附加寫入 `server.log` 旁邊的 `logs/execution-traces.jsonl`——
261
+ `RESOLVE_MCP_TRACE_FILE` 可以改變它的位置,`RESOLVE_MCP_LOG_FILE` 可以改變 `server.log` 本身的位置
262
+ (給一個路徑,或給空值表示不寫檔;離線測試套件會把它指到暫存檔,所以絕不會寫進操作者的 log)。
263
+ `list_recent_executions` 會回報該路徑以及是否可寫入,所以不必讀原始碼,就能分辨「log 是空的」與「根本沒有在寫入」。
264
+ 記錄的內容是工具名稱、動作、時間、狀態、語意差異與驗證結果——沒有參數,也沒有檔案路徑。唯一的自由文字欄位是你傳給
265
+ `begin_execution` 的 `request`,所以請像在客戶專案上寫 commit 訊息那樣看待它。
266
+
267
+ ## 已驗證陷阱防護(Verified-Trap Guard)
268
+
269
+ `src/utils/api_truth.py` 記錄了 Resolve API 中經過實機版本實測、而不是從函式簽名推斷出來的行為——
270
+ 回傳 `True` 卻什麼也沒做的呼叫、被默默拒絕的設定鍵、根本不存在的方法。這份紀錄以前是**只能主動查詢**的:
271
+ 它只回應 `resolve_control(action="api_truth")`,平常就是一個沒人會在工作中途去 grep 的檔案。
272
+
273
+ 現在它會在呼叫當下直接告訴呼叫端。對應到有記錄事實的符號的動作,會在結果中附上精簡的 `known_limitation`——
274
+ 只有符號、實際情況、建議做法,沒有別的,因為在冗長的調色工作階段中,回應的大小是實際的成本,而完整的條目只要再查一次就有。
275
+
276
+ 只有當對應關係明確指名那個符號時,才會附上事實。不會從相似的名稱推論:把不相干的說明釘在一個失敗上,
277
+ 看起來就像是診斷,而錯誤的診斷比沒有診斷更糟。
278
+
279
+ **有一種行為會直接拒絕,而不只是警告。** `TimelineItem.CopyGrades` 會整個取代目標的調色——
280
+ 這是把每個狀態烘焙成 33 點 LUT 並比對位元組實測出來的——它在這樣做的同時回傳 `True`,而且不會建立可以回復的版本。
281
+ 套用在帶有手工調色的片段上,就是被回報成成功的無法挽回損失。所以會呼叫它的動作會拒絕執行,直到呼叫端傳入
282
+ `acknowledge_trap: true`:
283
+
284
+ ```json
285
+ {
286
+ "success": false,
287
+ "error": "'timeline_item_color.copy_grades' is refused: its verified behaviour destroys existing work that cannot be recovered afterwards.",
288
+ "known_limitation": [{"symbol": "TimelineItem.CopyGrades", "reality": "...", "recommended": "..."}],
289
+ "retry_with": {"acknowledge_trap": true}
290
+ }
291
+ ```
292
+
293
+ 目的不是禁止這個操作,而是讓呼叫端明確表示自己知道它會做什麼。試跑(dry run)不受此限:預覽不會破壞任何東西。
294
+
295
+ 設定 `RESOLVE_MCP_DISABLE_TRAP_GUARD=1` 可以同時關閉拒絕與主動提示。對過去從破壞性複製收到單純
296
+ `{"success": true}` 的呼叫端來說,這是一項行為變更。
297
+
298
+ 用來觸發拒絕的事實必須能夠重新實測,所以有一個實機探測會重新推導每一項事實,並在 Resolve 的行為不再一致時記錄 `drifted`;
299
+ 如果某個 `destroys_prior_work` 條目沒有對應的探測,測試就會失敗。
300
+
301
+ ## 選用擴充
302
+
303
+ 核心安裝刻意保持精簡:Python、ffmpeg 與 Resolve 腳本 API。有些功能需要更多東西,而且**每一項在缺少時都會老實拒絕,
304
+ 並給出各自的安裝指令,而不是退而求其次去猜**——捏造的節拍或憑空的音量會產生自信但錯誤的結果,比沒有這個功能更糟。
305
+
306
+ 執行 `python scripts/doctor.py` 可以查看你已經有哪些。
307
+
308
+ | 擴充 | 啟用的功能 | 授權 |
309
+ |---|---|---|
310
+ | PATH 中的 **ffmpeg** | 靜音偵測、空白段標記、音量測量、音訊分析。最值得安裝的一項。 | LGPL/GPL——以子程序呼叫,從不內附 |
311
+ | `pip install numpy` | 調色預先平衡、參考靜態畫面比對、聲音密度稽核 | BSD |
312
+ | `pip install librosa` | 為配合音樂剪輯偵測拍、小節與樂句 | ISC |
313
+ | `pip install -U openai-whisper` | 逐字稿,以及所有建立在其上的逐字功能 | MIT |
314
+ | `pip install open_clip_torch` | 視覺相似度與 `find_similar` | MIT |
315
+ | `pip install transformers` | CLAP 音訊嵌入 | Apache-2.0 |
316
+ | `pip install opencv-python` | 額外的影格分析 | Apache-2.0 |
317
+
318
+ `media_analysis` 的 `capabilities` 動作會詳細回報分析環境,並告訴你每個缺少的部分可以啟用什麼。
319
+
320
+ **這裡沒有任何東西是內附的。** 模型權重有各自的授權,與載入它們的程式碼分開;商業使用前請先確認。
321
+
322
+ ## 這個工具不做什麼
323
+
324
+ 知道工具的極限在哪裡,和知道它能做什麼一樣有價值,而且在這裡讀到,比在專案進行到一半才發現便宜得多。
325
+
326
+ | 不支援 | 原因,以及你能得到的替代 |
327
+ |---|---|
328
+ | **挑出最好的一條** | 一條好不好,大部分取決於表演,而這些都無法從波形或逐字稿量出來。`rank_takes` 排的是*流暢度*——贅詞、重來、劇本涵蓋度——而且每次回應都會這樣說明。真正能用的那一條,常常反而是最不流暢的,因為那份遲疑往往就是表演本身。請用它找出乾淨的保險條,而不是用它決定要用哪一條。 |
329
+ | **自動音樂剪輯** | 選用的 `librosa` 支援提供節拍偵測,以及依拍/小節/樂句規劃的剪接點,不是完成的組接。強拍是從第一拍推斷的;有弱起拍時請用 `beat_offset`。語音靜音工具不適合用來找音樂的剪接點。 |
330
+ | **評斷剪輯好壞** | 這裡沒有任何東西會對一個剪輯好不好有意見。正因如此,每個破壞性動作都是規劃 → 審閱 → 確認。 |
331
+ | **取代剪輯師** | 產出的是第一版組接,就像助理剪輯在做的:匯入、同步、整理、串接、標出問題。它是讓你去剪的起點,不是剪好的成品。預設值刻意**寬鬆**——第一版組接本來就該偏長,因為修短又快又看得見,而找回被丟掉的素材又慢又看不見。 |
332
+ | **修改你的原始素材** | 依設計且毫無例外——見下文。 |
333
+
334
+ 凡是分析過但無法驗證的,都會回報為未驗證,絕不會併入「沒問題」。空的結果代表「沒有找到」,絕不代表「沒有東西可找」。
335
+
336
+ ## 原始素材安全
337
+
338
+ 本專案把攝影機原始檔與原始素材視為不可更動。分析工具只會讀取原始檔案,報告只寫到附屬檔、暫存或專案分析目錄;經確認後發佈的中繼資料只會寫進 Resolve 的專案資料庫。除非使用者明確要求,否則伺服器不得修改、轉檔、建立代理檔或產生原始素材的衍生檔。詳細的不更動原始素材工作流程請見[媒體分析指南](docs/guides/media-analysis-guide.md)。
339
+
340
+ ## 安全設計
341
+
342
+ 預設伺服器是由你的 MCP 用戶端啟動的本機 stdio 程序;它不會開啟網路監聽埠,也沒有內建的多使用者驗證介面。兩個需手動啟用的本機 HTTP 介面——控制面板與網路化的 MCP 傳輸——都只綁定本機迴路,每個請求都需要每次啟動各自產生的 bearer 權杖,並檢查 Host/Origin 以防 DNS rebinding 與 CSRF。工具中繼資料包含 MCP 用戶端安全提示,標示唯讀、破壞性、等冪與存取外部資源的操作。兩種伺服器的破壞性寫入都遵守 `destructive.safe_mode` 與安全稽核 log;只有複合伺服器會在變更時間軸前先封存——細粒度寫入只會被拒絕或被記錄,不會被還原。操作界線、確認指引與漏洞回報請見[安全政策](SECURITY.md)。
343
+
344
+ ## 關鍵數據
345
+
346
+ | 指標 | 數值 |
347
+ |------|------|
348
+ | MCP 工具 | **37** 複合 / **390** 細粒度(即時伺服器) |
349
+ | Advanced(離線)工具 | **18**——.drp/.drt/.drx+資料庫製作,不需開啟 Resolve |
350
+ | Kernel 動作 | 9 個複合工具共 **136** 個有防護的工作流程動作 |
351
+ | 已覆蓋的 API 方法 | **361/361**(100%) |
352
+ | 已實機測試的方法 | **349/361**(96.7%) |
353
+ | 實機測試通過率 | **349/349**(100%) |
354
+ | 測試環境 | DaVinci Resolve 19.1.3 Studio+Resolve 20.3.2 Studio+Resolve 21.0.2 Studio+Resolve 21.0.3 與 21.0.4 **免費版**(透過應用程式內橋接) |
355
+
356
+ 逐一方法的狀態請見 [API 覆蓋與測試結果](docs/reference/api-coverage.md)。目前的工作流程支援請見 [Kernel 動作覆蓋](docs/kernels/README.md)。
357
+
358
+ `analyze_media` 預設會直接執行,把可檢視的報告/產物保存在分析根目錄下,透過 `host_chat_paths` 協定請求宿主對話做視覺分析(analyze 會回傳影格的絕對路徑+一份 JSON schema;宿主對話把每個影格當成圖片讀取,再呼叫 `media_analysis(action="commit_vision", ...)` 完成),經由設定的本機後端產生逐字稿,並把分析摘要以及以來源時間為準的媒體池片段標記寫回 Resolve 專案。只有在你想關閉這些預設行為時,才傳入 `include_visuals=false`、`include_transcription=false`、`publish_metadata=false`、`timed_markers=no` 或 `dry_run=true`。略過 `commit_vision` 會讓這次執行停在 `pending_host_vision_analysis`——它會被呈現為失敗狀態,而不是默默降級。
359
+
360
+ ## 文件
361
+
362
+ | 文件 | 用途 |
363
+ |------|------|
364
+ | [安裝與設定](docs/install.md) | 需求、安裝程式選項、支援的用戶端、伺服器模式、手動設定 |
365
+ | [API 覆蓋與測試結果](docs/reference/api-coverage.md) | 關鍵數據、API 覆蓋表、實機測試狀態、完整方法參考 |
366
+ | [Kernel 動作覆蓋](docs/kernels/README.md) | 目前有防護的工作流程動作對照 |
367
+ | [AI 技能參考](docs/SKILL.md) | 給使用複合伺服器的 AI 助理的操作脈絡 |
368
+ | [控制面板指南](docs/guides/control-panel.md) | 本機瀏覽器面板導覽:Overview、Review(素材夾/片段/鏡頭)、Analyze、Setup、Preferences |
369
+ | [媒體分析指南](docs/guides/media-analysis-guide.md) | 不更動原始素材的 FFprobe、FFmpeg、Whisper、附屬檔與分析根目錄工作流程 |
370
+ | [多機位設定輔助指南](docs/guides/multicam-setup-guide.md) | 堆疊時間軸準備、輔助工具/API 的界線,以及 Resolve 介面上的轉換步驟 |
371
+ | [剪輯決策指南](docs/guides/editorial-decision-guide.md) | 專案自訂的剪輯專業指引,用於分析與時間軸決策 |
372
+ | [Avid AAF 套片](docs/guides/conforming-an-avid-aaf.md) | 為什麼 Resolve 原生的三條路線在合併過的交片上都會失敗,以及哪一條有危險 |
373
+ | [原生 .drt 製作](docs/guides/native-drt-authoring.md) | 離線以範本拼接製作時間軸:剪接、變速、轉場、淡入淡出、標記、複合片段——以及背後實測出的規律 |
374
+ | [無頭剪輯迴圈](docs/guides/headless-edit-loop.md) | 從命令列操作 Resolve:哪些交換格式能重新連結並來回轉換,在 GUI 與 -nogui 下實測 |
375
+ | [調色決策指南](docs/guides/color-decision-guide.md) | 專案自訂的調色指引,以及 Resolve 調色 API 的界線 |
376
+ | [貢獻與專案結構](docs/contributing.md) | 貢獻流程、平台支援、安全注意事項、儲存庫結構 |
377
+ | [安全政策](SECURITY.md) | 本機 stdio 信任邊界、工具中繼資料、確認指引、漏洞回報 |
378
+ | [發佈流程](docs/process/release-process.md) | 維護者的發佈檢查清單、版本標示位置、驗證、標籤與 release 說明 |
379
+ | [更新日誌](CHANGELOG.md) | 歷次 release 說明 |
380
+
381
+ 擴充功能開發參考文件在 [docs/authoring](docs/authoring/)。Resolve 開發者套件筆記在 [docs/notes](docs/notes/) 與 [docs/integrations](docs/integrations/)。提示範例在 [examples](examples/)。
382
+
383
+ ## 系統需求
384
+
385
+ - macOS、Windows 或 Linux 上的 DaVinci Resolve 18.5 以上版本。**Studio** 直接支援外部腳本。**免費版**不支援——Blackmagic 把外部腳本限定給 Studio——但仍可透過[應用程式內橋接](#免費版應用程式內橋接)連線,它從沒有限制的 **Workspace ▸ Scripts** 選單在 Resolve 內部執行。
386
+ - Python 3.10 以上(3.10–3.12 風險最低)。Python 3.13/3.14 在較新的 Resolve 版本上也能用(已在 Studio 20.3.2 上驗證);較舊的版本在 3.13 以上可能無法連線,這時請改用 3.10–3.12。
387
+ - 連不上?`python3 scripts/doctor.py` 會檢查伺服器所用的 Python,並針對每個問題印出確切的修正方式:32 位元或架構不符的 Python、對你的 Resolve 版本來說太新的 Python,或有多個 Python 而 MCP 用戶端啟動了錯的那一個。請見[檢查 Python 環境](docs/install.md#checking-the-python-environment)。
388
+ - Resolve 外部腳本設為 **Local**(Studio)。在免費版上這個偏好設定沒有作用——請改用[應用程式內橋接](#免費版應用程式內橋接)。
389
+
390
+ Resolve 19.1.3 仍是相容性基準。Resolve 20.x 的腳本呼叫是新增性質、有版本防護,並已在 20.3.2 上實機測試。Resolve 21.0 新增的腳本功能(音訊分類、說話者偵測逐字稿、IntelliSearch、場記板分析、動態去模糊、語音生成、工作階段背景工作控制)都放在執行期功能偵測之後,所以在舊版本上不會作用,在 Resolve 21 以上會自動啟用。它們已在 Studio 21.0.2.4 上實機測試——見 [Resolve 21 差異](docs/reference/api-coverage.md#resolve-21-delta-detail)。注意 `AnalyzeForIntellisearch`、`AnalyzeForSlate` 與 `GenerateSpeech` 各自需要另外下載的 AI Extras 套件,而 Resolve 回報缺少套件的方式並不一致(有的回傳 `False`,有的回傳錯誤字串),所以這些動作會以 `success: false` 加上 Resolve 提供的原因回報,而不是用猜的。
391
+
392
+ ## 回報問題與提出功能需求
393
+
394
+ 對你的 AI 助理說「send this as a bug」或「send this as a feature request」(把這個當作 bug/功能需求送出)。它會根據對話起草一則 GitHub issue,包含失敗的呼叫及其錯誤,並附上伺服器版本、Resolve 版本、連線模式與作業系統。本機路徑、你的使用者名稱,以及任何看起來像機密的內容都會被遮蔽。不會替你自動送出:你會拿到一個預先填好的連結,審閱草稿後再自己到 GitHub 送出。你也可以直接[開一則 issue](https://github.com/samuelgursky/davinci-resolve-mcp/issues/new/choose)。
395
+
396
+ ## 開發
397
+
398
+ ```bash
399
+ python src/server.py # 複合伺服器
400
+ python src/server.py --full # 細粒度伺服器
401
+ venv/bin/python tests/test_import.py
402
+ venv/bin/python scripts/audit_api_parity.py
403
+ ```
404
+
405
+ 發佈與驗證規則見 [docs/process/release-process.md](docs/process/release-process.md)。在這個儲存庫工作的 AI 助理應從 [AGENTS.md](AGENTS.md) 開始;Claude Code 使用者也可以閱讀 [CLAUDE.md](CLAUDE.md),它指向同一份正式說明。
406
+
407
+ ## 授權
408
+
409
+ MIT
410
+
411
+ ## 作者
412
+
413
+ Samuel Gursky (samgursky@gmail.com)
414
+ - GitHub: [github.com/samuelgursky](https://github.com/samuelgursky)
415
+
416
+ ## 致謝
417
+
418
+ - Blackmagic Design 的 DaVinci Resolve 及其腳本 API
419
+ - Model Context Protocol 團隊讓 AI 助理整合成為可能
420
+
421
+ ## 關於本翻譯
422
+
423
+ 由社群貢獻者 [@monarchsofchaos004-gif](https://github.com/monarchsofchaos004-gif) 依英文 README 以臺灣用語翻譯,並隨英文 README 的變更維護。發現翻譯問題歡迎提 issue 或 PR。
@@ -42,6 +42,10 @@ Every release bump must update all version surfaces:
42
42
  and the language switcher at the top of `README.md`** — a translation that
43
43
  silently lags is worse than no translation, because its version line then
44
44
  makes a claim that is false. No drift guard covers this; it is a human check.
45
+ - `README.zh-TW.md` — the Traditional Chinese (Taiwan) translation. Same rules
46
+ as `README.zh-CN.md`: update its version badge and the
47
+ `本翻譯對應 vX.Y.Z 版 README` line, carry over substantive English changes, or
48
+ delete the file and its entry in the language switchers if it cannot be kept current.
45
49
  - `CHANGELOG.md` latest release entry
46
50
  - `docs/reference/api-limitations.md` when any `submit`-tagged entry in
47
51
  `src/utils/api_truth.py` was added or changed (a newly documented Resolve API
@@ -90,7 +94,8 @@ the check is a regeneration followed by a test, not a `git diff --exit-code`,
90
94
  which would fire on the release bump's own legitimate change.
91
95
 
92
96
  `test_release_surface_drift` is the gate on the version bump itself: it asserts
93
- the README badge, the `README.zh-CN.md` badge and its `本翻译对应 vX.Y.Z` line, and
97
+ the README badge, the `README.zh-CN.md` badge and its `本翻译对应 vX.Y.Z` line, the
98
+ `README.zh-TW.md` badge and its `本翻譯對應 vX.Y.Z` line, and
94
99
  a `CHANGELOG.md` entry all match `package.json`. It was not in this list until
95
100
  v3.2.2, and v3.2.1 shipped with a zh-CN badge still reading v3.2.0 as a direct
96
101
  result — every other gate passed, because none of them looks at a version
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.7"
40
+ VERSION = "5.2.9"
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "davinci-resolve-mcp",
3
- "version": "5.2.7",
3
+ "version": "5.2.9",
4
4
  "description": "NPM bootstrapper for the DaVinci Resolve MCP Server.",
5
5
  "license": "MIT",
6
6
  "author": "Samuel Gursky <samgursky@gmail.com>",
@@ -21,6 +21,7 @@ from mcp.server.fastmcp import FastMCP
21
21
  from mcp.types import ToolAnnotations
22
22
  from src.utils.mcp_error_flag import ErrorFlaggingFastMCP
23
23
  from src.utils import subtitle_append_guard
24
+ from src.utils import clip_info_tracks
24
25
 
25
26
  from src.utils.app_control import (
26
27
  get_app_state,
@@ -93,7 +94,7 @@ if not logging.getLogger().handlers:
93
94
  handlers=[logging.StreamHandler()],
94
95
  )
95
96
 
96
- VERSION = "5.2.7"
97
+ VERSION = "5.2.9"
97
98
  logger = logging.getLogger("davinci-resolve-mcp")
98
99
  logger.info(f"Starting DaVinci Resolve MCP Server v{VERSION}")
99
100
  logger.info(f"Detected platform: {get_platform()}")
@@ -697,11 +698,13 @@ def _resolve_version_string():
697
698
  return None
698
699
 
699
700
 
700
- def _build_append_clip_info_dict(root, ci, index, timeline_start_frame=None):
701
+ def _build_append_clip_info_dict(root, ci, index, timeline_start_frame=None, timeline=None):
701
702
  """Build one MediaPool.AppendToTimeline clipInfo map (6 keys per docs line 221).
702
703
 
703
704
  Required: clip_id (or media_pool_item_id), start_frame, end_frame,
704
705
  record_frame, track_index. Optional: media_type (1=video only, 2=audio only).
706
+ With `timeline`, track_index must name an existing track: Resolve puts an
707
+ unknown index on track 1 and reports success (issue #370).
705
708
  """
706
709
  if not isinstance(ci, dict):
707
710
  return None, {"error": f"clip_infos[{index}] must be an object"}
@@ -724,6 +727,17 @@ def _build_append_clip_info_dict(root, ci, index, timeline_start_frame=None):
724
727
  ti = ci.get("trackIndex", ci.get("track_index"))
725
728
  if ti is None:
726
729
  return None, {"error": f"clip_infos[{index}] requires track_index/trackIndex"}
730
+ ti, ti_err = clip_info_tracks.coerce_track_index(ti, index)
731
+ if ti_err:
732
+ return None, {"error": ti_err, "code": "INVALID_TRACK_INDEX"}
733
+ mt, mt_err = clip_info_tracks.coerce_media_type(ci.get("mediaType", ci.get("media_type")), index)
734
+ if mt_err:
735
+ return None, {"error": mt_err, "code": "INVALID_MEDIA_TYPE"}
736
+ range_refusal = (None if subtitle_append_guard.is_subtitle_item(mp_item)
737
+ else clip_info_tracks.track_range_error(timeline, ti, mt, index))
738
+ if range_refusal:
739
+ return None, {"error": range_refusal["message"], "code": range_refusal["code"],
740
+ "track_counts": range_refusal["state"]["track_counts"]}
727
741
  out: Dict[str, Any] = {
728
742
  "mediaPoolItem": mp_item,
729
743
  "startFrame": sf,
@@ -731,7 +745,6 @@ def _build_append_clip_info_dict(root, ci, index, timeline_start_frame=None):
731
745
  "recordFrame": rf,
732
746
  "trackIndex": ti,
733
747
  }
734
- mt = ci.get("mediaType", ci.get("media_type"))
735
748
  if mt is not None:
736
749
  out["mediaType"] = mt
737
750
  if subtitle_append_guard.is_subtitle_item(mp_item):
@@ -210,7 +210,8 @@ def append_to_timeline(
210
210
  timeline_start = _timeline_start_frame(current_timeline)
211
211
  built = []
212
212
  for i, ci in enumerate(clip_infos):
213
- row, row_err = _build_append_clip_info_dict(root, ci, i, timeline_start)
213
+ row, row_err = _build_append_clip_info_dict(
214
+ root, ci, i, timeline_start, timeline=current_timeline)
214
215
  if row_err:
215
216
  return row_err
216
217
  built.append(row)
@@ -343,7 +344,8 @@ def setup_multicam_timeline(
343
344
  append_rows = plan.get("append_rows") or []
344
345
  append_infos = []
345
346
  for index, row in enumerate(append_rows):
346
- clip_info, clip_err = _build_append_clip_info_dict(root, row, index, timeline_start)
347
+ clip_info, clip_err = _build_append_clip_info_dict(
348
+ root, row, index, timeline_start, timeline=timeline)
347
349
  if clip_err:
348
350
  return clip_err
349
351
  append_infos.append(clip_info)
@@ -3,6 +3,7 @@
3
3
  from src.granular.common import * # noqa: F401,F403
4
4
  from src.utils.bool_params import recognised_bool
5
5
  from src.utils.page_lock import restoring_page
6
+ from src.utils.render_target import missing_target_dir, missing_target_dir_message
6
7
 
7
8
  resolve = ResolveProxy()
8
9
 
@@ -1222,7 +1223,8 @@ def set_render_settings(settings: Dict[str, Any]) -> Dict[str, Any]:
1222
1223
  Args:
1223
1224
  settings: Dict of render settings. All documented keys are forwarded:
1224
1225
  SelectAllFrames (bool), MarkIn (int), MarkOut (int),
1225
- TargetDir (str), CustomName (str), UniqueFilenameStyle (0=Prefix/1=Suffix),
1226
+ TargetDir (str; must be an existing directory, refused before the
1227
+ call otherwise), CustomName (str), UniqueFilenameStyle (0=Prefix/1=Suffix),
1226
1228
  ExportVideo (bool), ExportAudio (bool), FormatWidth (int),
1227
1229
  FormatHeight (int), FrameRate (float), PixelAspectRatio (float),
1228
1230
  VideoQuality (int/str), AudioCodec (str), AudioBitDepth (int),
@@ -1243,6 +1245,9 @@ def set_render_settings(settings: Dict[str, Any]) -> Dict[str, Any]:
1243
1245
  if coerced is None:
1244
1246
  return {"error": "UseUniqueFilenames must be a boolean (true/false)"}
1245
1247
  settings = dict(settings, UseUniqueFilenames=coerced)
1248
+ missing_target = missing_target_dir(settings)
1249
+ if missing_target is not None:
1250
+ return {"error": missing_target_dir_message(missing_target)}
1246
1251
  resolve = get_resolve()
1247
1252
  if resolve is None:
1248
1253
  return {"error": "Not connected to DaVinci Resolve"}
@@ -1056,6 +1056,11 @@ def create_timeline_from_clips(
1056
1056
  _, row_err = _build_create_clip_info_dict(root, ci, i)
1057
1057
  if row_err:
1058
1058
  return row_err
1059
+ # Rows that name a track past the new timeline's would land on track 1
1060
+ # with success (issue #370): validate first, then add those tracks.
1061
+ needed_tracks, track_err = clip_info_tracks.needed_tracks(clip_infos)
1062
+ if track_err:
1063
+ return {"error": track_err, "code": "INVALID_TRACK_INDEX"}
1059
1064
  tl = mp.CreateEmptyTimeline(name)
1060
1065
  if not tl:
1061
1066
  return {"success": False, "error": "Failed to create timeline"}
@@ -1068,12 +1073,19 @@ def create_timeline_from_clips(
1068
1073
  "error": describe_switch_failure(switch_detail,
1069
1074
  "appending the clip_infos"),
1070
1075
  "switch": switch_detail}
1076
+ ensure_err = clip_info_tracks.ensure_tracks(tl, needed_tracks)
1077
+ if ensure_err:
1078
+ return {"success": False,
1079
+ "error": f"Timeline {name!r} was created but the tracks the clip_infos "
1080
+ f"name could not be added: {ensure_err}",
1081
+ "code": "ADD_TRACK_FAILED"}
1071
1082
  timeline_start = _timeline_start_frame(tl)
1072
1083
  built = []
1073
1084
  for i, ci in enumerate(clip_infos):
1074
1085
  append_ci = dict(ci)
1075
1086
  append_ci.setdefault("track_index", append_ci.get("trackIndex", 1))
1076
- row, row_err = _build_append_clip_info_dict(root, append_ci, i, timeline_start)
1087
+ row, row_err = _build_append_clip_info_dict(
1088
+ root, append_ci, i, timeline_start, timeline=tl)
1077
1089
  if row_err:
1078
1090
  return row_err
1079
1091
  built.append(row)
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.7"
14
+ VERSION = "5.2.9"
15
15
 
16
16
  import base64
17
17
  import os
@@ -64,6 +64,8 @@ from src.utils.film_cues import export_cue_sheet as _export_film_cue_sheet
64
64
  from src.utils.cdl import normalize_cdl_payload
65
65
  from src.utils.media_paths import media_exists as _media_exists
66
66
  from src.utils.preset_files import preset_export_file as _preset_export_file
67
+ from src.utils.render_target import missing_target_dir_error as _missing_target_dir_error
68
+ from src.utils import clip_info_tracks as _clip_info_tracks
67
69
  from src.utils import archive_guard
68
70
  from src.utils import subtitle_append_guard
69
71
  from src.utils import typed_api_search
@@ -3917,6 +3919,24 @@ def _normalize_record_frame(
3917
3919
  return start + rf, None
3918
3920
 
3919
3921
 
3922
+ def _rows_with_default_record_frame_mode(rows, p):
3923
+ """Apply a top-level record_frame_mode to clip_infos rows that set none.
3924
+
3925
+ The mode used to be read only per row, so `record_frame_mode` passed beside
3926
+ `clip_infos` was dropped and an absolute frame landed start-relative with
3927
+ success (issue #365). A row's own mode still wins.
3928
+ """
3929
+ mode = p.get("record_frame_mode", p.get("recordFrameMode"))
3930
+ if mode is None or not isinstance(rows, list):
3931
+ return rows
3932
+ out = []
3933
+ for ci in rows:
3934
+ if isinstance(ci, dict) and "record_frame_mode" not in ci and "recordFrameMode" not in ci:
3935
+ ci = {**ci, "record_frame_mode": mode}
3936
+ out.append(ci)
3937
+ return out
3938
+
3939
+
3920
3940
  def _timeline_start_frame(tl) -> Optional[int]:
3921
3941
  if not tl:
3922
3942
  return None
@@ -3994,12 +4014,18 @@ def _build_append_clip_info_dict(
3994
4014
  index: int,
3995
4015
  timeline_start_frame: Optional[int] = None,
3996
4016
  pack: bool = False,
4017
+ timeline=None,
3997
4018
  ):
3998
4019
  """Build one MediaPool.AppendToTimeline clipInfo map (Python API uses camelCase keys).
3999
4020
 
4000
4021
  See docs/reference/resolve_scripting_api.txt: mediaPoolItem, startFrame, endFrame,
4001
4022
  optional mediaType, trackIndex, recordFrame. With pack=True, recordFrame is omitted
4002
4023
  so Resolve appends each clip contiguously at the end of its track.
4024
+
4025
+ trackIndex must be a 1-based int and mediaType 1 or 2. With `timeline`, the
4026
+ index must also name an existing track: Resolve puts an unknown index on
4027
+ track 1 and reports success (issue #370). Callers that add tracks after
4028
+ building the rows leave `timeline` unset.
4003
4029
  """
4004
4030
  if not isinstance(ci, dict):
4005
4031
  return None, _err(f"clip_infos[{index}] must be an object")
@@ -4030,6 +4056,12 @@ def _build_append_clip_info_dict(
4030
4056
  return None, _err(
4031
4057
  f"clip_infos[{index}] requires track_index/trackIndex (1-based track index)"
4032
4058
  )
4059
+ ti, ti_err = _clip_info_tracks.coerce_track_index(ti, index)
4060
+ if ti_err:
4061
+ return None, _err(ti_err, code="INVALID_TRACK_INDEX", category="invalid_input")
4062
+ mt, mt_err = _clip_info_tracks.coerce_media_type(ci.get("mediaType", ci.get("media_type")), index)
4063
+ if mt_err:
4064
+ return None, _err(mt_err, code="INVALID_MEDIA_TYPE", category="invalid_input")
4033
4065
  out: Dict[str, Any] = {
4034
4066
  "mediaPoolItem": mp_item,
4035
4067
  "startFrame": sf,
@@ -4038,12 +4070,18 @@ def _build_append_clip_info_dict(
4038
4070
  }
4039
4071
  if not pack:
4040
4072
  out["recordFrame"] = rf
4041
- mt = ci.get("mediaType", ci.get("media_type"))
4042
4073
  if mt is not None:
4043
4074
  out["mediaType"] = mt
4044
4075
  blocked = _subtitle_append_block(out, index=index)
4045
4076
  if blocked:
4046
4077
  return None, blocked
4078
+ # A subtitle item's trackIndex names a subtitle track, which the
4079
+ # video/audio range check does not measure.
4080
+ if not subtitle_append_guard.is_subtitle_item(mp_item):
4081
+ range_refusal = _clip_info_tracks.track_range_error(timeline, ti, mt, index)
4082
+ if range_refusal:
4083
+ message = range_refusal.pop("message")
4084
+ return None, _err(message, **range_refusal)
4047
4085
  return out, None
4048
4086
 
4049
4087
 
@@ -6388,15 +6426,23 @@ def _timeline_ripple_insert_impl(proj, tl, p: Dict[str, Any], *, resolve=None) -
6388
6426
  ci = dict(raw_ci)
6389
6427
  ci.pop("record_frame", None)
6390
6428
  ci.pop("recordFrame", None)
6391
- track_index = ci.get("trackIndex", ci.get("track_index", 1))
6392
- media_type = ci.get("mediaType", ci.get("media_type", 1))
6429
+ track_index, ti_err = _clip_info_tracks.coerce_track_index(
6430
+ ci.get("trackIndex", ci.get("track_index", 1)), idx)
6431
+ if ti_err:
6432
+ return _err(ti_err, code="INVALID_TRACK_INDEX", category="invalid_input")
6433
+ media_type, mt_err = _clip_info_tracks.coerce_media_type(
6434
+ ci.get("mediaType", ci.get("media_type", 1)), idx)
6435
+ if mt_err:
6436
+ return _err(mt_err, code="INVALID_MEDIA_TYPE", category="invalid_input")
6437
+ ci.pop("trackIndex", None)
6438
+ ci.pop("mediaType", None)
6393
6439
  ci["track_index"] = track_index
6394
6440
  ci["media_type"] = media_type
6395
- key = (int(media_type), int(track_index))
6441
+ key = (media_type, track_index)
6396
6442
  record = cursor_by_track.get(key, insert_frame)
6397
6443
  ci["record_frame"] = record
6398
6444
  ci["record_frame_mode"] = "absolute"
6399
- info, ierr = _build_append_clip_info_dict(root, ci, idx, tl_start)
6445
+ info, ierr = _build_append_clip_info_dict(root, ci, idx, tl_start, timeline=tl)
6400
6446
  if ierr:
6401
6447
  return ierr
6402
6448
  duration = int(info["endFrame"]) - int(info["startFrame"])
@@ -8023,7 +8069,11 @@ def _timeline_create_variant_from_ranges(proj, source_tl, p: Dict[str, Any]) ->
8023
8069
  media_type = _timeline_media_type(track_type)
8024
8070
  if media_type not in (1, 2):
8025
8071
  return _err(f"ranges[{index}] track_type/media_type must resolve to video or audio")
8026
- track_index = int(row.get("track_index", row.get("trackIndex", 1)))
8072
+ track_index, ti_err = _clip_info_tracks.coerce_track_index(
8073
+ row.get("track_index", row.get("trackIndex", 1)), index)
8074
+ if ti_err:
8075
+ return _err(ti_err.replace("clip_infos[", "ranges[", 1),
8076
+ code="INVALID_TRACK_INDEX", category="invalid_input")
8027
8077
  if media_type == 1:
8028
8078
  max_tracks["video"] = max(max_tracks["video"], track_index)
8029
8079
  else:
@@ -11050,7 +11100,8 @@ def _setup_multicam_timeline(proj, mp, p: Dict[str, Any]):
11050
11100
  append_infos = []
11051
11101
  append_rows = plan.get("append_rows") or []
11052
11102
  for index, row in enumerate(append_rows):
11053
- clip_info, clip_err = _build_append_clip_info_dict(root, row, index, timeline_start)
11103
+ clip_info, clip_err = _build_append_clip_info_dict(
11104
+ root, row, index, timeline_start, timeline=new_tl)
11054
11105
  if clip_err:
11055
11106
  return clip_err
11056
11107
  append_infos.append(clip_info)
@@ -23248,6 +23299,10 @@ def render(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[str, An
23248
23299
  category="invalid_input",
23249
23300
  reason="Nothing was sent to SetRenderSettings.",
23250
23301
  )
23302
+ target_refusal = _missing_target_dir_error(settings)
23303
+ if target_refusal:
23304
+ message = target_refusal.pop("message")
23305
+ return _err(message, **target_refusal)
23251
23306
  result = {"success": bool(proj.SetRenderSettings(settings))}
23252
23307
  if ignored_settings:
23253
23308
  result["ignored_settings"] = ignored_settings
@@ -23570,7 +23625,7 @@ def media_pool(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[str
23570
23625
  if policy_result:
23571
23626
  return policy_result
23572
23627
  if p.get("clip_infos") is not None:
23573
- raw = p["clip_infos"]
23628
+ raw = _rows_with_default_record_frame_mode(p["clip_infos"], p)
23574
23629
  if not isinstance(raw, list):
23575
23630
  return _err("clip_infos must be a list")
23576
23631
  if not raw:
@@ -23579,6 +23634,12 @@ def media_pool(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[str
23579
23634
  _, row_err = _build_create_clip_info_dict(root, ci, i)
23580
23635
  if row_err:
23581
23636
  return row_err
23637
+ # Validate track_index/media_type before the timeline exists, then
23638
+ # add the tracks the rows name: an index past the new timeline's
23639
+ # tracks would land on track 1 with success (issue #370).
23640
+ needed_tracks, track_err = _clip_info_tracks.needed_tracks(raw)
23641
+ if track_err:
23642
+ return _err(track_err, code="INVALID_TRACK_INDEX", category="invalid_input")
23582
23643
  tl = mp.CreateEmptyTimeline(create_name)
23583
23644
  if not tl:
23584
23645
  return _err("Failed to create timeline from clip_infos")
@@ -23586,12 +23647,21 @@ def media_pool(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[str
23586
23647
  proj, tl, what="appending the clip_infos")
23587
23648
  if switch_err:
23588
23649
  return switch_err
23650
+ ensure_err = _clip_info_tracks.ensure_tracks(tl, needed_tracks)
23651
+ if ensure_err:
23652
+ return _err(
23653
+ f"Timeline {tl.GetName()!r} was created but the tracks the clip_infos "
23654
+ f"name could not be added: {ensure_err}",
23655
+ code="ADD_TRACK_FAILED", category="api_error",
23656
+ state={"timeline": tl.GetName(), "needed": needed_tracks},
23657
+ )
23589
23658
  timeline_start = _timeline_start_frame(tl)
23590
23659
  built = []
23591
23660
  for i, ci in enumerate(raw):
23592
23661
  append_ci = dict(ci)
23593
23662
  append_ci.setdefault("track_index", append_ci.get("trackIndex", 1))
23594
- row, row_err = _build_append_clip_info_dict(root, append_ci, i, timeline_start)
23663
+ row, row_err = _build_append_clip_info_dict(
23664
+ root, append_ci, i, timeline_start, timeline=tl)
23595
23665
  if row_err:
23596
23666
  return row_err
23597
23667
  built.append(row)
@@ -23677,15 +23747,17 @@ def media_pool(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[str
23677
23747
  "timelines_before": before_n, "timelines_after": after_n}
23678
23748
  elif action == "append_to_timeline":
23679
23749
  if p.get("clip_infos") is not None:
23680
- raw = p["clip_infos"]
23750
+ raw = _rows_with_default_record_frame_mode(p["clip_infos"], p)
23681
23751
  if not isinstance(raw, list):
23682
23752
  return _err("clip_infos must be a list")
23683
23753
  if not raw:
23684
23754
  return _err("clip_infos must be a non-empty list")
23685
- timeline_start = _timeline_start_frame(proj.GetCurrentTimeline())
23755
+ current_tl = proj.GetCurrentTimeline()
23756
+ timeline_start = _timeline_start_frame(current_tl)
23686
23757
  built = []
23687
23758
  for i, ci in enumerate(raw):
23688
- row, row_err = _build_append_clip_info_dict(root, ci, i, timeline_start)
23759
+ row, row_err = _build_append_clip_info_dict(
23760
+ root, ci, i, timeline_start, timeline=current_tl)
23689
23761
  if row_err:
23690
23762
  return row_err
23691
23763
  built.append(row)
@@ -27164,7 +27236,8 @@ def edit_engine(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[st
27164
27236
  # Sequential assembly: each select lands after the previous one.
27165
27237
  append_ci.setdefault("record_frame", record_cursor)
27166
27238
  append_ci.setdefault("track_index", 1)
27167
- row, row_err = _build_append_clip_info_dict(root_folder, append_ci, i, timeline_start)
27239
+ row, row_err = _build_append_clip_info_dict(
27240
+ root_folder, append_ci, i, timeline_start, timeline=tl)
27168
27241
  if row_err:
27169
27242
  build_errors.append({"index": i, "error": row_err.get("error")})
27170
27243
  continue
@@ -27571,7 +27644,7 @@ def edit_engine(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[st
27571
27644
  "record_frame_mode": "absolute",
27572
27645
  "track_index": int(item_block.get("track_index") or 1),
27573
27646
  }
27574
- row, row_err = _build_append_clip_info_dict(root_folder, ci, 0, timeline_start)
27647
+ row, row_err = _build_append_clip_info_dict(root_folder, ci, 0, timeline_start, timeline=tl)
27575
27648
  if row_err:
27576
27649
  return {"success": False, "error": f"swap append failed: {row_err.get('error')}", "lifted": lift}
27577
27650
  # No mediaType on the clip info: the replacement appends video+audio
@@ -0,0 +1,133 @@
1
+ """trackIndex / mediaType validation for AppendToTimeline clipInfo rows.
2
+
3
+ Resolve takes a trackIndex that names no existing track (0, beyond the track
4
+ count) or that is not an int (``"2"``) and places the item on track 1, answering
5
+ with the new items as if the request were honoured (issue #370). The server's
6
+ own read-back then reports the wrong-track placement as verified. These checks
7
+ run before anything reaches AppendToTimeline.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from typing import Any, Optional, Tuple
13
+
14
+ MEDIA_TYPES = {1: "video", 2: "audio"}
15
+
16
+
17
+ def _as_int(value: Any) -> Optional[int]:
18
+ """An int from an int, an integral float, or a digit string; else None."""
19
+ if isinstance(value, bool):
20
+ return None
21
+ if isinstance(value, int):
22
+ return value
23
+ if isinstance(value, float):
24
+ return int(value) if value.is_integer() else None
25
+ if isinstance(value, str):
26
+ text = value.strip()
27
+ if text.lstrip("+-").isdigit():
28
+ return int(text)
29
+ return None
30
+
31
+
32
+ def coerce_track_index(value: Any, index: int) -> Tuple[Optional[int], Optional[str]]:
33
+ """(track_index, None) or (None, message) for a clipInfo row's trackIndex."""
34
+ ti = _as_int(value)
35
+ if ti is None:
36
+ return None, (
37
+ f"clip_infos[{index}] track_index must be an integer (1-based), got {value!r}"
38
+ )
39
+ if ti < 1:
40
+ return None, f"clip_infos[{index}] track_index must be >= 1 (1-based), got {ti}"
41
+ return ti, None
42
+
43
+
44
+ def coerce_media_type(value: Any, index: int) -> Tuple[Optional[int], Optional[str]]:
45
+ """(media_type, None) or (None, message); None in means None out."""
46
+ if value is None:
47
+ return None, None
48
+ mt = _as_int(value)
49
+ if mt not in MEDIA_TYPES:
50
+ return None, (
51
+ f"clip_infos[{index}] media_type must be 1 (video only) or 2 (audio only), "
52
+ f"got {value!r}"
53
+ )
54
+ return mt, None
55
+
56
+
57
+ def track_count(timeline: Any, track_type: str) -> Optional[int]:
58
+ try:
59
+ return int(timeline.GetTrackCount(track_type) or 0)
60
+ except Exception:
61
+ return None
62
+
63
+
64
+ def track_range_error(timeline: Any, track_index: int, media_type: Optional[int],
65
+ index: int) -> Optional[dict]:
66
+ """Refusal fields when track_index names no track on `timeline`, else None.
67
+
68
+ With media_type set, the index is checked against that track type. Without
69
+ it, Resolve places video on the video track and audio on the audio track of
70
+ that index, and an audio-only or video-only clip uses only one of them, so
71
+ only an index past both counts is refused. An unreadable count is not
72
+ refused here.
73
+ """
74
+ if timeline is None:
75
+ return None
76
+ types = [MEDIA_TYPES[media_type]] if media_type in MEDIA_TYPES else ["video", "audio"]
77
+ counts = {t: track_count(timeline, t) for t in types}
78
+ if any(c is None for c in counts.values()):
79
+ return None
80
+ if any(track_index <= c for c in counts.values()):
81
+ return None
82
+ described = " and ".join(f"{c} {t}" for t, c in counts.items())
83
+ kind = types[0] if len(types) == 1 else "video or audio"
84
+ return {
85
+ "message": (
86
+ f"clip_infos[{index}] track_index {track_index} names no {kind} track: the "
87
+ f"timeline has {described} track(s). Resolve would place the clip on track 1 "
88
+ "and report success; nothing was appended."
89
+ ),
90
+ "code": "TRACK_INDEX_OUT_OF_RANGE",
91
+ "category": "invalid_input",
92
+ "remediation": "Add the track first (timeline add_track), or pass an existing track_index.",
93
+ "state": {"track_index": track_index, "media_type": media_type, "track_counts": counts},
94
+ }
95
+
96
+
97
+ def needed_tracks(rows: Any) -> Tuple[Optional[dict], Optional[str]]:
98
+ """({"video": n, "audio": m}, None) for the tracks `rows` name, or (None, message).
99
+
100
+ For building a new timeline from rows: each row's track_index (default 1)
101
+ must be valid, and the timeline then needs that many tracks of the row's
102
+ media type, or of both types when the row sets none.
103
+ """
104
+ needed = {"video": 1, "audio": 0}
105
+ for i, ci in enumerate(rows if isinstance(rows, list) else []):
106
+ if not isinstance(ci, dict):
107
+ continue
108
+ ti, err = coerce_track_index(ci.get("trackIndex", ci.get("track_index", 1)), i)
109
+ if err:
110
+ return None, err
111
+ mt, err = coerce_media_type(ci.get("mediaType", ci.get("media_type")), i)
112
+ if err:
113
+ return None, err
114
+ for track_type in ([MEDIA_TYPES[mt]] if mt else ["video", "audio"]):
115
+ needed[track_type] = max(needed[track_type], ti)
116
+ return needed, None
117
+
118
+
119
+ def ensure_tracks(timeline: Any, needed: dict) -> Optional[str]:
120
+ """Add tracks until `timeline` has `needed` of each type; an error message or None."""
121
+ for track_type, count in needed.items():
122
+ current = track_count(timeline, track_type)
123
+ if current is None:
124
+ return f"GetTrackCount({track_type}) failed"
125
+ while current < count:
126
+ try:
127
+ ok = timeline.AddTrack(track_type)
128
+ except Exception as exc:
129
+ return f"AddTrack({track_type}) failed: {exc}"
130
+ if not ok:
131
+ return f"AddTrack({track_type}) returned false at track {current + 1}"
132
+ current += 1
133
+ return None
@@ -321,6 +321,17 @@ NON_TIMELINE_WRITE_TOOLS: frozenset = frozenset({
321
321
  })
322
322
 
323
323
 
324
+ #: Registered timeline actions that leave the working timeline unchanged. They
325
+ #: keep every gate (safe mode, dry-run refusal, the audit log) but skip
326
+ #: version-on-mutate archiving. `timeline.duplicate` copies the current timeline
327
+ #: into a new one; archiving the untouched source before it wrote an
328
+ #: `_archived_vNN` sibling that read as evidence of an edit that never happened
329
+ #: (issue #366).
330
+ NON_MUTATING_TIMELINE_ACTIONS: FrozenSet[Tuple[str, str]] = frozenset({
331
+ ("timeline", "duplicate"),
332
+ })
333
+
334
+
324
335
  # ── Strict-mode allowlist ───────────────────────────────────────────────────
325
336
  #
326
337
  # Actions in this set REFUSE to run if the version-on-mutate archive fails. For
@@ -1282,7 +1293,10 @@ def destructive_op(tool_name: str) -> Callable[[Callable[..., Any]], Callable[..
1282
1293
  recognised=risk_recognised,
1283
1294
  )
1284
1295
 
1285
- if tool_name in NON_TIMELINE_WRITE_TOOLS:
1296
+ if (tool_name in NON_TIMELINE_WRITE_TOOLS
1297
+ or (tool_name, action) in NON_MUTATING_TIMELINE_ACTIONS):
1298
+ skipped_reason = ("not_a_timeline_mutation" if tool_name in NON_TIMELINE_WRITE_TOOLS
1299
+ else "source_timeline_unchanged")
1286
1300
  result = fn(action, params, *args, **kwargs)
1287
1301
  _audit_security_event(
1288
1302
  operation_id=operation_id,
@@ -1291,14 +1305,14 @@ def destructive_op(tool_name: str) -> Callable[[Callable[..., Any]], Callable[..
1291
1305
  risk_level=risk_level,
1292
1306
  status="allowed",
1293
1307
  params=params,
1294
- reason="not_a_timeline_mutation",
1308
+ reason=skipped_reason,
1295
1309
  recognised=risk_recognised,
1296
1310
  )
1297
1311
  if isinstance(result, dict):
1298
1312
  result.setdefault("_versioning", {
1299
1313
  "analysis_run_id": None,
1300
1314
  "archived": False,
1301
- "skipped_reason": "not_a_timeline_mutation",
1315
+ "skipped_reason": skipped_reason,
1302
1316
  })
1303
1317
  return _annotate_security(
1304
1318
  result,
@@ -0,0 +1,79 @@
1
+ """Refuse tool arguments the tool's signature does not name (issue #372).
2
+
3
+ FastMCP validates a call's arguments with a pydantic model built from the tool
4
+ function's signature, and that model ignores keys it has no field for. For the
5
+ compound tools, which take `(action, params)`, a selector passed beside
6
+ `action` instead of inside `params` — `timeline(action="get_name",
7
+ timeline_name="vB")` — was therefore dropped before any server code ran, and
8
+ the call acted on the current timeline and answered success. Nothing
9
+ downstream could report it as `ignored_params`, because nothing downstream
10
+ ever saw it.
11
+
12
+ The check runs at the protocol boundary, before the tool is called, and
13
+ refuses rather than folding the keys into `params`: a guessed placement is
14
+ another way to act on something the caller did not ask for.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ from typing import Any, Dict, Iterable, List, Optional
20
+
21
+
22
+ def accepted_arguments(tool: Any) -> Optional[set]:
23
+ """The argument names `tool` accepts (field names and aliases), or None if unknown."""
24
+ model = getattr(getattr(tool, "fn_metadata", None), "arg_model", None)
25
+ fields = getattr(model, "model_fields", None)
26
+ if not isinstance(fields, dict):
27
+ return None
28
+ names = set(fields)
29
+ names.update(f.alias for f in fields.values() if getattr(f, "alias", None))
30
+ return names
31
+
32
+
33
+ def unknown_arguments(tool: Any, arguments: Optional[Dict[str, Any]]) -> List[str]:
34
+ """Keys of `arguments` that `tool` has no parameter for, sorted."""
35
+ if not isinstance(arguments, dict) or not arguments:
36
+ return []
37
+ accepted = accepted_arguments(tool)
38
+ if accepted is None:
39
+ return []
40
+ return sorted(str(k) for k in arguments if k not in accepted)
41
+
42
+
43
+ def refusal(tool_name: str, unknown: Iterable[str], arguments: Dict[str, Any],
44
+ accepted: Optional[set]) -> Dict[str, Any]:
45
+ """The error envelope for a call that passed arguments the tool does not take."""
46
+ unknown = list(unknown)
47
+ quoted = ", ".join(repr(k) for k in unknown)
48
+ takes_params = bool(accepted) and "params" in accepted
49
+ if takes_params:
50
+ moved = dict(arguments.get("params") or {}) if isinstance(arguments.get("params"), dict) else {}
51
+ moved.update({k: arguments[k] for k in unknown})
52
+ message = (
53
+ f"{tool_name} does not take {quoted} beside 'action'; this tool reads its "
54
+ f"arguments from 'params'. Nothing was run: the key would have been dropped "
55
+ f"and the call would have acted with it unset (for a timeline selector, on "
56
+ f"the current timeline)."
57
+ )
58
+ remediation = f"Move {quoted} into params, e.g. params={moved!r}."
59
+ state = {"unknown_arguments": unknown, "corrected_params": moved}
60
+ else:
61
+ message = (
62
+ f"{tool_name} has no parameter {quoted}. Nothing was run: the key would "
63
+ "have been dropped silently."
64
+ )
65
+ remediation = "Pass only the parameters the tool's input schema lists."
66
+ state = {"unknown_arguments": unknown}
67
+ if accepted:
68
+ state["accepted_arguments"] = sorted(accepted)
69
+ return {
70
+ "success": False,
71
+ "error": {
72
+ "message": message,
73
+ "code": "UNKNOWN_ARGUMENTS",
74
+ "category": "invalid_input",
75
+ "retryable": True,
76
+ "remediation": remediation,
77
+ "state": state,
78
+ },
79
+ }
@@ -78,4 +78,28 @@ class ErrorFlaggingFastMCP(FastMCP):
78
78
  """
79
79
 
80
80
  async def call_tool(self, name: str, arguments: dict[str, Any]) -> Any:
81
+ refused = refuse_unknown_arguments(self, name, arguments)
82
+ if refused is not None:
83
+ return refused
81
84
  return flag_tool_error(await super().call_tool(name, arguments))
85
+
86
+
87
+ def refuse_unknown_arguments(server: Any, name: str, arguments: Any) -> Any:
88
+ """An `isError` result when `arguments` holds keys the tool does not take (#372), else None."""
89
+ from mcp.types import CallToolResult, TextContent
90
+
91
+ from src.utils import mcp_arg_guard
92
+
93
+ try:
94
+ tool = server._tool_manager.get_tool(name)
95
+ except Exception:
96
+ return None
97
+ unknown = mcp_arg_guard.unknown_arguments(tool, arguments)
98
+ if not unknown:
99
+ return None
100
+ body = mcp_arg_guard.refusal(name, unknown, arguments, mcp_arg_guard.accepted_arguments(tool))
101
+ return CallToolResult(
102
+ content=[TextContent(type="text", text=json.dumps(body, indent=2))],
103
+ structuredContent=body,
104
+ isError=True,
105
+ )
@@ -0,0 +1,47 @@
1
+ """Render TargetDir validation shared by the compound and granular servers.
2
+
3
+ `Project.SetRenderSettings` takes a TargetDir that does not exist and answers
4
+ True; the refusal only surfaces later, at `AddRenderJob` or when the job
5
+ starts (issue #368). The server runs on the machine Resolve renders on, so a
6
+ directory this process cannot see is one Resolve cannot write to either.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import os
12
+ from typing import Any, Dict, Optional
13
+
14
+
15
+ def missing_target_dir(settings: Any) -> Optional[str]:
16
+ """The TargetDir from `settings` when it names no existing directory, else None.
17
+
18
+ Only a non-empty string is checked; an absent key leaves the project's
19
+ current target alone, and other types are left to Resolve to refuse.
20
+ """
21
+ if not isinstance(settings, dict):
22
+ return None
23
+ target = settings.get("TargetDir")
24
+ if not isinstance(target, str) or not target.strip():
25
+ return None
26
+ return None if os.path.isdir(target) else target
27
+
28
+
29
+ def missing_target_dir_message(target: str) -> str:
30
+ return (
31
+ f"TargetDir does not exist: {target}. Nothing was sent to SetRenderSettings; "
32
+ "Resolve would accept it here and refuse only at add_job or render start."
33
+ )
34
+
35
+
36
+ def missing_target_dir_error(settings: Any) -> Optional[Dict[str, Any]]:
37
+ """Fields for a refusal, or None when TargetDir is absent or exists."""
38
+ target = missing_target_dir(settings)
39
+ if target is None:
40
+ return None
41
+ return {
42
+ "message": missing_target_dir_message(target),
43
+ "code": "TARGET_DIR_NOT_FOUND",
44
+ "category": "invalid_input",
45
+ "remediation": "Create the directory first, or pass an existing TargetDir.",
46
+ "state": {"TargetDir": target},
47
+ }