Skip to main content
Glama

execute_lua

Run Lua code to control REAPER DAW through its ReaScript API, enabling automation and custom functionality within the digital audio workstation.

Instructions

Execute arbitrary Lua code in REAPER.

This gives full control over REAPER via ReaScript.
The code runs in REAPER's Lua environment with access to the reaper.* API.

Args:
    code: Lua code to execute

Example:
    execute_lua("reaper.ShowMessageBox('Hello from MCP!', 'Test', 0)")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'execute_lua'. Decorated with @mcp.tool() for automatic registration. Delegates execution to ReaperBridge instance.
    @mcp.tool()
    def execute_lua(ctx: Context, code: str) -> str:
        """
        Execute arbitrary Lua code in REAPER.
        
        This gives full control over REAPER via ReaScript.
        The code runs in REAPER's Lua environment with access to the reaper.* API.
        
        Args:
            code: Lua code to execute
        
        Example:
            execute_lua("reaper.ShowMessageBox('Hello from MCP!', 'Test', 0)")
        """
        bridge = get_bridge()
        result = bridge.execute_lua(code)
        return result.get("message", "Lua code executed")
  • Core implementation of Lua execution via file-based command to REAPER's Lua script. Writes command to JSON file and polls for response.
    def execute_lua(self, code: str) -> Dict[str, Any]:
        """Execute arbitrary Lua code in REAPER."""
        self._write_command("execute_lua", {"code": code})
        
        response = self._read_response(timeout=5.0)
        if response:
            return response
        return {"success": True, "message": "Lua code sent for execution"}
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the code runs in REAPER's Lua environment with access to the reaper.* API, which is useful behavioral context. However, it doesn't mention potential risks (e.g., destructive operations, performance impacts), error handling, or output format, leaving gaps in transparency for a powerful execution tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded: the first sentence states the core purpose, followed by essential context about the environment and API access. The Args and Example sections are structured efficiently, with every sentence adding value without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (executing arbitrary code), no annotations, and an output schema present, the description is reasonably complete. It covers the purpose, environment, and parameter semantics with an example. However, it lacks details on safety considerations or output interpretation, which could be beneficial despite the output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaningful semantics by explaining that the 'code' parameter is 'Lua code to execute' and provides an example showing usage with the reaper.* API. This goes beyond the schema's basic type information, though it could elaborate more on code constraints or expected patterns.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verb ('Execute') and resource ('arbitrary Lua code in REAPER'), distinguishing it from sibling tools that perform specific REAPER operations like 'set_tempo' or 'create_track'. It explicitly mentions this gives 'full control over REAPER via ReaScript', establishing its unique capability among the available tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use this tool: for executing Lua code with access to REAPER's API. It doesn't explicitly state when not to use it or name alternatives, but the context is sufficiently clear given that sibling tools are specific operations, making this the tool for custom scripting.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yura9011/scythe_mcp_reaper'

If you have feedback or need assistance with the MCP directory API, please join our Discord server