assign_to_bus
Route an event's master track output to a specific mixer bus by providing the event path and bus path.
Instructions
Route the event's master track output to a mixer bus.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| event_path | Yes | ||
| bus_path | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- fmod_mcp/tools/events.py:159-172 (handler)Core implementation of the assign_to_bus tool. Uses studio.project.lookup() to find the event and bus by path, then sets evt.masterTrack.mixerGroup.output = bus to route the event's master track output to the specified mixer bus.
async def assign_to_bus( client: StudioClient, event_path: str, bus_path: str, ) -> dict[str, Any]: js = f""" var evt = studio.project.lookup({json.dumps(event_path)}); if (!evt) throw new Error("Event not found: " + {json.dumps(event_path)}); var bus = studio.project.lookup({json.dumps(bus_path)}); if (!bus) throw new Error("Bus not found: " + {json.dumps(bus_path)}); evt.masterTrack.mixerGroup.output = bus; return {{ path: evt.getPath(), bus: bus.getPath() }}; """ return await client.eval(js) - fmod_mcp/server.py:126-129 (registration)Server-side registration of the assign_to_bus tool via the @mcp.tool() decorator. Wraps the core handler from events module, accepting event_path and bus_path strings, and returns a dict.
@mcp.tool() async def assign_to_bus(event_path: str, bus_path: str) -> dict[str, Any]: """Route the event's master track output to a mixer bus.""" return await events.assign_to_bus(_studio(), event_path, bus_path) - fmod_mcp/tools/events.py:159-172 (schema)The function signature defines the schema: event_path (str) and bus_path (str) as inputs, returning a dict with 'path' and 'bus' keys.
async def assign_to_bus( client: StudioClient, event_path: str, bus_path: str, ) -> dict[str, Any]: js = f""" var evt = studio.project.lookup({json.dumps(event_path)}); if (!evt) throw new Error("Event not found: " + {json.dumps(event_path)}); var bus = studio.project.lookup({json.dumps(bus_path)}); if (!bus) throw new Error("Bus not found: " + {json.dumps(bus_path)}); evt.masterTrack.mixerGroup.output = bus; return {{ path: evt.getPath(), bus: bus.getPath() }}; """ return await client.eval(js) - tests/test_server_registration.py:19-42 (registration)Test registration: 'assign_to_bus' is listed in the EXPECTED_TOOLS set to verify it is properly registered on the server.
"assign_to_bus", # effects "list_effect_types", "add_effect", "list_effects", "get_effect", "set_effect_param", "remove_effect", "bypass_effect", # project "save_project", "build_banks", # escape "run_js", } def test_all_tools_registered(): tools = set(mcp._tool_manager._tools.keys()) missing = EXPECTED_TOOLS - tools extra = tools - EXPECTED_TOOLS assert not missing, f"Missing tools: {missing}" assert not extra, f"Unexpected extra tools: {extra}" - tests/test_tools.py:167-174 (helper)Test for the assign_to_bus tool, verifying that the JavaScript sent includes 'masterTrack.mixerGroup.output'.
async def test_assign_to_bus( client: StudioClient, mock_studio: MockStudio ): mock_studio.responder = responder_sequence([("OK", {"path": "event:/a", "bus": "bus:/SFX"})]) await events.assign_to_bus(client, "event:/a", "bus:/SFX") js = _last_sent_js(mock_studio) assert "masterTrack.mixerGroup.output" in js