Skip to main content
Glama
williamzujkowski

Strudel MCP Server

generate_melody

Create melodies by specifying a musical scale, root note, and length. This tool generates melodic patterns for music composition and live coding applications.

Instructions

Generate melody from scale

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scaleYesScale name
rootYesRoot note
lengthNoNumber of notes

Implementation Reference

  • Tool schema definition including input validation for scale, root note, and optional length.
      name: 'generate_melody',
      description: 'Generate melody from scale',
      inputSchema: {
        type: 'object',
        properties: {
          scale: { type: 'string', description: 'Scale name' },
          root: { type: 'string', description: 'Root note' },
          length: { type: 'number', description: 'Number of notes' }
        },
        required: ['scale', 'root']
      }
    },
  • Main handler in executeTool switch statement: validates inputs, generates scale using MusicTheory, calls PatternGenerator.generateMelody, appends to current pattern or writes new, returns success message.
    case 'generate_melody':
      InputValidator.validateRootNote(args.root);
      InputValidator.validateScaleName(args.scale);
      if (args.length !== undefined) {
        InputValidator.validatePositiveInteger(args.length, 'length');
      }
      const scale = this.theory.generateScale(args.root, args.scale);
      const melody = this.generator.generateMelody(scale, args.length || 8);
      const currentMelody = await this.getCurrentPatternSafe();
      const newMelodyPattern = currentMelody ? currentMelody + '\n' + melody : melody;
      await this.writePatternSafe(newMelodyPattern);
      return `Generated melody in ${args.root} ${args.scale}`;
  • Core melody generation logic: creates melodic line using scale notes with step/leap probabilities, random octaves, outputs Strudel note pattern with triangle synth.
    generateMelody(scale: string[], length: number = 8, octaveRange: [number, number] = [3, 5]): string {
      const notes = [];
      let lastNoteIndex = Math.floor(Math.random() * scale.length);
      
      for (let i = 0; i < length; i++) {
        // Create more musical intervals (prefer steps over leaps)
        const stepProbability = 0.7;
        const useStep = Math.random() < stepProbability;
        
        let noteIndex: number;
        if (useStep) {
          // Move by step (1 or 2 scale degrees)
          const step = Math.random() < 0.5 ? 1 : -1;
          noteIndex = (lastNoteIndex + step + scale.length) % scale.length;
        } else {
          // Leap to any note
          noteIndex = Math.floor(Math.random() * scale.length);
        }
        
        const note = scale[noteIndex];
        const octave = octaveRange[0] + Math.floor(Math.random() * (octaveRange[1] - octaveRange[0] + 1));
        notes.push(`${note.toLowerCase()}${octave}`);
        lastNoteIndex = noteIndex;
      }
      
      return `note("${notes.join(' ')}").s("triangle")`;
    }
  • Tool registration via setRequestHandler for ListToolsRequestSchema, which returns the tools array containing generate_melody.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: this.getTools()
    }));
Behavior2/5

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

No annotations are provided, so the description carries full burden. 'Generate melody from scale' implies a creative output, but it doesn't disclose behavioral traits such as whether this is deterministic or random, what format the melody is returned in (e.g., MIDI, notation), or any constraints like tempo or style. This leaves significant gaps for an agent to understand how the tool behaves.

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 a single, efficient phrase with zero waste. It's front-loaded with the core action and resource, making it easy to parse quickly without unnecessary elaboration.

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 annotations and no output schema, the description is incomplete for a generative tool. It doesn't explain what the output is (e.g., a musical sequence, file, or data structure), any quality or randomness aspects, or how parameters like 'length' affect the result. This makes it inadequate for an agent to fully understand the tool's context and usage.

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

Parameters3/5

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

Schema description coverage is 100%, with clear parameter descriptions in the schema (scale name, root note, number of notes). The description adds no additional meaning beyond implying that 'scale' and 'root' are required inputs, but it doesn't explain parameter interactions or provide examples. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description 'Generate melody from scale' clearly states the verb ('generate') and resource ('melody'), specifying the input source ('from scale'). It distinguishes from siblings like 'generate_bassline' or 'generate_chord_progression' by focusing on melody, but doesn't explicitly differentiate from 'generate_pattern' or 'compose' which might overlap in musical generation.

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?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'generate_pattern', 'compose', and 'generate_variation' that might also create musical sequences, there's no indication of specific contexts, prerequisites, or exclusions for choosing this melody generator.

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/williamzujkowski/strudel-mcp-server'

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