Skip to main content
Glama

render_time_selection

Render a specified time range of a REAPER project to an audio file with configurable format, sample rate, bit depth, and channels.

Instructions

Render a specific time range of the project to a file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
output_pathYes
startYes
endYes
formatNowav
sample_rateNo
bit_depthNo
channelsNo

Implementation Reference

  • The `render_time_selection` function - the actual tool logic that sets time selection, configures render settings with bounds=1, and invokes REAPER's render command.
    @mcp.tool()
    def render_time_selection(
        output_path: str,
        start: float,
        end: float,
        format: str = "wav",
        sample_rate: int = 48000,
        bit_depth: int = 24,
        channels: int = 2,
    ) -> dict:
        """Render a specific time range of the project to a file."""
        try:
            output_path = str(Path(output_path).expanduser().resolve())
            os.makedirs(os.path.dirname(output_path), exist_ok=True)
            project = get_project()
            project.time_selection = (start, end)
            _set_render_settings(output_path, format, sample_rate, bit_depth, channels, bounds=1)
            RPR.Main_OnCommand(41824, 0)
            if not os.path.exists(output_path):
                return {"success": False, "error": "Render completed but output file not found"}
            return {
                "success": True,
                "output_path": output_path,
                "start": start,
                "end": end,
                "format": format,
                "file_size_bytes": os.path.getsize(output_path),
            }
        except Exception as e:
            return {"success": False, "error": str(e)}
  • The function signature/type annotations serve as the schema: accepts output_path (str), start (float), end (float), format (str default 'wav'), sample_rate (int), bit_depth (int), channels (int), returns dict.
    @mcp.tool()
    def render_time_selection(
        output_path: str,
        start: float,
        end: float,
        format: str = "wav",
        sample_rate: int = 48000,
        bit_depth: int = 24,
        channels: int = 2,
    ) -> dict:
        """Render a specific time range of the project to a file."""
        try:
            output_path = str(Path(output_path).expanduser().resolve())
            os.makedirs(os.path.dirname(output_path), exist_ok=True)
            project = get_project()
            project.time_selection = (start, end)
            _set_render_settings(output_path, format, sample_rate, bit_depth, channels, bounds=1)
            RPR.Main_OnCommand(41824, 0)
            if not os.path.exists(output_path):
                return {"success": False, "error": "Render completed but output file not found"}
            return {
                "success": True,
                "output_path": output_path,
                "start": start,
                "end": end,
                "format": format,
                "file_size_bytes": os.path.getsize(output_path),
            }
        except Exception as e:
            return {"success": False, "error": str(e)}
  • The tool is registered via the `@mcp.tool()` decorator inside `register_tools(mcp)` which is called from server.py line 26.
    def register_tools(mcp):
    
        @mcp.tool()
        def render_project(
            output_path: str,
            format: str = "wav",
            sample_rate: int = 48000,
            bit_depth: int = 24,
            channels: int = 2,
        ) -> dict:
            """
            Render the entire project to a file.
            format: wav, flac, mp3 (requires LAME), ogg.
            sample_rate: e.g. 44100, 48000, 96000.
            bit_depth: 16, 24, or 32 (WAV only; ignored for mp3/ogg/flac).
            channels: 1 (mono) or 2 (stereo).
            """
            try:
                output_path = str(Path(output_path).expanduser().resolve())
                os.makedirs(os.path.dirname(output_path), exist_ok=True)
                _set_render_settings(output_path, format, sample_rate, bit_depth, channels, bounds=0)
                RPR.Main_OnCommand(41824, 0)  # File: Render project to disk (no dialog)
                if not os.path.exists(output_path):
                    return {"success": False, "error": "Render command completed but output file not found"}
                return {
                    "success": True,
                    "output_path": output_path,
                    "format": format,
                    "sample_rate": sample_rate,
                    "bit_depth": bit_depth,
                    "channels": channels,
                    "file_size_bytes": os.path.getsize(output_path),
                }
            except Exception as e:
                logger.error(f"render_project failed: {e}")
                return {"success": False, "error": str(e)}
    
        @mcp.tool()
        def render_time_selection(
            output_path: str,
            start: float,
            end: float,
            format: str = "wav",
            sample_rate: int = 48000,
            bit_depth: int = 24,
            channels: int = 2,
        ) -> dict:
            """Render a specific time range of the project to a file."""
            try:
                output_path = str(Path(output_path).expanduser().resolve())
                os.makedirs(os.path.dirname(output_path), exist_ok=True)
                project = get_project()
                project.time_selection = (start, end)
                _set_render_settings(output_path, format, sample_rate, bit_depth, channels, bounds=1)
                RPR.Main_OnCommand(41824, 0)
                if not os.path.exists(output_path):
                    return {"success": False, "error": "Render completed but output file not found"}
                return {
                    "success": True,
                    "output_path": output_path,
                    "start": start,
                    "end": end,
                    "format": format,
                    "file_size_bytes": os.path.getsize(output_path),
                }
            except Exception as e:
                return {"success": False, "error": str(e)}
  • The `_set_render_settings` helper configures REAPER's render parameters (output path, format, sample rate, bit depth, channels, bounds flag) via the REAPER API.
    def _set_render_settings(
        output_path: str,
        format: str,
        sample_rate: int,
        bit_depth: int,
        channels: int,
        bounds: int,
    ) -> None:
        """Configure REAPER's render settings. bounds: 0=entire project, 1=time selection."""
        fmt_code = FORMAT_CODES.get(format.lower(), 0)
        bdepth_code = BIT_DEPTH_CODES.get(bit_depth, 2)
        RPR.GetSetProjectInfo_String(0, "RENDER_FILE", output_path, True)
        RPR.GetSetProjectInfo(0, "RENDER_FORMAT", fmt_code, True)
        RPR.GetSetProjectInfo(0, "RENDER_FORMAT2", bdepth_code, True)
        RPR.GetSetProjectInfo(0, "RENDER_SRATE", float(sample_rate), True)
        RPR.GetSetProjectInfo(0, "RENDER_CHANNELS", float(channels), True)
        RPR.GetSetProjectInfo(0, "RENDER_BOUNDSFLAG", float(bounds), True)
  • The `get_project()` helper returns the current REAPER project object via reapy, used to set the time selection on the project.
    def get_project() -> reapy.Project:
        ensure_connected()
        return reapy.Project()
Behavior3/5

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

No annotations are provided, so the description carries full burden. It indicates a write operation (rendering to file) but lacks details on file overwriting behavior, required permissions, or side effects. It is adequate but not thorough.

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

Conciseness3/5

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

The description is a single concise sentence, but it sacrifices necessary detail for brevity. It could be more informative without being overly verbose.

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

Completeness2/5

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

Given no output schema, no annotations, and 7 parameters with 0% coverage, the description is insufficient. It does not explain return values, file formation, or that render uses project settings. For a tool with this complexity, more context is needed.

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

Parameters1/5

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

With 0% schema description coverage, the description fails to add meaning to any of the 7 parameters. It only vaguely implies 'time range' but does not explain format, sample_rate, bit_depth, channels, or output_path meaning.

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 action 'render' and the resource 'specific time range of the project' with output 'to a file'. It effectively distinguishes from sibling tools like 'render_project' (full project) and 'render_stems'.

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

Usage Guidelines3/5

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

The description implies usage for partial renders but provides no explicit guidance on when to use this tool versus alternatives like 'render_project' or 'render_stems'. No exclusions or prerequisites are mentioned.

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/bonfire-audio/reaper-mcp'

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