run_js
Evaluate JavaScript code within FMOD Studio's scripting terminal to control audio import, event creation, and bank building. Use return to output results.
Instructions
Evaluate arbitrary JavaScript in the Studio scripting terminal.
Your snippet is wrapped in an IIFE, so use return to surface a value.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes |
Implementation Reference
- fmod_mcp/server.py:199-205 (registration)MCP tool registration for 'run_js' — the @mcp.tool() decorator registers it as an MCP tool. The handler delegates to escape.run_js().
@mcp.tool() async def run_js(code: str) -> Any: """Evaluate arbitrary JavaScript in the Studio scripting terminal. Your snippet is wrapped in an IIFE, so use `return` to surface a value. """ return await escape.run_js(_studio(), code) - fmod_mcp/tools/escape.py:9-15 (handler)Core handler implementation — async function that evaluates arbitrary JavaScript via client.eval(code).
async def run_js(client: StudioClient, code: str) -> Any: """Evaluate a raw JavaScript snippet. The snippet must use ``return`` to surface its value — it is wrapped in an IIFE before being sent to Studio. """ return await client.eval(code) - tests/test_server_registration.py:31-33 (registration)Test expectation confirming 'run_js' is registered as a tool.
# escape "run_js", } - tests/test_tools.py:190-197 (helper)Unit test for run_js — verifies the code string is passed through to the client and the result is returned.
async def test_run_js_passes_code_through( client: StudioClient, mock_studio: MockStudio ): mock_studio.responder = responder_sequence([("OK", 99)]) result = await escape.run_js(client, "return 99;") assert result == 99 assert "return 99;" in _last_sent_js(mock_studio)