We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/nagarjun226/sushi-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
example_usage.py•3.43 KiB
#!/usr/bin/env python3
"""
Example script demonstrating basic Sushi MCP server usage.
This shows how to interact with Sushi programmatically using the gRPC interface.
"""
import grpc
import sushi_rpc_pb2
import sushi_rpc_pb2_grpc
def main():
# Connect to Sushi
channel = grpc.insecure_channel('localhost:51051')
# Create stubs for different controllers
system_controller = sushi_rpc_pb2_grpc.SystemControllerStub(channel)
transport_controller = sushi_rpc_pb2_grpc.TransportControllerStub(channel)
audio_graph_controller = sushi_rpc_pb2_grpc.AudioGraphControllerStub(channel)
parameter_controller = sushi_rpc_pb2_grpc.ParameterControllerStub(channel)
try:
# Get Sushi version
version = system_controller.GetSushiVersion(sushi_rpc_pb2.GenericVoidValue())
print(f"Connected to Sushi version: {version.value}")
# Get current tempo
tempo = transport_controller.GetTempo(sushi_rpc_pb2.GenericVoidValue())
print(f"Current tempo: {tempo.value} BPM")
# Get all tracks
tracks = audio_graph_controller.GetAllTracks(sushi_rpc_pb2.GenericVoidValue())
print(f"\nFound {len(tracks.tracks)} tracks:")
for track in tracks.tracks:
print(f" - Track {track.id}: {track.name} ({track.channels} channels)")
# Get processors on this track
processors = audio_graph_controller.GetTrackProcessors(
sushi_rpc_pb2.TrackIdentifier(id=track.id)
)
for processor in processors.processors:
# Get processor info
proc_info = audio_graph_controller.GetProcessorInfo(
sushi_rpc_pb2.ProcessorIdentifier(id=processor.id)
)
print(f" * Processor {processor.id}: {proc_info.name}")
# Get first few parameters
params = parameter_controller.GetProcessorParameters(
sushi_rpc_pb2.ProcessorIdentifier(id=processor.id)
)
for i, param in enumerate(params.parameters[:3]): # Show first 3 params
# Get current value
value = parameter_controller.GetParameterValue(
sushi_rpc_pb2.ParameterIdentifier(
processor_id=processor.id,
parameter_id=param.id
)
)
print(f" - {param.name}: {value.value} (range: {param.min_domain_value} to {param.max_domain_value})")
if len(params.parameters) > 3:
print(f" ... and {len(params.parameters) - 3} more parameters")
# Example: Set tempo to 120 BPM
print("\nSetting tempo to 120 BPM...")
transport_controller.SetTempo(sushi_rpc_pb2.GenericFloatValue(value=120.0))
# Example: Start playback
print("Starting playback...")
transport_controller.SetPlayingMode(
sushi_rpc_pb2.PlayingMode(mode=sushi_rpc_pb2.PlayingMode.Mode.PLAYING)
)
print("\nExample completed successfully!")
except grpc.RpcError as e:
print(f"Error connecting to Sushi: {e}")
print("Make sure Sushi is running with gRPC enabled on localhost:51051")
finally:
channel.close()
if __name__ == "__main__":
main()