davinci-resolve-mcp 4.7.8 → 4.7.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,28 @@
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 v4.7.9 — a negative still, album or item index is refused
6
+
7
+ ### Fixed
8
+
9
+ - **A negative index acted on the last element instead of being refused.** ([#247](https://github.com/samuelgursky/davinci-resolve-mcp/pull/247), @Dev-next-gen)
10
+ Python reads `items[-1]` as the last item, and several lookups bounded an index with
11
+ `>= len(...)` only. The granular `_get_timeline_item` — which 85 granular tools go
12
+ through — had exactly the gap EX5 closed in the compound `_get_item`, so
13
+ `item_index=-1` acted on the last clip of the track. Every album and still lookup in
14
+ the compound `gallery` / `gallery_stills` tools and in `src/granular/gallery.py` had
15
+ the same one-sided check. Sharpest case: `gallery_stills delete_stills` and granular
16
+ `delete_stills_from_album` with `still_indices=[-1]` deleted the album's LAST still,
17
+ and an out-of-range index was silently dropped while the others were deleted and the
18
+ call reported success. The lower bound is now in the granular resolver and gallery
19
+ lookups, a small `_index_in_range` helper guards the compound gallery tools, and the
20
+ two delete paths refuse the whole call when any index is not a 0-based position
21
+ (the way `ti_copy_grades` treats its target list) rather than deleting a set nobody
22
+ asked for. Valid indices behave exactly as before; the one visible change is that a
23
+ partly invalid `still_indices` list now errors instead of partially deleting. Guard
24
+ test: `tests/test_negative_index_refused.py` drives the real tool bodies against fake
25
+ gallery and timeline objects; 16 subtests fail on the previous code.
26
+
5
27
  ## What's New in v4.7.8 — `allow_non_mcp_name="false"` no longer lifts the `_mcp_` name guard
6
28
 
7
29
  ### Fixed
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  English | [简体中文](README.zh-CN.md)
4
4
 
5
- [![Version](https://img.shields.io/badge/version-4.7.8-blue.svg)](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
5
+ [![Version](https://img.shields.io/badge/version-4.7.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(389%20full)-blue.svg)](#server-modes)
package/README.zh-CN.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](README.md) | 简体中文
4
4
 
5
- [![Version](https://img.shields.io/badge/version-4.7.8-blue.svg)](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
5
+ [![Version](https://img.shields.io/badge/version-4.7.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(389%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
- > 本翻译对应 v4.7.8 版 README。如与英文原版有出入,以 [英文原版](README.md) 为准。
15
+ > 本翻译对应 v4.7.9 版 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 = "4.7.8"
40
+ VERSION = "4.7.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": "4.7.8",
3
+ "version": "4.7.9",
4
4
  "description": "NPM bootstrapper for the DaVinci Resolve MCP Server.",
5
5
  "license": "MIT",
6
6
  "author": "Samuel Gursky <samgursky@gmail.com>",
@@ -93,7 +93,7 @@ if not logging.getLogger().handlers:
93
93
  handlers=[logging.StreamHandler()],
94
94
  )
95
95
 
96
- VERSION = "4.7.8"
96
+ VERSION = "4.7.9"
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()}")
@@ -810,7 +810,9 @@ def _get_timeline_item(track_type="video", track_index=1, item_index=0):
810
810
  if err:
811
811
  return None, err
812
812
  items = tl.GetItemListInTrack(track_type, track_index)
813
- if not items or item_index >= len(items):
813
+ # Reject negatives: `items[-1]` is the LAST clip, so a negative index would
814
+ # act on a clip nobody named (EX5 fixed the compound `_get_item`, not this twin).
815
+ if not items or item_index < 0 or item_index >= len(items):
814
816
  return None, {"error": f"No item at index {item_index} on {track_type} track {track_index}"}
815
817
  return items[item_index], None
816
818
 
@@ -4,6 +4,18 @@ from src.granular.common import * # noqa: F401,F403
4
4
 
5
5
  resolve = ResolveProxy()
6
6
 
7
+
8
+ def _index_in_range(idx, length):
9
+ """True for a real 0-based position. Negatives are refused: Python would read
10
+ `albums[-1]` as the last album and act on something nobody named."""
11
+ return isinstance(idx, int) and not isinstance(idx, bool) and 0 <= idx < length
12
+
13
+
14
+ def _invalid_indices(indices, length):
15
+ """The entries of `indices` that are not a 0-based position below `length`."""
16
+ return [i for i in indices if not _index_in_range(i, length)]
17
+
18
+
7
19
  @mcp.tool(annotations=READ_ONLY_TOOL)
8
20
  def get_gallery_album_name() -> Dict[str, Any]:
9
21
  """Get the name of the current gallery album."""
@@ -107,7 +119,7 @@ def set_current_still_album(album_index: int) -> Dict[str, Any]:
107
119
  if not gallery:
108
120
  return {"error": "Failed to get Gallery"}
109
121
  albums = gallery.GetGalleryStillAlbums()
110
- if not albums or album_index >= len(albums):
122
+ if not albums or album_index < 0 or album_index >= len(albums):
111
123
  return {"error": f"No album at index {album_index}"}
112
124
  result = gallery.SetCurrentStillAlbum(albums[album_index])
113
125
  return {"success": bool(result)}
@@ -176,7 +188,7 @@ def get_album_stills(album_index: int = 0) -> Dict[str, Any]:
176
188
  if not gallery:
177
189
  return {"error": "Failed to get Gallery"}
178
190
  albums = gallery.GetGalleryStillAlbums()
179
- if not albums or album_index >= len(albums):
191
+ if not albums or album_index < 0 or album_index >= len(albums):
180
192
  return {"error": f"No album at index {album_index}"}
181
193
  stills = albums[album_index].GetStills()
182
194
  return {"still_count": len(stills) if stills else 0}
@@ -198,10 +210,10 @@ def get_still_label(album_index: int, still_index: int) -> Dict[str, Any]:
198
210
  return {"error": "No project open"}
199
211
  gallery = project.GetGallery()
200
212
  albums = gallery.GetGalleryStillAlbums()
201
- if not albums or album_index >= len(albums):
213
+ if not albums or album_index < 0 or album_index >= len(albums):
202
214
  return {"error": f"No album at index {album_index}"}
203
215
  stills = albums[album_index].GetStills()
204
- if not stills or still_index >= len(stills):
216
+ if not stills or still_index < 0 or still_index >= len(stills):
205
217
  return {"error": f"No still at index {still_index}"}
206
218
  label = albums[album_index].GetLabel(stills[still_index])
207
219
  return {"label": label if label else ""}
@@ -225,10 +237,10 @@ def set_still_label(album_index: int, still_index: int, label: str) -> Dict[str,
225
237
  return {"error": "No project open"}
226
238
  gallery = project.GetGallery()
227
239
  albums = gallery.GetGalleryStillAlbums()
228
- if not albums or album_index >= len(albums):
240
+ if not albums or album_index < 0 or album_index >= len(albums):
229
241
  return {"error": f"No album at index {album_index}"}
230
242
  stills = albums[album_index].GetStills()
231
- if not stills or still_index >= len(stills):
243
+ if not stills or still_index < 0 or still_index >= len(stills):
232
244
  return {"error": f"No still at index {still_index}"}
233
245
  result = albums[album_index].SetLabel(stills[still_index], label)
234
246
  return {"success": bool(result)}
@@ -250,7 +262,7 @@ def import_stills_to_album(album_index: int, file_paths: List[str]) -> Dict[str,
250
262
  return {"error": "No project open"}
251
263
  gallery = project.GetGallery()
252
264
  albums = gallery.GetGalleryStillAlbums()
253
- if not albums or album_index >= len(albums):
265
+ if not albums or album_index < 0 or album_index >= len(albums):
254
266
  return {"error": f"No album at index {album_index}"}
255
267
  result = albums[album_index].ImportStills(file_paths)
256
268
  return {"success": bool(result)}
@@ -274,7 +286,7 @@ def export_stills_from_album(album_index: int, folder_path: str, file_prefix: st
274
286
  return {"error": "No project open"}
275
287
  gallery = project.GetGallery()
276
288
  albums = gallery.GetGalleryStillAlbums()
277
- if not albums or album_index >= len(albums):
289
+ if not albums or album_index < 0 or album_index >= len(albums):
278
290
  return {"error": f"No album at index {album_index}"}
279
291
  stills = albums[album_index].GetStills()
280
292
  if not stills:
@@ -300,11 +312,17 @@ def delete_stills_from_album(album_index: int, still_indices: List[int]) -> Dict
300
312
  return {"error": "No project open"}
301
313
  gallery = project.GetGallery()
302
314
  albums = gallery.GetGalleryStillAlbums()
303
- if not albums or album_index >= len(albums):
315
+ if not albums or album_index < 0 or album_index >= len(albums):
304
316
  return {"error": f"No album at index {album_index}"}
305
317
  stills = albums[album_index].GetStills()
306
318
  if not stills:
307
319
  return {"error": "No stills in album"}
308
- to_delete = [stills[i] for i in still_indices if i < len(stills)]
320
+ # A negative index is a real Python index (`stills[-1]` is the last still),
321
+ # and an out-of-range one used to be dropped while the rest were deleted.
322
+ # Refuse the whole call instead of deleting a set nobody asked for.
323
+ invalid = _invalid_indices(still_indices, len(stills))
324
+ if invalid:
325
+ return {"error": f"still_indices out of range for {len(stills)} stills: {invalid}"}
326
+ to_delete = [stills[i] for i in still_indices]
309
327
  result = albums[album_index].DeleteStills(to_delete)
310
328
  return {"success": bool(result)}
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 = "4.7.8"
14
+ VERSION = "4.7.9"
15
15
 
16
16
  import base64
17
17
  import os
@@ -28848,6 +28848,17 @@ def timeline_item_takes(action: str, params: Optional[Dict[str, Any]] = None) ->
28848
28848
  return _unknown(action, ["add","get_count","get_selected_index","get_by_index","select","delete","finalize"])
28849
28849
 
28850
28850
 
28851
+ def _index_in_range(idx, length):
28852
+ """True for a real 0-based position. Negatives are refused: Python would read
28853
+ `albums[-1]` as the last album and act on something nobody named."""
28854
+ return isinstance(idx, int) and not isinstance(idx, bool) and 0 <= idx < length
28855
+
28856
+
28857
+ def _invalid_indices(indices, length):
28858
+ """The entries of `indices` that are not a 0-based position below `length`."""
28859
+ return [i for i in indices if not _index_in_range(i, length)]
28860
+
28861
+
28851
28862
  # ═══════════════════════════════════════════════════════════════════════════════
28852
28863
  # TOOL 23: gallery
28853
28864
  # ═══════════════════════════════════════════════════════════════════════════════
@@ -28881,13 +28892,13 @@ def gallery(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[str, A
28881
28892
  if action == "get_album_name":
28882
28893
  albums = gal.GetGalleryStillAlbums() or []
28883
28894
  idx = p.get("album_index", 0)
28884
- if idx < len(albums):
28895
+ if _index_in_range(idx, len(albums)):
28885
28896
  return {"name": gal.GetAlbumName(albums[idx])}
28886
28897
  return _err("Album index out of range")
28887
28898
  elif action == "set_album_name":
28888
28899
  albums = gal.GetGalleryStillAlbums() or []
28889
28900
  idx = p.get("album_index", 0)
28890
- if idx < len(albums):
28901
+ if _index_in_range(idx, len(albums)):
28891
28902
  return {"success": bool(gal.SetAlbumName(albums[idx], p["name"]))}
28892
28903
  return _err("Album index out of range")
28893
28904
  elif action == "get_current_album":
@@ -28896,7 +28907,7 @@ def gallery(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[str, A
28896
28907
  elif action == "set_current_album":
28897
28908
  albums = gal.GetGalleryStillAlbums() or []
28898
28909
  idx = p.get("album_index", 0)
28899
- if idx < len(albums):
28910
+ if _index_in_range(idx, len(albums)):
28900
28911
  return {"success": bool(gal.SetCurrentStillAlbum(albums[idx]))}
28901
28912
  return _err("Album index out of range")
28902
28913
  elif action == "get_still_albums":
@@ -28964,7 +28975,7 @@ def gallery_stills(action: str, params: Optional[Dict[str, Any]] = None) -> Dict
28964
28975
  album_idx = p.get("album_index")
28965
28976
  if album_idx is not None:
28966
28977
  albums = gal.GetGalleryStillAlbums() or []
28967
- if album_idx < len(albums):
28978
+ if _index_in_range(album_idx, len(albums)):
28968
28979
  album = albums[album_idx]
28969
28980
  else:
28970
28981
  return _err("Album index out of range")
@@ -28982,13 +28993,13 @@ def gallery_stills(action: str, params: Optional[Dict[str, Any]] = None) -> Dict
28982
28993
  elif action == "get_label":
28983
28994
  stills = album.GetStills() or []
28984
28995
  idx = p.get("still_index", 0)
28985
- if idx < len(stills):
28996
+ if _index_in_range(idx, len(stills)):
28986
28997
  return {"label": album.GetLabel(stills[idx])}
28987
28998
  return _err("Still index out of range")
28988
28999
  elif action == "set_label":
28989
29000
  stills = album.GetStills() or []
28990
29001
  idx = p.get("still_index", 0)
28991
- if idx < len(stills):
29002
+ if _index_in_range(idx, len(stills)):
28992
29003
  return {"success": bool(album.SetLabel(stills[idx], p["label"]))}
28993
29004
  return _err("Still index out of range")
28994
29005
  elif action == "import_stills":
@@ -29119,8 +29130,15 @@ def gallery_stills(action: str, params: Optional[Dict[str, Any]] = None) -> Dict
29119
29130
  return {"files": file_details, "format": used_format, "folder": folder_path, "cleaned_up": cleanup}
29120
29131
  elif action == "delete_stills":
29121
29132
  stills = album.GetStills() or []
29122
- to_delete = [stills[i] for i in p["still_indices"] if i < len(stills)]
29123
- return {"success": bool(album.DeleteStills(to_delete))} if to_delete else _err("No valid still indices")
29133
+ still_indices = p["still_indices"]
29134
+ if not isinstance(still_indices, list) or not still_indices:
29135
+ return _err("still_indices must be a non-empty list of 0-based indices")
29136
+ # A negative index is a real Python index (`stills[-1]` is the last still),
29137
+ # and an out-of-range one used to be dropped while the rest were deleted.
29138
+ invalid = _invalid_indices(still_indices, len(stills))
29139
+ if invalid:
29140
+ return _err(f"still_indices out of range for {len(stills)} stills: {invalid}")
29141
+ return {"success": bool(album.DeleteStills([stills[i] for i in still_indices]))}
29124
29142
  return _unknown(action, ["get_stills","get_label","set_label","import_stills","export_stills","grab_and_export","delete_stills"])
29125
29143
 
29126
29144