obs-mcp 0.2.0

OBS Studio control server for AI assistants via MCP and the OBS WebSocket protocol
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
#!/usr/bin/env python3
"""Generate src/tools_table.rs from TypeScript OBS WebSocket tool modules.

Parses the TypeScript tool definitions for the OBS WebSocket v5 protocol
and emits a Rust table of ToolDef rows. The tool surface mirrors the
public OBS WebSocket v5 protocol; descriptions are original short
factual sentences written for this project.

Usage:
    python3 scripts/gen_tools_table.py [path-to-ts-tools-dir]

The tools directory defaults to the OBS_MCP_TS_REFERENCE environment
variable; pass it as an argument otherwise.
"""

import os
import re
import sys
from pathlib import Path

TOOLS_DIR = (
    Path(sys.argv[1])
    if len(sys.argv) > 1
    else Path(os.environ.get("OBS_MCP_TS_REFERENCE", ""))
)
if not TOOLS_DIR.is_dir():
    print(
        "usage: python3 scripts/gen_tools_table.py [path-to-ts-tools-dir]\n"
        "or set OBS_MCP_TS_REFERENCE to the reference clone's src/tools directory",
        file=sys.stderr,
    )
    sys.exit(1)

# (tool_name, request_type, params, renames, description)
# params: list of (name, kind, required, desc)
#   kind in: str, num, int, bool, obj, enum:val1|val2
# renames: list of (tool_arg, request_field)
TOOLS = [
    # --- config: persistent data, scene collections, profiles, video, service ---
    ("obs-get-persistent-data", "GetPersistentData",
     [("realm", "str", True, "Data realm: 'OBS_WEBSOCKET_DATA_REALM_GLOBAL' or 'OBS_WEBSOCKET_DATA_REALM_PROFILE'."),
      ("slotName", "str", True, "Name of the data slot to retrieve.")], [],
     "Read a value from OBS persistent data storage for a realm and slot."),
    ("obs-set-persistent-data", "SetPersistentData",
     [("realm", "str", True, "Data realm to write to."),
      ("slotName", "str", True, "Name of the data slot to write."),
      ("slotValue", "obj", True, "Arbitrary JSON value to store in the slot.")], [],
     "Store an arbitrary JSON value in OBS persistent data storage."),
    ("obs-get-scene-collection-list", "GetSceneCollectionList", [], [],
     "List the names of all scene collections in OBS."),
    ("obs-set-current-scene-collection", "SetCurrentSceneCollection",
     [("sceneCollectionName", "str", True, "Name of the scene collection to switch to.")], [],
     "Switch OBS to a different scene collection."),
    ("obs-create-scene-collection", "CreateSceneCollection",
     [("sceneCollectionName", "str", True, "Name for the new scene collection.")], [],
     "Create a new empty scene collection and switch to it."),
    ("obs-get-profile-list", "GetProfileList", [], [],
     "List the names of all configuration profiles in OBS."),
    ("obs-set-current-profile", "SetCurrentProfile",
     [("profileName", "str", True, "Name of the profile to switch to.")], [],
     "Switch OBS to a different configuration profile."),
    ("obs-create-profile", "CreateProfile",
     [("profileName", "str", True, "Name for the new profile.")], [],
     "Create a new empty configuration profile and switch to it."),
    ("obs-remove-profile", "RemoveProfile",
     [("profileName", "str", True, "Name of the profile to remove.")], [],
     "Delete a configuration profile from OBS."),
    ("obs-get-profile-parameter", "GetProfileParameter",
     [("parameterCategory", "str", True, "Category of the profile parameter."),
      ("parameterName", "str", True, "Name of the profile parameter.")], [],
     "Read a single parameter from the current OBS profile."),
    ("obs-set-profile-parameter", "SetProfileParameter",
     [("parameterCategory", "str", True, "Category of the profile parameter."),
      ("parameterName", "str", True, "Name of the profile parameter."),
      ("parameterValue", "str", True, "New value for the parameter.")], [],
     "Write a single parameter in the current OBS profile."),
    ("obs-get-video-settings", "GetVideoSettings", [], [],
     "Get the base and output canvas resolutions and the fractional FPS value of OBS."),
    ("obs-set-video-settings", "SetVideoSettings",
     [("fpsNumerator", "num", False, "Numerator of the fractional FPS value."),
      ("fpsDenominator", "num", False, "Denominator of the fractional FPS value."),
      ("baseWidth", "num", False, "Width of the base (canvas) resolution in pixels."),
      ("baseHeight", "num", False, "Height of the base (canvas) resolution in pixels."),
      ("outputWidth", "num", False, "Width of the output resolution in pixels."),
      ("outputHeight", "num", False, "Height of the output resolution in pixels.")], [],
     "Update the video output settings of OBS: resolution and frame rate."),
    ("obs-get-stream-service-settings", "GetStreamServiceSettings", [], [],
     "Get the stream service settings: the service type (rtmp_common, etc.) and its configuration."),
    ("obs-set-stream-service-settings", "SetStreamServiceSettings",
     [("streamServiceType", "str", True, "Type of the stream service, e.g. 'rtmp_common'."),
      ("streamServiceSettings", "obj", True, "Settings object for the stream service (key, server, etc.).")], [],
     "Set the stream service settings used for streaming."),
    ("obs-get-record-directory", "GetRecordDirectory", [], [],
     "Get the directory OBS saves recordings to."),
    ("obs-set-record-directory", "SetRecordDirectory",
     [("recordDirectory", "str", True, "Absolute path of the recording directory.")], [],
     "Change the directory OBS saves recordings to."),

    # --- filters ---
    ("obs-get-filter-kind-list", "GetSourceFilterKindList", [], [],
     "List all available source filter kinds (types) in OBS."),
    ("obs-get-source-filter-list", "GetSourceFilterList",
     [("sourceName", "str", True, "Name of the source to list filters for.")], [],
     "List the filters attached to a source, with their settings and enabled state."),
    ("obs-get-filter-default-settings", "GetSourceFilterDefaultSettings",
     [("filterKind", "str", True, "Kind of filter to get default settings for.")], [],
     "Get the default settings for a source filter kind."),
    ("obs-create-source-filter", "CreateSourceFilter",
     [("sourceName", "str", True, "Name of the source to add the filter to."),
      ("filterName", "str", True, "Name for the new filter."),
      ("filterKind", "str", True, "Kind of filter to create."),
      ("filterSettings", "obj", False, "Settings object to initialize the filter with.")], [],
     "Create a new filter on a source and optionally initialize its settings."),
    ("obs-remove-source-filter", "RemoveSourceFilter",
     [("sourceName", "str", True, "Name of the source the filter belongs to."),
      ("filterName", "str", True, "Name of the filter to remove.")], [],
     "Remove a filter from a source."),
    ("obs-set-source-filter-name", "SetSourceFilterName",
     [("sourceName", "str", True, "Name of the source the filter belongs to."),
      ("filterName", "str", True, "Current name of the filter."),
      ("newFilterName", "str", True, "New name for the filter.")], [],
     "Rename a source filter."),
    ("obs-get-source-filter", "GetSourceFilter",
     [("sourceName", "str", True, "Name of the source the filter belongs to."),
      ("filterName", "str", True, "Name of the filter to read.")], [],
     "Get the settings, kind and enabled state of one source filter."),
    ("obs-set-source-filter-index", "SetSourceFilterIndex",
     [("sourceName", "str", True, "Name of the source the filter belongs to."),
      ("filterName", "str", True, "Name of the filter to move."),
      ("filterIndex", "num", True, "New index (position) of the filter in the chain.")], [],
     "Move a source filter to a new position in the filter chain."),
    ("obs-set-source-filter-settings", "SetSourceFilterSettings",
     [("sourceName", "str", True, "Name of the source the filter belongs to."),
      ("filterName", "str", True, "Name of the filter to configure."),
      ("filterSettings", "obj", True, "Settings object to apply to the filter."),
      ("overlay", "bool", False, "True to merge over existing settings, false to replace them.")], [],
     "Update the settings of a source filter, optionally overlaying existing values."),
    ("obs-set-source-filter-enabled", "SetSourceFilterEnabled",
     [("sourceName", "str", True, "Name of the source the filter belongs to."),
      ("filterName", "str", True, "Name of the filter to enable or disable."),
      ("filterEnabled", "bool", True, "True to enable the filter, false to disable it.")], [],
     "Enable or disable a source filter."),

    # --- general ---
    ("obs-get-status", "GetVersion", [], [],
     "Report the MCP server status and the OBS connection state: connected, identified, URL, password configured, auto-start configured and triggered, and the OBS and WebSocket versions."),
    ("obs-get-version", "GetVersion", [], [],
     "Get OBS Studio, obs-websocket and RPC version information."),
    ("obs-test-connection", "GetVersion", [], [],
     "Test the OBS WebSocket connection by issuing a lightweight version request."),
    ("obs-get-stats", "GetStats", [], [],
     "Get statistics about OBS, obs-websocket and the current session (CPU, memory, disk, fps)."),
    ("obs-broadcast-custom-event", "BroadcastCustomEvent",
     [("eventData", "obj", True, "Arbitrary JSON payload to emit to all WebSocket receivers.")], [],
     "Broadcast a custom event to all OBS WebSocket clients."),
    ("obs-call-vendor-request", "CallVendorRequest",
     [("vendorName", "str", True, "Name of the vendor implementing the request."),
      ("requestType", "str", True, "Request type to call."),
      ("requestData", "obj", False, "Arbitrary JSON data for the request.")], [],
     "Call a request registered by a vendor plugin in OBS."),
    ("obs-get-hotkey-list", "GetHotkeyList", [], [],
     "List the names of all hotkeys registered in OBS."),
    ("obs-trigger-hotkey-by-name", "TriggerHotkeyByName",
     [("hotkeyName", "str", True, "Name of the hotkey to trigger."),
      ("contextName", "str", False, "Name of the context of the hotkey to trigger.")], [],
     "Trigger a hotkey in OBS by its registered name."),
    ("obs-trigger-hotkey-by-key-sequence", "TriggerHotkeyByKeySequence",
     [("keyId", "str", False, "OBS internal key identifier (OBS_KEY_*)."),
      ("keyModifiers", "obj", False, "Object with boolean shift, control, alt, command modifiers.")], [],
     "Trigger a hotkey in OBS by simulating a key sequence with modifiers."),
    ("obs-sleep", "Sleep",
     [("sleepMillis", "num", False, "Number of milliseconds to sleep."),
      ("sleepFrames", "num", False, "Number of frames to sleep.")], [],
     "Pause the OBS WebSocket request pipeline for a duration or a frame count."),

    # --- inputs ---
    ("obs-get-input-list", "GetInputList",
     [("inputKind", "str", False, "Kind of inputs to filter by (optional).")], [],
     "List inputs (sources with audio/video) in OBS, optionally filtered by kind."),
    ("obs-get-input-kind-list", "GetInputKindList",
     [("unversioned", "bool", False, "True to return unversioned kind strings.")], [],
     "List all available input kinds in OBS."),
    ("obs-get-special-inputs", "GetSpecialInputs", [], [],
     "Get the names of the special OBS inputs: desktop audio, mic, and so on."),
    ("obs-create-input", "CreateInput",
     [("sceneName", "str", True, "Name of the scene to add the input to as a scene item."),
      ("inputName", "str", True, "Name for the new input."),
      ("inputKind", "str", True, "Kind of input to create."),
      ("inputSettings", "obj", False, "Settings object to initialize the input with."),
      ("sceneItemEnabled", "bool", False, "Whether the created scene item starts enabled.")], [],
     "Create a new input source, add it to a scene, and return the new scene item id."),
    ("obs-remove-input", "RemoveInput",
     [("inputName", "str", True, "Name of the input to remove.")], [],
     "Remove an input source from OBS."),
    ("obs-set-input-name", "SetInputName",
     [("inputName", "str", True, "Current name of the input."),
      ("newInputName", "str", True, "New name for the input.")], [],
     "Rename an input source."),
    ("obs-get-input-default-settings", "GetInputDefaultSettings",
     [("inputKind", "str", True, "Kind of input to get default settings for.")], [],
     "Get the default settings for an input kind."),
    ("obs-get-input-settings", "GetInputSettings",
     [("inputName", "str", True, "Name of the input to read.")], [],
     "Get the current settings of an input source."),
    ("obs-set-input-settings", "SetInputSettings",
     [("inputName", "str", True, "Name of the input to configure."),
      ("inputSettings", "obj", True, "Settings object to apply."),
      ("overlay", "bool", False, "True to merge over existing settings, false to replace them.")], [],
     "Update the settings of an input source, optionally overlaying existing values."),
    ("obs-get-input-mute", "GetInputMute",
     [("inputName", "str", True, "Name of the input to query.")], [],
     "Check whether an input source is muted."),
    ("obs-set-input-mute", "SetInputMute",
     [("inputName", "str", True, "Name of the input."),
      ("inputMuted", "bool", True, "True to mute, false to unmute.")], [],
     "Mute or unmute an input source."),
    ("obs-toggle-input-mute", "ToggleInputMute",
     [("inputName", "str", True, "Name of the input to toggle.")], [],
     "Toggle the mute state of an input source and report the new state."),
    ("obs-get-input-volume", "GetInputVolume",
     [("inputName", "str", True, "Name of the input to query.")], [],
     "Get the volume of an input source in both multiplier and dB."),
    ("obs-set-input-volume", "SetInputVolume",
     [("inputName", "str", True, "Name of the input."),
      ("inputVolumeMul", "num", False, "Volume multiplier in the range 0 to 20."),
      ("inputVolumeDb", "num", False, "Volume in dB in the range -100 to 26.")], [],
     "Set the volume of an input source by multiplier or dB. Provide exactly one of the two."),
    ("obs-get-input-audio-balance", "GetInputAudioBalance",
     [("inputName", "str", True, "Name of the input to query.")], [],
     "Get the stereo audio balance of an input source."),
    ("obs-set-input-audio-balance", "SetInputAudioBalance",
     [("inputName", "str", True, "Name of the input."),
      ("inputAudioBalance", "num", True, "Balance value between 0.0 (left) and 1.0 (right).")], [],
     "Set the stereo audio balance of an input source."),
    ("obs-get-input-audio-sync-offset", "GetInputAudioSyncOffset",
     [("inputName", "str", True, "Name of the input to query.")], [],
     "Get the audio sync offset of an input source in milliseconds."),
    ("obs-set-input-audio-sync-offset", "SetInputAudioSyncOffset",
     [("inputName", "str", True, "Name of the input."),
      ("inputAudioSyncOffset", "num", True, "Sync offset in milliseconds.")], [],
     "Set the audio sync offset of an input source in milliseconds."),
    ("obs-get-input-audio-monitor-type", "GetInputAudioMonitorType",
     [("inputName", "str", True, "Name of the input to query.")], [],
     "Get the audio monitor type of an input source."),
    ("obs-set-input-audio-monitor-type", "SetInputAudioMonitorType",
     [("inputName", "str", True, "Name of the input."),
      ("monitorType", "str", True, "Monitor type: OBS_MONITORING_TYPE_NONE, MONITOR_ONLY or BOTH.")], [],
     "Set the audio monitor type of an input source."),

    # --- media inputs ---
    ("obs-get-media-input-status", "GetMediaInputStatus",
     [("inputName", "str", True, "Name of the media input to query.")], [],
     "Get the playback state of a media input: media state, cursor, duration."),
    ("obs-set-media-input-cursor", "SetMediaInputCursor",
     [("inputName", "str", True, "Name of the media input."),
      ("mediaCursor", "num", True, "New playback cursor position in milliseconds.")], [],
     "Seek a media input to a new cursor position in milliseconds."),
    ("obs-offset-media-input-cursor", "OffsetMediaInputCursor",
     [("inputName", "str", True, "Name of the media input."),
      ("mediaCursorOffset", "num", True, "Cursor offset in milliseconds (can be negative).")], [],
     "Offset the playback cursor of a media input by a number of milliseconds."),
    ("obs-trigger-media-input-action", "TriggerMediaInputAction",
     [("inputName", "str", True, "Name of the media input."),
      ("mediaAction", "enum:OBS_MEDIA_STATE_NONE|OBS_MEDIA_STATE_PLAYING|OBS_MEDIA_STATE_OPENING|OBS_MEDIA_STATE_BUFFERING|OBS_MEDIA_STATE_PAUSED|OBS_MEDIA_STATE_STOPPED|OBS_MEDIA_STATE_ENDED|OBS_MEDIA_STATE_ERROR", True,
       "Media action to trigger: play, pause, stop, restart, next, previous.")], [],
     "Trigger an action on a media input such as play, pause, stop or restart."),

    # --- outputs: virtual cam, replay buffer, generic outputs ---
    ("obs-get-virtual-cam-status", "GetVirtualCamStatus", [], [],
     "Check whether the virtual camera output is active."),
    ("obs-toggle-virtual-cam", "ToggleVirtualCam", [], [],
     "Toggle the virtual camera output and report its new state."),
    ("obs-start-virtual-cam", "StartVirtualCam", [], [],
     "Start the virtual camera output."),
    ("obs-stop-virtual-cam", "StopVirtualCam", [], [],
     "Stop the virtual camera output."),
    ("obs-get-replay-buffer-status", "GetReplayBufferStatus", [], [],
     "Check whether the replay buffer output is active."),
    ("obs-toggle-replay-buffer", "ToggleReplayBuffer", [], [],
     "Toggle the replay buffer output and report its new state."),
    ("obs-start-replay-buffer", "StartReplayBuffer", [], [],
     "Start the replay buffer output."),
    ("obs-stop-replay-buffer", "StopReplayBuffer", [], [],
     "Stop the replay buffer output."),
    ("obs-save-replay-buffer", "SaveReplayBuffer", [], [],
     "Save the current replay buffer contents to disk."),
    ("obs-get-last-replay-buffer-replay", "GetLastReplayBufferReplay", [], [],
     "Get the filename of the last saved replay buffer replay."),
    ("obs-get-output-list", "GetOutputList", [], [],
     "List all outputs in OBS with their active state."),
    ("obs-get-output-status", "GetOutputStatus",
     [("outputName", "str", True, "Name of the output to query.")], [],
     "Get the active state, reconnecting state and timecode of an output."),
    ("obs-toggle-output", "ToggleOutput",
     [("outputName", "str", True, "Name of the output to toggle.")], [],
     "Toggle the active state of an output."),
    ("obs-start-output", "StartOutput",
     [("outputName", "str", True, "Name of the output to start.")], [],
     "Start an output by name."),
    ("obs-stop-output", "StopOutput",
     [("outputName", "str", True, "Name of the output to stop.")], [],
     "Stop an output by name."),
    ("obs-get-output-settings", "GetOutputSettings",
     [("outputName", "str", True, "Name of the output to read.")], [],
     "Get the settings of an output."),
    ("obs-set-output-settings", "SetOutputSettings",
     [("outputName", "str", True, "Name of the output."),
      ("outputSettings", "obj", True, "Settings object to apply to the output.")], [],
     "Update the settings of an output."),

    # --- recording ---
    ("obs-get-record-status", "GetRecordStatus", [], [],
     "Get the recording state: active, paused, and the recording timecode."),
    ("obs-toggle-record", "ToggleRecord", [], [],
     "Toggle recording and report the new state."),
    ("obs-start-record", "StartRecord", [], [],
     "Start recording."),
    ("obs-stop-record", "StopRecord", [], [],
     "Stop recording and report the output path of the saved file."),
    ("obs-toggle-record-pause", "ToggleRecordPause", [], [],
     "Toggle the paused state of an active recording."),
    ("obs-pause-record", "PauseRecord", [], [],
     "Pause an active recording."),
    ("obs-resume-record", "ResumeRecord", [], [],
     "Resume a paused recording."),
    ("obs-split-record-file", "SplitRecordFile", [], [],
     "Split the current recording into a new file."),
    ("obs-create-record-chapter", "CreateRecordChapter",
     [("chapterName", "str", False, "Name for the new recording chapter (optional).")], [],
     "Create a chapter marker in the current recording at the current time."),

    # --- scene items ---
    ("obs-get-scene-items", "GetSceneItemList",
     [("sceneName", "str", True, "Name of the scene to list items for.")], [],
     "List the scene items of a scene with their ids and source names."),
    ("obs-create-scene-item", "CreateSceneItem",
     [("sceneName", "str", True, "Name of the scene to add the item to."),
      ("sourceName", "str", True, "Name of the source to add."),
      ("enabled", "bool", False, "Whether the item starts visible (default true).")],
     [("enabled", "sceneItemEnabled")],
     "Add a source as a scene item to a scene and return the new scene item id."),
    ("obs-remove-scene-item", "RemoveSceneItem",
     [("sceneName", "str", True, "Name of the scene the item is in."),
      ("sceneItemId", "num", True, "Id of the scene item to remove.")], [],
     "Remove a scene item from a scene."),
    ("obs-set-scene-item-enabled", "SetSceneItemEnabled",
     [("sceneName", "str", True, "Name of the scene the item is in."),
      ("sceneItemId", "num", True, "Id of the scene item."),
      ("enabled", "bool", True, "True to show the item, false to hide it.")],
     [("enabled", "sceneItemEnabled")],
     "Show or hide a scene item."),
    ("obs-get-scene-item-transform", "GetSceneItemTransform",
     [("sceneName", "str", True, "Name of the scene the item is in."),
      ("sceneItemId", "num", True, "Id of the scene item.")], [],
     "Get the transform (position, rotation, scale, crop) of a scene item."),
    ("obs-set-scene-item-transform", "SetSceneItemTransform",
     [("sceneName", "str", True, "Name of the scene the item is in."),
      ("sceneItemId", "num", True, "Id of the scene item."),
      ("transform", "obj", True, "Transform object: positionX, positionY, rotation, scaleX, scaleY, cropTop, cropBottom, cropLeft, cropRight, bounds* fields.")], [],
     "Set the transform of a scene item: position, rotation, scale and crop."),
    ("obs-get-scene-item-id", "GetSceneItemId",
     [("sceneName", "str", True, "Name of the scene to search in."),
      ("sourceName", "str", True, "Name of the source to find.")], [],
     "Find the scene item id of a source inside a scene."),

    # --- scenes ---
    ("obs-get-scene-list", "GetSceneList", [], [],
     "List all scenes in OBS with the current program scene marked."),
    ("obs-get-current-scene", "GetCurrentProgramScene", [], [],
     "Get the name of the current program (live) scene."),
    ("obs-set-current-scene", "SetCurrentProgramScene",
     [("sceneName", "str", True, "Name of the scene to switch to.")], [],
     "Switch the program scene to a named scene."),
    ("obs-get-preview-scene", "GetCurrentPreviewScene", [], [],
     "Get the current preview scene when studio mode is enabled."),
    ("obs-set-preview-scene", "SetCurrentPreviewScene",
     [("sceneName", "str", True, "Name of the scene to show in preview.")], [],
     "Set the preview scene when studio mode is enabled."),
    ("obs-create-scene", "CreateScene",
     [("sceneName", "str", True, "Name for the new scene.")], [],
     "Create a new empty scene."),
    ("obs-remove-scene", "RemoveScene",
     [("sceneName", "str", True, "Name of the scene to remove.")], [],
     "Remove a scene from OBS."),
    ("obs-trigger-studio-transition", "TriggerStudioModeTransition", [], [],
     "Trigger the transition from preview to program scene in studio mode."),

    # --- sources ---
    ("obs-get-source-active", "GetSourceActive",
     [("sourceName", "str", False, "Name of the source (or its UUID) to query."),
      ("sourceUuid", "str", False, "UUID of the source (alternative to sourceName).")], [],
     "Check whether a source is visible in any scene."),
    ("obs-get-source-screenshot", "GetSourceScreenshot",
     [("sourceName", "str", False, "Name of the source to capture."),
      ("sourceUuid", "str", False, "UUID of the source (alternative to sourceName)."),
      ("imageFormat", "str", True, "Image format: png, jpg, bmp, webp."),
      ("imageWidth", "num", False, "Width to scale the screenshot to."),
      ("imageHeight", "num", False, "Height to scale the screenshot to."),
      ("imageCompressionQuality", "num", False, "Compression quality 0-100, -1 for default.")], [],
     "Take a screenshot of a source and return it as a base64-encoded image."),
    ("obs-save-source-screenshot", "SaveSourceScreenshot",
     [("sourceName", "str", False, "Name of the source to capture."),
      ("sourceUuid", "str", False, "UUID of the source (alternative to sourceName)."),
      ("imageFormat", "str", True, "Image format: png, jpg, bmp, webp."),
      ("imageFilePath", "str", True, "Filesystem path to save the screenshot to."),
      ("imageWidth", "num", False, "Width to scale the screenshot to."),
      ("imageHeight", "num", False, "Height to scale the screenshot to."),
      ("imageCompressionQuality", "num", False, "Compression quality 0-100, -1 for default.")], [],
     "Take a screenshot of a source and save it to a file on disk."),

    # --- streaming ---
    ("obs-get-stream-status", "GetStreamStatus", [], [],
     "Get the streaming state: active, reconnecting, and the stream timecode."),
    ("obs-start-stream", "StartStream", [], [],
     "Start streaming."),
    ("obs-stop-stream", "StopStream", [], [],
     "Stop streaming."),
    ("obs-toggle-stream", "ToggleStream", [], [],
     "Toggle streaming and report the new state."),
    ("obs-send-stream-caption", "SendStreamCaption",
     [("captionText", "str", True, "CEA-608 caption text to send over the stream.")], [],
     "Send a CEA-608 caption over the active stream output."),

    # --- transitions ---
    ("obs-get-transition-list", "GetSceneTransitionList", [], [],
     "List all scene transitions in OBS with the current transition marked."),
    ("obs-get-current-transition", "GetCurrentSceneTransition", [], [],
     "Get the current scene transition: name, kind and settings."),
    ("obs-set-current-transition", "SetCurrentSceneTransition",
     [("transitionName", "str", True, "Name of the transition to make current.")], [],
     "Set the active scene transition by name."),
    ("obs-get-transition-duration", "GetCurrentSceneTransition", [], [],
     "Get the duration of the current scene transition in milliseconds (returned by the current transition object)."),
    ("obs-set-transition-duration", "SetCurrentSceneTransitionDuration",
     [("duration", "num", True, "Transition duration in milliseconds.")],
     [("duration", "transitionDuration")],
     "Set the duration of the current scene transition in milliseconds."),
    ("obs-get-transition-kind", "GetCurrentSceneTransition", [], [],
     "Get the kind of the current scene transition."),
    ("obs-set-transition-settings", "SetCurrentSceneTransitionSettings",
     [("transitionSettings", "obj", True, "Settings object for the current transition.")], [],
     "Update the settings of the current scene transition."),
    ("obs-get-transition-settings", "GetCurrentSceneTransition", [], [],
     "Get the settings of the current scene transition (returned by the current transition object)."),
    ("obs-trigger-transition", "TriggerStudioModeTransition", [], [],
     "Trigger a studio mode transition from preview to program."),

    # --- studio mode / UI ---
    ("obs-get-studio-mode", "GetStudioModeEnabled", [], [],
     "Check whether studio mode is enabled."),
    ("obs-set-studio-mode", "SetStudioModeEnabled",
     [("studioModeEnabled", "bool", True, "True to enable studio mode, false to disable.")], [],
     "Enable or disable studio mode."),
    ("obs-open-input-properties", "OpenInputPropertiesDialog",
     [("inputName", "str", False, "Name of the input."),
      ("inputUuid", "str", False, "UUID of the input (alternative to inputName).")], [],
     "Open the properties dialog of an input in the OBS UI."),
    ("obs-open-input-filters", "OpenInputFiltersDialog",
     [("inputName", "str", False, "Name of the input."),
      ("inputUuid", "str", False, "UUID of the input (alternative to inputName).")], [],
     "Open the filters dialog of an input in the OBS UI."),
    ("obs-open-input-interact", "OpenInputInteractDialog",
     [("inputName", "str", False, "Name of the input."),
      ("inputUuid", "str", False, "UUID of the input (alternative to inputName).")], [],
     "Open the interaction dialog of an input in the OBS UI."),
    ("obs-get-monitor-list", "GetMonitorList", [], [],
     "List the monitors detected by OBS with their geometry."),
    ("obs-open-video-mix-projector", "OpenVideoMixProjector",
     [("videoMixType", "enum:OBS_WEBSOCKET_VIDEO_MIX_TYPE_PREVIEW|OBS_WEBSOCKET_VIDEO_MIX_TYPE_PROGRAM|OBS_WEBSOCKET_VIDEO_MIX_TYPE_MULTIVIEW", True,
       "Video mix type: preview, program or multiview."),
      ("monitorIndex", "num", False, "Index of the monitor to open the projector on."),
      ("projectorGeometry", "str", False, "Projector geometry as a string like '0,0,1280,720'.")], [],
     "Open a video mix projector window in the OBS UI."),
    ("obs-open-source-projector", "OpenSourceProjector",
     [("sourceName", "str", False, "Name of the source to project."),
      ("sourceUuid", "str", False, "UUID of the source (alternative to sourceName)."),
      ("monitorIndex", "num", False, "Index of the monitor to open the projector on."),
      ("projectorGeometry", "str", False, "Projector geometry as a string like '0,0,1280,720'.")], [],
     "Open a source projector window in the OBS UI."),

    # --- canvas / group support (OBS 32 protocol) ---
    ("obs-get-canvas-list", "GetCanvasList", [], [],
     "List all canvases in OBS with their resolution and scene counts."),
    ("obs-get-group-list", "GetGroupList", [], [],
     "List all groups in OBS with their scene items."),
    ("obs-get-group-scene-items", "GetGroupSceneItemList",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the group to list items for."),
      ("sceneUuid", "str", False, "UUID of the group (alternative to sceneName).")], [],
     "List the scene items of a group."),
    ("obs-set-scene-name", "SetSceneName",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Current name of the scene to rename."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName)."),
      ("newSceneName", "str", True, "New name for the scene.")], [],
     "Rename a scene in OBS."),

    # --- scene item per-property accessors (OBS 32 protocol) ---
    ("obs-duplicate-scene-item", "DuplicateSceneItem",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the scene the item is in."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName)."),
      ("sceneItemId", "num", True, "Id of the scene item to duplicate."),
      ("destinationSceneName", "str", False, "Name of the scene to copy the item into (defaults to the source scene)."),
      ("destinationSceneUuid", "str", False, "UUID of the destination scene (alternative to destinationSceneName).")], [],
     "Duplicate a scene item, copying its transform, crop and settings."),
    ("obs-get-scene-item-enabled", "GetSceneItemEnabled",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the scene the item is in."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName)."),
      ("sceneItemId", "num", True, "Id of the scene item.")], [],
     "Check whether a scene item is visible (enabled)."),
    ("obs-get-scene-item-index", "GetSceneItemIndex",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the scene the item is in."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName)."),
      ("sceneItemId", "num", True, "Id of the scene item.")], [],
     "Get the index position of a scene item in its scene."),
    ("obs-set-scene-item-index", "SetSceneItemIndex",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the scene the item is in."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName)."),
      ("sceneItemId", "num", True, "Id of the scene item."),
      ("sceneItemIndex", "num", True, "New index position of the item.")], [],
     "Set the index position of a scene item in its scene."),
    ("obs-get-scene-item-locked", "GetSceneItemLocked",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the scene the item is in."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName)."),
      ("sceneItemId", "num", True, "Id of the scene item.")], [],
     "Check whether a scene item is locked."),
    ("obs-set-scene-item-locked", "SetSceneItemLocked",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the scene the item is in."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName)."),
      ("sceneItemId", "num", True, "Id of the scene item."),
      ("sceneItemLocked", "bool", True, "True to lock the item, false to unlock.")], [],
     "Lock or unlock a scene item."),
    ("obs-get-scene-item-blend-mode", "GetSceneItemBlendMode",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the scene the item is in."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName)."),
      ("sceneItemId", "num", True, "Id of the scene item.")], [],
     "Get the blend mode of a scene item."),
    ("obs-set-scene-item-blend-mode", "SetSceneItemBlendMode",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the scene the item is in."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName)."),
      ("sceneItemId", "num", True, "Id of the scene item."),
      ("sceneItemBlendMode", "str", True, "Blend mode, e.g. OBS_BLEND_NORMAL, OBS_BLEND_ADDITIVE, OBS_BLEND_SCREEN.")], [],
     "Set the blend mode of a scene item."),
    ("obs-get-scene-item-source", "GetSceneItemSource",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the scene the item is in."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName)."),
      ("sceneItemId", "num", True, "Id of the scene item.")], [],
     "Get the source (name and id) associated with a scene item."),
    ("obs-get-scene-item-private-settings", "GetSceneItemPrivateSettings",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the scene the item is in."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName)."),
      ("sceneItemId", "num", True, "Id of the scene item.")], [],
     "Get the private (internal) settings of a scene item."),
    ("obs-set-scene-item-private-settings", "SetSceneItemPrivateSettings",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the scene the item is in."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName)."),
      ("sceneItemId", "num", True, "Id of the scene item."),
      ("sceneItemSettings", "obj", True, "Private settings object to overlay onto the item.")], [],
     "Update the private (internal) settings of a scene item; values are overlaid, never wiped."),
    ("obs-get-source-private-settings", "GetSourcePrivateSettings",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sourceName/sourceUuid)."),
      ("sourceName", "str", False, "Name of the source."),
      ("sourceUuid", "str", False, "UUID of the source (alternative to sourceName).")], [],
     "Get the private (internal) settings of a source."),
    ("obs-set-source-private-settings", "SetSourcePrivateSettings",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sourceName/sourceUuid)."),
      ("sourceName", "str", False, "Name of the source."),
      ("sourceUuid", "str", False, "UUID of the source (alternative to sourceName)."),
      ("sourceSettings", "obj", True, "Private settings object to overlay onto the source.")], [],
     "Update the private (internal) settings of a source; values are overlaid, never wiped."),

    # --- input deinterlace and audio tracks (OBS 32 protocol) ---
    ("obs-get-input-audio-tracks", "GetInputAudioTracks",
     [("inputName", "str", False, "Name of the input."),
      ("inputUuid", "str", False, "UUID of the input (alternative to inputName).")], [],
     "Get the enabled state of all audio tracks of an input."),
    ("obs-set-input-audio-tracks", "SetInputAudioTracks",
     [("inputName", "str", False, "Name of the input."),
      ("inputUuid", "str", False, "UUID of the input (alternative to inputName)."),
      ("inputAudioTracks", "obj", True, "Object mapping track index to enabled state, e.g. { '1': true, '2': false }.")], [],
     "Set which audio tracks of an input are enabled."),
    ("obs-get-input-deinterlace-mode", "GetInputDeinterlaceMode",
     [("inputName", "str", False, "Name of the input."),
      ("inputUuid", "str", False, "UUID of the input (alternative to inputName).")], [],
     "Get the deinterlace mode of an input."),
    ("obs-set-input-deinterlace-mode", "SetInputDeinterlaceMode",
     [("inputName", "str", False, "Name of the input."),
      ("inputUuid", "str", False, "UUID of the input (alternative to inputName)."),
      ("inputDeinterlaceMode", "str", True, "Deinterlace mode, e.g. OBS_DEINTERLACE_MODE_DISABLE, BLEND, BOB, DISCARD.")], [],
     "Set the deinterlace mode of an input."),
    ("obs-get-input-deinterlace-field-order", "GetInputDeinterlaceFieldOrder",
     [("inputName", "str", False, "Name of the input."),
      ("inputUuid", "str", False, "UUID of the input (alternative to inputName).")], [],
     "Get the deinterlace field order of an input."),
    ("obs-set-input-deinterlace-field-order", "SetInputDeinterlaceFieldOrder",
     [("inputName", "str", False, "Name of the input."),
      ("inputUuid", "str", False, "UUID of the input (alternative to inputName)."),
      ("inputDeinterlaceFieldOrder", "str", True, "Field order, e.g. OBS_DEINTERLACE_FIELD_ORDER_TOP, BOTTOM.")], [],
     "Set the deinterlace field order of an input."),
    ("obs-get-input-properties-list-items", "GetInputPropertiesListPropertyItems",
     [("inputName", "str", False, "Name of the input."),
      ("inputUuid", "str", False, "UUID of the input (alternative to inputName)."),
      ("propertyName", "str", True, "Name of the list property to read.")], [],
     "Get the selectable items of a list property in an input's properties."),
    ("obs-press-input-properties-button", "PressInputPropertiesButton",
     [("inputName", "str", False, "Name of the input."),
      ("inputUuid", "str", False, "UUID of the input (alternative to inputName)."),
      ("propertyName", "str", True, "Name of the button property to press.")], [],
     "Press a button in the properties of an input."),

    # --- transition additions (OBS 32 protocol) ---
    ("obs-get-transition-kind-list", "GetTransitionKindList", [], [],
     "List all available transition kinds in OBS."),
    ("obs-get-current-transition-cursor", "GetCurrentSceneTransitionCursor", [], [],
     "Get the cursor position of the current scene transition while it is running."),
    ("obs-get-scene-transition-override", "GetSceneSceneTransitionOverride",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the scene."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName).")], [],
     "Get the transition overridden for a scene, if any."),
    ("obs-set-scene-transition-override", "SetSceneSceneTransitionOverride",
     [("canvasUuid", "str", False, "UUID of the canvas (alternative to sceneName/sceneUuid)."),
      ("sceneName", "str", False, "Name of the scene."),
      ("sceneUuid", "str", False, "UUID of the scene (alternative to sceneName)."),
      ("transitionName", "str", False, "Name of the transition to override with (omit to clear the override)."),
      ("transitionDuration", "num", False, "Duration of the override transition in milliseconds.")], [],
     "Set or clear the transition overridden for a scene."),
    ("obs-set-tbar-position", "SetTBarPosition",
     [("position", "num", True, "TBar position between 0.0 and 1.0."),
      ("release", "bool", False, "True to release the TBar after setting the position.")], [],
     "Set the position of the TBar (manual transition control)."),
]


