Skip to main content
Glama

Generate music

text_to_music

Generate music from a text prompt and save the resulting audio files locally; tracks are licensed for commercial social, brand, and advertising use.

Instructions

Generate music from a text prompt and save the resulting audio file(s) to a local directory. Generated tracks are fully licensed (music licensed via Shutterstock) and cleared for commercial use on social, brand content, and advertising.

⚠️ COST WARNING: This tool makes an API call to Sonilo which may incur charges. Only use when explicitly requested by the user.

Args: prompt (str): Description of the music to generate (1–1000 chars). duration (int, optional): Length in seconds (5–360). Omit it and Sonilo picks a length that suits the prompt. output_format (str, optional): 'm4a' (default), 'wav', or 'mp3' (320 kbps). Anything but 'm4a' requires the backend's async generation mode (submit + poll) instead of streaming — selected automatically, no user-facing mode param needed. variants_num (int, optional): 1-10, default 1. Generate this many distinct music variants in one request — each is its own creative direction with its own title, not just a re-roll. Cost scales linearly with N. Values above 1 require the backend's async generation mode (handled automatically, same as output_format='wav') and are never covered by the free trial — even a trial account is billed for variants beyond the first. stems (bool, optional): Default false. Pass stems=true to also get the track split into four separate instrument tracks — drums, bass, vocals and other — at no extra charge; it adds a few minutes to the wait (this tool then waits up to 75 minutes), so set it only when the user asks for stems or separated tracks. Uses the backend's async generation mode (handled automatically, same as output_format='wav'). If a stems result comes back with stems_error instead of (or alongside a partial) stems — surfaced here as a note in the returned text — only the separation failed or was skipped: the music itself generated fine, the saved audio files are valid, and the user was not charged for the separation — report it as a missing extra, not as a failed generation. output_directory (str, optional): Absolute path, or relative to SONILO_MCP_BASE_PATH. Defaults to SONILO_MCP_BASE_PATH (~/Desktop unless overridden).

Returns: One TextContent per generated audio stream, each containing the absolute path of the saved audio file (.m4a by default, .wav when output_format='wav'). At variants_num > 1, one entry per variant (suffixed -0, -1, ...), each labeled with its title when the backend provides one. stems=True: also one TextContent per saved stem file (drums/bass/vocals/other, per stream), or a note carrying stems_error when the free separation failed or was skipped.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "prompt": "<prompt>"
    },
    "name": "text_to_music"
  }
}

Input Schema

NameRequiredDescriptionDefault
stemsNo
promptYes
durationNo
variants_numNo
output_formatNo
output_directoryNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changedv0.28.0
    • addedInput schema / properties / duration / anyOf
      Added value: +[
      +  {
      +    "type": "integer"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • addedInput schema / properties / duration / default
      Added value: +null
    • removedInput schema / properties / duration / type
      Removed value: -"integer"
    • addedInput schema / properties / output_format
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Output Format"
      +}
    • addedInput schema / properties / stems
      Added value: +{
      +  "default": false,
      +  "title": "Stems",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / variants_num
      Added value: +{
      +  "default": 1,
      +  "title": "Variants Num",
      +  "type": "integer"
      +}
    • changedInput schema / required
      Previous value: -[
      -  "prompt",
      -  "duration"
      -]New value: +[
      +  "prompt"
      +]
  2. First observedv0.4.0

TDQS

A4.7/5.0
Behavior5/5

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

Goes well beyond the annotations: upfront cost warning, licensing/commercial-use status, async vs streaming mode switching, 75-minute stems wait, linear cost scaling with variants, trial-account billing exception, and how to interpret a stems_error as a missing extra rather than a failed generation. This is exactly the context annotations cannot carry.

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

Conciseness4/5

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

Front-loaded and organized into Args/Returns blocks with the cost warning early, which is the right priority order. It loses a point for repeating the 'requires backend async generation mode (handled automatically, same as output_format=wav)' clause three separate times, which bloats an otherwise tight spec.

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

Completeness5/5

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

Covers the full lifecycle: what is produced, where it lands, the default base path, per-variant/per-stem return shapes, and failure semantics for stems. Even with an output schema present, the description supplies decision-relevant behavior (billing, waits, licensing) that the schema cannot express.

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

Parameters5/5

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

Schema coverage is 0%, so the description carries the full burden and does: prompt length range, duration bounds with the omit-to-auto behavior, format enum with bitrate and mode implications, variants range and cost/scaling semantics, stems default and side effects. No parameter meaning is left to guesswork.

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?

States a specific verb+resource ('Generate music from a text prompt') and adds the differentiating outcome — saving audio files to a local directory. Among siblings like text_to_sfx, video_to_music and video_to_video_music, the text-prompt-to-music scope is unambiguous.

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?

Gives an explicit guardrail ('Only use when explicitly requested by the user') and a conditional rule for stems ('set it only when the user asks for stems or separated tracks'). It doesn't name sibling alternatives for the video- or SFX-based cases, so routing between siblings is left mostly to the names.

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