Skip to main content
Glama

analyze_frequency_spectrum

Render a REAPER project and obtain RMS levels in dB for seven frequency bands: sub-bass (20–60Hz), bass (60–250Hz), low mids, mids, high mids, presence, and brilliance (8–20kHz).

Instructions

Render the project and analyze frequency band levels. Returns RMS level in dB for seven bands: sub_bass (20–60Hz), bass (60–250Hz), low_mids (250–500Hz), mids (500–2kHz), high_mids (2–4kHz), presence (4–8kHz), brilliance (8–20kHz).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'analyze_frequency_spectrum' tool. It renders the project to a temp WAV, uses librosa to compute STFT, splits the spectrum into 7 frequency bands (sub_bass, bass, low_mids, mids, high_mids, presence, brilliance), and returns RMS levels in dB for each band using the helper _band_rms_db.
    @mcp.tool()
    def analyze_frequency_spectrum() -> dict:
        """
        Render the project and analyze frequency band levels.
        Returns RMS level in dB for seven bands:
        sub_bass (20–60Hz), bass (60–250Hz), low_mids (250–500Hz),
        mids (500–2kHz), high_mids (2–4kHz), presence (4–8kHz), brilliance (8–20kHz).
        """
        try:
            import librosa
            import soundfile as sf
            from reaper_mcp.render_tools import render_to_temp_file
    
            tmp = render_to_temp_file()
            try:
                y, sr = librosa.load(tmp, sr=None, mono=True)
            finally:
                if os.path.exists(tmp):
                    os.unlink(tmp)
    
            D = np.abs(librosa.stft(y))
            freqs = librosa.fft_frequencies(sr=sr)
    
            bands = {
                "sub_bass":   (20,   60),
                "bass":       (60,   250),
                "low_mids":   (250,  500),
                "mids":       (500,  2000),
                "high_mids":  (2000, 4000),
                "presence":   (4000, 8000),
                "brilliance": (8000, min(20000, sr // 2)),
            }
    
            results = {
                name: {
                    "range_hz": f"{lo}–{hi}",
                    "level_db": round(_band_rms_db(D, freqs, lo, hi), 1),
                }
                for name, (lo, hi) in bands.items()
            }
    
            return {"success": True, "frequency_bands": results}
        except Exception as e:
            logger.error(f"analyze_frequency_spectrum failed: {e}")
            return {"success": False, "error": str(e)}
  • Helper function _band_rms_db that computes the RMS level in dB for a specific frequency range from an STFT magnitude matrix D and its corresponding frequency array.
    def _band_rms_db(D: np.ndarray, freqs: np.ndarray, lo: float, hi: float) -> float:
        mask = (freqs >= lo) & (freqs <= hi)
        if not mask.any():
            return -120.0
        power = float(np.mean(D[mask, :] ** 2))
        return float(10 * np.log10(power + 1e-12))
  • The 'register_tools' function entry point which is called from server.py. Inside it, the @mcp.tool() decorator on line 23 registers 'analyze_frequency_spectrum' as an MCP tool.
    def register_tools(mcp):
  • Import of the register_tools function from analysis_tools module into the server.
    from reaper_mcp.analysis_tools import register_tools as _reg_analysis
  • Invocation of _reg_analysis(mcp) which triggers all tool registrations in analysis_tools.py, including analyze_frequency_spectrum.
    _reg_analysis(mcp)
Behavior3/5

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

The description mentions that the tool renders the project, which is a side effect, but does not elaborate on its impact (e.g., time cost, file changes). No annotations exist to compensate. It also does not state whether a project must be loaded or audio present.

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 extremely concise: two sentences that front-load the action and then enumerate the output details. Every sentence earns its place with no redundancy.

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

Completeness3/5

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

Given no parameters, no output schema, and no annotations, the description explains the core functionality and return value. However, it lacks mentions of prerequisites (e.g., open project) and side effects of rendering, leaving some gaps for an agent to infer.

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?

With zero parameters, the schema provides no information, so the description must add value. It does so by explaining the output bands and their frequency ranges, which is beyond the schema's empty definition. Baseline for no params is 4, met here.

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 action ('Render the project and analyze frequency band levels') and specifies the exact output (RMS level in dB for seven defined bands). It distinguishes this tool from sibling analysis tools like analyze_dynamics or analyze_loudness by its focus on frequency spectrum.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives, nor are there any prerequisites or conditions mentioned. The description only explains what the tool does, not the context for its use.

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