Repository navigation
Expand file tree
/
Copy pathpython_pipe_mcp_server.py
More file actions
983 lines (732 loc) · 32.3 KB
/
Copy pathpython_pipe_mcp_server.py
File metadata and controls
983 lines (732 loc) · 32.3 KB
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
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
from __future__ import annotations
from typing import Any
from mcp.server.fastmcp import FastMCP
from python_pipe_bridge import execute_command
mcp = FastMCP("synthv-pipe-bridge", json_response=True)
@mcp.tool()
def ping() -> Any:
"""Ping the Synth V Lua side and return current project/track/group summary."""
return execute_command("ping")
@mcp.tool()
def echo(message: str) -> Any:
"""Send a message to the Synth V Lua side and receive an echoed response plus project summary."""
return execute_command("echo", message=message)
@mcp.tool()
def get_host_info() -> Any:
"""Read host information for the current Synth V application instance."""
return execute_command("get_host_info")
@mcp.tool()
def get_host_clipboard() -> Any:
"""Read plain text from the host system clipboard."""
return execute_command("get_host_clipboard")
@mcp.tool()
def set_host_clipboard(text: str) -> Any:
"""Replace the host system clipboard text."""
return execute_command("set_host_clipboard", text=text)
@mcp.tool()
def show_message_box(title: str, message: str) -> Any:
"""Show a blocking message box inside Synth V."""
return execute_command("show_message_box", title=title, message=message)
@mcp.tool()
def show_input_box(title: str, message: str, default_text: str = "") -> Any:
"""Show a blocking text input box inside Synth V."""
return execute_command("show_input_box", title=title, message=message, defaultText=default_text)
@mcp.tool()
def show_ok_cancel_box(title: str, message: str) -> Any:
"""Show a blocking OK/Cancel box inside Synth V."""
return execute_command("show_ok_cancel_box", title=title, message=message)
@mcp.tool()
def show_yes_no_cancel_box(title: str, message: str) -> Any:
"""Show a blocking Yes/No/Cancel box inside Synth V."""
return execute_command("show_yes_no_cancel_box", title=title, message=message)
@mcp.tool()
def show_custom_dialog(form: dict[str, Any]) -> Any:
"""Show a blocking custom dialog inside Synth V using the official dialog form schema."""
return execute_command("show_custom_dialog", form=form)
@mcp.tool()
def show_info(message: str, title: str = "Synth V") -> Any:
"""Show a simple informational message box inside Synth V."""
return execute_command("show_message_box", title=title, message=message)
@mcp.tool()
def prompt_text(message: str, title: str = "Input", default_text: str = "") -> Any:
"""Prompt for a single line of text inside Synth V."""
return execute_command("show_input_box", title=title, message=message, defaultText=default_text)
@mcp.tool()
def confirm(message: str, title: str = "Confirm") -> Any:
"""Ask for an OK/Cancel confirmation inside Synth V."""
return execute_command("show_ok_cancel_box", title=title, message=message)
@mcp.tool()
def ask_yes_no_cancel(message: str, title: str = "Question") -> Any:
"""Ask a Yes/No/Cancel question inside Synth V."""
return execute_command("show_yes_no_cancel_box", title=title, message=message)
@mcp.tool()
def get_arrangement_selection() -> Any:
"""Read the current selection from the arrangement view."""
return execute_command("get_arrangement_selection")
@mcp.tool()
def get_arrangement_selection_state() -> Any:
"""Read summary booleans for the current arrangement selection state."""
return execute_command("get_arrangement_selection_state")
@mcp.tool()
def clear_arrangement_selection_all() -> Any:
"""Clear all current arrangement selections."""
return execute_command("clear_arrangement_selection_all")
@mcp.tool()
def clear_arrangement_selection_groups() -> Any:
"""Clear selected groups in the arrangement view."""
return execute_command("clear_arrangement_selection_groups")
@mcp.tool()
def select_arrangement_groups(groups: list[dict[str, int]]) -> Any:
"""Select arrangement groups by {trackIndex, index} pairs."""
return execute_command("select_arrangement_groups", groups=groups)
@mcp.tool()
def unselect_arrangement_groups(groups: list[dict[str, int]]) -> Any:
"""Unselect arrangement groups by {trackIndex, index} pairs."""
return execute_command("unselect_arrangement_groups", groups=groups)
@mcp.tool()
def list_note_groups_in_library() -> Any:
"""List note groups stored in the project library."""
return execute_command("list_note_groups_in_library")
@mcp.tool()
def get_note_group_in_library(index: int) -> Any:
"""Read one note group from the project library by 1-based index."""
return execute_command("get_note_group_in_library", index=index)
@mcp.tool()
def add_note_group_to_library(name: str | None = None) -> Any:
"""Create an empty note group and add it to the project library."""
payload: dict[str, Any] = {}
if name is not None:
payload["name"] = name
return execute_command("add_note_group_to_library", **payload)
@mcp.tool()
def clone_current_group_to_library(name: str | None = None) -> Any:
"""Clone the current piano-roll group into the project library."""
payload: dict[str, Any] = {}
if name is not None:
payload["name"] = name
return execute_command("clone_current_group_to_library", **payload)
@mcp.tool()
def remove_note_group_from_library(index: int) -> Any:
"""Remove one note group from the project library by 1-based index."""
return execute_command("remove_note_group_from_library", index=index)
@mcp.tool()
def set_note_group_name_in_library(index: int, name: str) -> Any:
"""Rename one note group in the project library."""
return execute_command("set_note_group_name_in_library", index=index, name=name)
@mcp.tool()
def set_current_group_name(name: str) -> Any:
"""Rename the current piano-roll note group."""
return execute_command("set_current_group_name", name=name)
@mcp.tool()
def add_track(name: str | None = None, display_color: str | None = None, bounced: bool | None = None) -> Any:
"""Create a new track in the current project."""
payload: dict[str, Any] = {}
if name is not None:
payload["name"] = name
if display_color is not None:
payload["displayColor"] = display_color
if bounced is not None:
payload["bounced"] = bounced
return execute_command("add_track", **payload)
@mcp.tool()
def remove_track(track_index: int | None = None) -> Any:
"""Remove one track from the current project."""
payload: dict[str, Any] = {}
if track_index is not None:
payload["trackIndex"] = track_index
return execute_command("remove_track", **payload)
@mcp.tool()
def get_group_reference(index: int, track_index: int | None = None) -> Any:
"""Read one group reference from a track by 1-based index."""
payload: dict[str, Any] = {"index": index}
if track_index is not None:
payload["trackIndex"] = track_index
return execute_command("get_group_reference", **payload)
@mcp.tool()
def add_group_reference(
target_group_index: int,
track_index: int | None = None,
onset: int | None = None,
duration: int | None = None,
time_offset: int | None = None,
pitch_offset: int | None = None,
muted: bool | None = None,
) -> Any:
"""Insert one library note-group reference into a track."""
payload: dict[str, Any] = {"targetGroupIndex": target_group_index}
if track_index is not None:
payload["trackIndex"] = track_index
if onset is not None:
payload["onset"] = onset
if duration is not None:
payload["duration"] = duration
if time_offset is not None:
payload["timeOffset"] = time_offset
if pitch_offset is not None:
payload["pitchOffset"] = pitch_offset
if muted is not None:
payload["muted"] = muted
return execute_command("add_group_reference", **payload)
@mcp.tool()
def set_group_reference(
index: int,
track_index: int | None = None,
onset: int | None = None,
duration: int | None = None,
time_offset: int | None = None,
pitch_offset: int | None = None,
muted: bool | None = None,
) -> Any:
"""Update one existing group reference on a track."""
payload: dict[str, Any] = {"index": index}
if track_index is not None:
payload["trackIndex"] = track_index
if onset is not None:
payload["onset"] = onset
if duration is not None:
payload["duration"] = duration
if time_offset is not None:
payload["timeOffset"] = time_offset
if pitch_offset is not None:
payload["pitchOffset"] = pitch_offset
if muted is not None:
payload["muted"] = muted
return execute_command("set_group_reference", **payload)
@mcp.tool()
def remove_group_reference(index: int, track_index: int | None = None) -> Any:
"""Remove one group reference from a track by 1-based index."""
payload: dict[str, Any] = {"index": index}
if track_index is not None:
payload["trackIndex"] = track_index
return execute_command("remove_group_reference", **payload)
@mcp.tool()
def get_project_overview() -> Any:
"""Read current project, track, current-group, and tempo summary."""
return execute_command("get_project_overview")
@mcp.tool()
def get_project_duration() -> Any:
"""Read the total project duration."""
return execute_command("get_project_duration")
@mcp.tool()
def list_tracks() -> Any:
"""List tracks in the current Synth V project."""
return execute_command("list_tracks")
@mcp.tool()
def get_track_info(track_index: int | None = None) -> Any:
"""Read basic track properties for one track."""
payload = {}
if track_index is not None:
payload["trackIndex"] = track_index
return execute_command("get_track_info", **payload)
@mcp.tool()
def get_track_mixer(track_index: int | None = None) -> Any:
"""Read volume, pan, mute, and solo state for a track."""
payload = {}
if track_index is not None:
payload["trackIndex"] = track_index
return execute_command("get_track_mixer", **payload)
@mcp.tool()
def set_track_mixer(track_index: int | None = None, gain_decibel: float | None = None, pan: float | None = None, muted: bool | None = None, solo: bool | None = None) -> Any:
"""Update volume, pan, mute, and solo state for a track."""
payload = {}
if track_index is not None:
payload["trackIndex"] = track_index
if gain_decibel is not None:
payload["gainDecibel"] = gain_decibel
if pan is not None:
payload["pan"] = pan
if muted is not None:
payload["muted"] = muted
if solo is not None:
payload["solo"] = solo
return execute_command("set_track_mixer", **payload)
@mcp.tool()
def set_track_name(name: str, track_index: int | None = None) -> Any:
"""Rename a track."""
payload = {"name": name}
if track_index is not None:
payload["trackIndex"] = track_index
return execute_command("set_track_name", **payload)
@mcp.tool()
def set_track_color(color: str, track_index: int | None = None) -> Any:
"""Set a track display color."""
payload = {"color": color}
if track_index is not None:
payload["trackIndex"] = track_index
return execute_command("set_track_color", **payload)
@mcp.tool()
def set_track_bounced(enabled: bool, track_index: int | None = None) -> Any:
"""Set the bounced state for a track."""
payload = {"enabled": enabled}
if track_index is not None:
payload["trackIndex"] = track_index
return execute_command("set_track_bounced", **payload)
@mcp.tool()
def get_track_notes(track_index: int | None = None) -> Any:
"""Read all group references and notes for a track."""
payload = {}
if track_index is not None:
payload["trackIndex"] = track_index
return execute_command("get_track_notes", **payload)
@mcp.tool()
def get_current_group() -> Any:
"""Read the current piano-roll group reference."""
return execute_command("get_current_group")
@mcp.tool()
def get_selection() -> Any:
"""Read the current selection from the piano roll."""
return execute_command("get_selection")
@mcp.tool()
def get_selection_state() -> Any:
"""Read summary booleans for the current piano-roll selection state."""
return execute_command("get_selection_state")
@mcp.tool()
def clear_selection_all() -> Any:
"""Clear all current piano-roll selections."""
return execute_command("clear_selection_all")
@mcp.tool()
def clear_selection_notes() -> Any:
"""Clear selected notes in the piano roll."""
return execute_command("clear_selection_notes")
@mcp.tool()
def clear_selection_groups() -> Any:
"""Clear selected groups in the piano roll."""
return execute_command("clear_selection_groups")
@mcp.tool()
def clear_selection_pitch_controls() -> Any:
"""Clear selected pitch controls in the piano roll."""
return execute_command("clear_selection_pitch_controls")
@mcp.tool()
def select_notes(indices: list[int]) -> Any:
"""Select notes in the current group by 1-based indexes."""
return execute_command("select_notes", indices=indices)
@mcp.tool()
def unselect_notes(indices: list[int]) -> Any:
"""Unselect notes in the current group by 1-based indexes."""
return execute_command("unselect_notes", indices=indices)
@mcp.tool()
def select_groups(indices: list[int], track_index: int | None = None) -> Any:
"""Select group references on a track by 1-based indexes."""
payload = {"indices": indices}
if track_index is not None:
payload["trackIndex"] = track_index
return execute_command("select_groups", **payload)
@mcp.tool()
def unselect_groups(indices: list[int], track_index: int | None = None) -> Any:
"""Unselect group references on a track by 1-based indexes."""
payload = {"indices": indices}
if track_index is not None:
payload["trackIndex"] = track_index
return execute_command("unselect_groups", **payload)
@mcp.tool()
def get_selected_pitch_controls() -> Any:
"""Read selected pitch controls from the piano roll."""
return execute_command("get_selected_pitch_controls")
@mcp.tool()
def get_selected_points(parameter_type: str) -> Any:
"""Read selected automation/pitch points for one parameter type."""
return execute_command("get_selected_points", parameterType=parameter_type)
@mcp.tool()
def select_points(parameter_type: str, positions: list[int]) -> Any:
"""Select automation/pitch points for one parameter type by blick positions."""
return execute_command("select_points", parameterType=parameter_type, positions=positions)
@mcp.tool()
def unselect_points(parameter_type: str, positions: list[int]) -> Any:
"""Unselect automation/pitch points for one parameter type by blick positions."""
return execute_command("unselect_points", parameterType=parameter_type, positions=positions)
@mcp.tool()
def list_pitch_controls() -> Any:
"""List all pitch controls in the current group."""
return execute_command("list_pitch_controls")
@mcp.tool()
def get_pitch_control(index: int) -> Any:
"""Read one pitch control by 1-based index from the current group."""
return execute_command("get_pitch_control", index=index)
@mcp.tool()
def get_pitch_control_value(index: int, time: float) -> Any:
"""Read the value of one pitch control curve at a given time."""
return execute_command("get_pitch_control_value", index=index, time=time)
@mcp.tool()
def add_pitch_control_point(position: float, pitch: float) -> Any:
"""Add one pitch control point to the current group."""
return execute_command("add_pitch_control_point", position=position, pitch=pitch)
@mcp.tool()
def add_pitch_control_curve(position: float, pitch: float, points: list[Any]) -> Any:
"""Add one pitch control curve to the current group."""
return execute_command("add_pitch_control_curve", position=position, pitch=pitch, points=points)
@mcp.tool()
def update_pitch_control_point(index: int, position: float | None = None, pitch: float | None = None) -> Any:
"""Update one pitch control point in the current group."""
payload = {"index": index}
if position is not None:
payload["position"] = position
if pitch is not None:
payload["pitch"] = pitch
return execute_command("update_pitch_control_point", **payload)
@mcp.tool()
def update_pitch_control_curve(index: int, position: float | None = None, pitch: float | None = None, points: list[Any] | None = None) -> Any:
"""Update one pitch control curve in the current group."""
payload = {"index": index}
if position is not None:
payload["position"] = position
if pitch is not None:
payload["pitch"] = pitch
if points is not None:
payload["points"] = points
return execute_command("update_pitch_control_curve", **payload)
@mcp.tool()
def delete_pitch_control(index: int) -> Any:
"""Delete one pitch control from the current group by 1-based index."""
return execute_command("delete_pitch_control", index=index)
@mcp.tool()
def delete_pitch_controls(indices: list[int]) -> Any:
"""Delete multiple pitch controls from the current group by 1-based indexes."""
return execute_command("delete_pitch_controls", indices=indices)
@mcp.tool()
def clear_pitch_controls() -> Any:
"""Delete all pitch controls from the current group."""
return execute_command("clear_pitch_controls")
@mcp.tool()
def list_notes() -> Any:
"""List notes in the current group open in the piano roll."""
return execute_command("list_notes")
@mcp.tool()
def get_note(index: int) -> Any:
"""Read one note from the current group by 1-based index."""
return execute_command("get_note", index=index)
@mcp.tool()
def get_note_attributes(index: int) -> Any:
"""Read advanced attributes for one note, including detune and retake-adjacent fields."""
return execute_command("get_note_attributes", index=index)
@mcp.tool()
def set_note_attributes(
index: int,
attributes: dict[str, Any] | None = None,
detune: float | None = None,
pitch_auto_mode: bool | None = None,
rap_accent: float | None = None,
) -> Any:
"""Update advanced attributes for one note."""
payload: dict[str, Any] = {"index": index}
if attributes is not None:
payload["attributes"] = attributes
if detune is not None:
payload["detune"] = detune
if pitch_auto_mode is not None:
payload["pitchAutoMode"] = pitch_auto_mode
if rap_accent is not None:
payload["rapAccent"] = rap_accent
return execute_command("set_note_attributes", **payload)
@mcp.tool()
def get_note_retakes(index: int) -> Any:
"""Read retake count metadata for one note."""
return execute_command("get_note_retakes", index=index)
@mcp.tool()
def generate_note_retake(index: int, new_duration: bool = False, new_pitch: bool = False, new_timbre: bool = False, activate: bool = False) -> Any:
"""Generate one retake for a note."""
return execute_command(
"generate_note_retake",
index=index,
newDuration=new_duration,
newPitch=new_pitch,
newTimbre=new_timbre,
activate=activate,
)
@mcp.tool()
def delete_note_retake(index: int, take_id: int) -> Any:
"""Delete one retake from a note."""
return execute_command("delete_note_retake", index=index, takeId=take_id)
@mcp.tool()
def set_note_active_retake(index: int, take_id: int) -> Any:
"""Set the active retake for a note."""
return execute_command("set_note_active_retake", index=index, takeId=take_id)
@mcp.tool()
def get_notes_in_range(begin_position: int, end_position: int) -> Any:
"""List notes in the current group that overlap the given blick range."""
return execute_command("get_notes_in_range", beginPosition=begin_position, endPosition=end_position)
@mcp.tool()
def clear_notes() -> Any:
"""Delete all notes in the current group."""
return execute_command("clear_notes")
@mcp.tool()
def delete_notes_in_range(begin_position: int, end_position: int) -> Any:
"""Delete notes in the current group that overlap the given blick range."""
return execute_command("delete_notes_in_range", beginPosition=begin_position, endPosition=end_position)
@mcp.tool()
def add_note(
onset: int,
duration: int,
pitch: int,
lyrics: str = "la",
phonemes: str | None = None,
note_type: str | None = None,
language_override: str | None = None,
detune: float | None = None,
pitch_auto_mode: bool | None = None,
rap_accent: float | None = None,
attributes: dict[str, Any] | None = None,
) -> Any:
"""Add a note to the current group."""
payload = {
"onset": onset,
"duration": duration,
"pitch": pitch,
"lyrics": lyrics,
"phonemes": phonemes,
"type": note_type,
"languageOverride": language_override,
"detune": detune,
"pitchAutoMode": pitch_auto_mode,
"rapAccent": rap_accent,
"attributes": attributes,
}
payload = {key: value for key, value in payload.items() if value is not None}
return execute_command("add_note", **payload)
@mcp.tool()
def add_notes(notes: list[dict[str, Any]]) -> Any:
"""Add multiple notes to the current group."""
return execute_command("add_notes", notes=notes)
@mcp.tool()
def update_note(
index: int,
onset: int | None = None,
duration: int | None = None,
pitch: int | None = None,
lyrics: str | None = None,
phonemes: str | None = None,
note_type: str | None = None,
language_override: str | None = None,
detune: float | None = None,
pitch_auto_mode: bool | None = None,
rap_accent: float | None = None,
attributes: dict[str, Any] | None = None,
) -> Any:
"""Update a note in the current group by 1-based index."""
payload = {
"index": index,
"onset": onset,
"duration": duration,
"pitch": pitch,
"lyrics": lyrics,
"phonemes": phonemes,
"type": note_type,
"languageOverride": language_override,
"detune": detune,
"pitchAutoMode": pitch_auto_mode,
"rapAccent": rap_accent,
"attributes": attributes,
}
payload = {key: value for key, value in payload.items() if value is not None}
return execute_command("update_note", **payload)
@mcp.tool()
def update_notes(updates: list[dict[str, Any]]) -> Any:
"""Update multiple notes in the current group."""
return execute_command("update_notes", updates=updates)
@mcp.tool()
def delete_note(index: int) -> Any:
"""Delete a note from the current group by 1-based index."""
return execute_command("delete_note", index=index)
@mcp.tool()
def delete_notes(indices: list[int]) -> Any:
"""Delete multiple notes from the current group by 1-based indexes."""
return execute_command("delete_notes", indices=indices)
@mcp.tool()
def list_tempo_marks() -> Any:
"""List tempo marks in the current project."""
return execute_command("list_tempo_marks")
@mcp.tool()
def get_tempo_at(position: int = 0) -> Any:
"""Read the effective tempo at a blick position."""
return execute_command("get_tempo_at", position=position)
@mcp.tool()
def set_tempo_mark(position: int, bpm: float) -> Any:
"""Add or overwrite a tempo mark at a blick position."""
return execute_command("set_tempo_mark", position=position, bpm=bpm)
@mcp.tool()
def remove_tempo_mark(position: int) -> Any:
"""Remove a tempo mark at a blick position."""
return execute_command("remove_tempo_mark", position=position)
@mcp.tool()
def get_current_group_voice() -> Any:
"""Read voice parameters from the current group reference."""
return execute_command("get_current_group_voice")
@mcp.tool()
def seconds_to_blick(seconds: float, bpm: float) -> Any:
"""Convert seconds to blick using a BPM value."""
return execute_command("seconds_to_blick", seconds=seconds, bpm=bpm)
@mcp.tool()
def blick_to_seconds(blick: float, bpm: float) -> Any:
"""Convert blick to seconds using a BPM value."""
return execute_command("blick_to_seconds", blick=blick, bpm=bpm)
@mcp.tool()
def quarter_to_blick(quarter: float) -> Any:
"""Convert quarter-note units to blick."""
return execute_command("quarter_to_blick", quarter=quarter)
@mcp.tool()
def blick_to_quarter(blick: float) -> Any:
"""Convert blick to quarter-note units."""
return execute_command("blick_to_quarter", blick=blick)
@mcp.tool()
def pitch_to_freq(pitch: float) -> Any:
"""Convert pitch to frequency."""
return execute_command("pitch_to_freq", pitch=pitch)
@mcp.tool()
def freq_to_pitch(frequency: float) -> Any:
"""Convert frequency to pitch."""
return execute_command("freq_to_pitch", frequency=frequency)
@mcp.tool()
def black_key(pitch: int) -> Any:
"""Check whether a pitch is a black key."""
return execute_command("black_key", pitch=pitch)
@mcp.tool()
def get_group_parameter(parameter_type: str) -> Any:
"""Read an automation parameter object from the current group."""
return execute_command("get_group_parameter", parameterType=parameter_type)
@mcp.tool()
def get_parameter_points(parameter_type: str, begin_position: float | None = None, end_position: float | None = None) -> Any:
"""Read automation points for a parameter in the current group."""
payload = {"parameterType": parameter_type}
if begin_position is not None and end_position is not None:
payload["beginPosition"] = begin_position
payload["endPosition"] = end_position
return execute_command("get_parameter_points", **payload)
@mcp.tool()
def get_parameter_value(parameter_type: str, position: float, linear: bool = False) -> Any:
"""Read an automation value at a given position."""
return execute_command("get_parameter_value", parameterType=parameter_type, position=position, linear=linear)
@mcp.tool()
def add_parameter_point(parameter_type: str, position: float, value: float) -> Any:
"""Add an automation point to the current group."""
return execute_command("add_parameter_point", parameterType=parameter_type, position=position, value=value)
@mcp.tool()
def remove_parameter_point(parameter_type: str, position: float, end_position: float | None = None) -> Any:
"""Remove one automation point or a range of automation points."""
payload = {"parameterType": parameter_type, "position": position}
if end_position is not None:
payload["endPosition"] = end_position
return execute_command("remove_parameter_point", **payload)
@mcp.tool()
def clear_parameter_points(parameter_type: str) -> Any:
"""Remove all automation points for one parameter in the current group."""
return execute_command("clear_parameter_points", parameterType=parameter_type)
@mcp.tool()
def simplify_parameter_points(parameter_type: str, begin_position: float, end_position: float, threshold: float | None = None) -> Any:
"""Simplify automation points for a parameter in the current group."""
payload = {
"parameterType": parameter_type,
"beginPosition": begin_position,
"endPosition": end_position,
}
if threshold is not None:
payload["threshold"] = threshold
return execute_command("simplify_parameter_points", **payload)
@mcp.tool()
def set_current_group_voice(loudness: float | None = None, tension: float | None = None, breathiness: float | None = None, gender: float | None = None, tone_shift: float | None = None) -> Any:
"""Update voice parameters on the current group reference."""
payload = {
"paramLoudness": loudness,
"paramTension": tension,
"paramBreathiness": breathiness,
"paramGender": gender,
"paramToneShift": tone_shift,
}
payload = {key: value for key, value in payload.items() if value is not None}
return execute_command("set_current_group_voice", **payload)
@mcp.tool()
def transpose_selected_notes(semitones: int) -> Any:
"""Transpose currently selected notes by a number of semitones."""
return execute_command("transpose_selected_notes", semitones=semitones)
@mcp.tool()
def set_selected_lyrics(lyrics: str) -> Any:
"""Replace the lyrics of all currently selected notes."""
return execute_command("set_selected_lyrics", lyrics=lyrics)
@mcp.tool()
def set_selected_phonemes(phonemes: str) -> Any:
"""Replace the phonemes of all currently selected notes."""
return execute_command("set_selected_phonemes", phonemes=phonemes)
@mcp.tool()
def set_selected_language_override(language_override: str) -> Any:
"""Set the language override of all currently selected notes."""
return execute_command("set_selected_language_override", languageOverride=language_override)
@mcp.tool()
def move_selected_notes(offset: int) -> Any:
"""Move currently selected notes by a blick offset."""
return execute_command("move_selected_notes", offset=offset)
@mcp.tool()
def duplicate_selected_notes(offset: int, pitch_offset: int = 0) -> Any:
"""Duplicate currently selected notes with an onset and optional pitch offset."""
return execute_command("duplicate_selected_notes", offset=offset, pitchOffset=pitch_offset)
@mcp.tool()
def transpose_notes_by_indices(indices: list[int], semitones: int) -> Any:
"""Transpose notes in the current group by 1-based indexes."""
return execute_command("transpose_notes_by_indices", indices=indices, semitones=semitones)
@mcp.tool()
def set_notes_lyrics(indices: list[int], lyrics: str) -> Any:
"""Replace the lyrics of notes in the current group by 1-based indexes."""
return execute_command("set_notes_lyrics", indices=indices, lyrics=lyrics)
@mcp.tool()
def set_notes_phonemes(indices: list[int], phonemes: str) -> Any:
"""Replace the phonemes of notes in the current group by 1-based indexes."""
return execute_command("set_notes_phonemes", indices=indices, phonemes=phonemes)
@mcp.tool()
def set_notes_language_override(indices: list[int], language_override: str) -> Any:
"""Set the language override of notes in the current group by 1-based indexes."""
return execute_command("set_notes_language_override", indices=indices, languageOverride=language_override)
@mcp.tool()
def get_script_data(target: str, key: str, track_index: int | None = None, index: int | None = None) -> Any:
"""Read script-private metadata from a project, track, mixer, group, groupRef, note, or timeAxis object."""
payload = {"target": target, "key": key}
if track_index is not None:
payload["trackIndex"] = track_index
if index is not None:
payload["index"] = index
return execute_command("get_script_data", **payload)
@mcp.tool()
def set_script_data(target: str, key: str, value: Any, track_index: int | None = None, index: int | None = None) -> Any:
"""Write script-private metadata to a project, track, mixer, group, groupRef, note, or timeAxis object."""
payload = {"target": target, "key": key, "value": value}
if track_index is not None:
payload["trackIndex"] = track_index
if index is not None:
payload["index"] = index
return execute_command("set_script_data", **payload)
@mcp.tool()
def has_script_data(target: str, key: str, track_index: int | None = None, index: int | None = None) -> Any:
"""Check whether a script-private metadata key exists on a target object."""
payload = {"target": target, "key": key}
if track_index is not None:
payload["trackIndex"] = track_index
if index is not None:
payload["index"] = index
return execute_command("has_script_data", **payload)
@mcp.tool()
def get_script_data_keys(target: str, track_index: int | None = None, index: int | None = None) -> Any:
"""List all script-private metadata keys on a target object."""
payload = {"target": target}
if track_index is not None:
payload["trackIndex"] = track_index
if index is not None:
payload["index"] = index
return execute_command("get_script_data_keys", **payload)
@mcp.tool()
def remove_script_data(target: str, key: str, track_index: int | None = None, index: int | None = None) -> Any:
"""Remove one script-private metadata key from a target object."""
payload = {"target": target, "key": key}
if track_index is not None:
payload["trackIndex"] = track_index
if index is not None:
payload["index"] = index
return execute_command("remove_script_data", **payload)
@mcp.tool()
def clear_script_data(target: str, track_index: int | None = None, index: int | None = None) -> Any:
"""Clear all script-private metadata from a target object."""
payload = {"target": target}
if track_index is not None:
payload["trackIndex"] = track_index
if index is not None:
payload["index"] = index
return execute_command("clear_script_data", **payload)
def main() -> None:
mcp.run(transport="stdio")
if __name__ == "__main__":
main()