def rust_kind(kind):
    if kind == "str":
        return "Str"
    if kind == "num":
        return "Num"
    if kind == "int":
        return "Int"
    if kind == "bool":
        return "Bool"
    if kind == "obj":
        return "Obj"
    if kind.startswith("enum:"):
        return "Enum(&[" + ", ".join(f'"{v}"' for v in kind[5:].split("|")) + "])"
    raise ValueError(kind)


def emit():
    lines = []
    lines.append("//! Generated tool table. Do not edit by hand; run")
    lines.append("//! `python3 scripts/gen_tools_table.py` to regenerate.")
    lines.append("//!")
    lines.append("//! The tool surface mirrors the public OBS WebSocket v5 protocol")
    lines.append("//! (https://github.com/obsproject/obs-websocket).")
    lines.append("")
    lines.append("use super::tools::{ParamKind, ToolDef};")
    lines.append("use super::tools::p;")
    lines.append("")
    lines.append("/// All registered OBS tools as a static table.")
    lines.append("pub fn all_tools() -> Vec<ToolDef> {")
    lines.append("    vec![")
    for name, req, params, renames, desc in TOOLS:
        lines.append(f'        ToolDef::new("{name}", "{desc}", "{req}")')
        if params:
            lines.append("            .with_params(vec![")
            for pname, pkind, preq, pdesc in params:
                lines.append(
                    f'                p("{pname}", ParamKind::{rust_kind(pkind)}, '
                    f'"{pdesc}", {"true" if preq else "false"}),'
                )
            lines.append("            ])")
        if renames:
            rs = ", ".join(f'("{a}", "{b}")' for a, b in renames)
            lines.append(f"            .with_renames(vec![{rs}])")
        lines.append("            ,")
    lines.append("    ]")
    lines.append("}")
    lines.append("")
    return "\n".join(lines)


def main():
    src = Path(__file__).resolve().parent.parent / "src" / "tools_table.rs"
    src.write_text(emit())
    print(f"wrote {src} with {len(TOOLS)} tools")


if __name__ == "__main__":
    main()