configure_drum_controls
Set up pitch and envelope settings for each drum type, enabling customizable ranges and natural decay control. Generates XML structure for global drum controls and validates inputs to ensure accurate configuration.
Instructions
Configure global pitch and envelope controls for each drum type.
This tool will:
Add per-drum pitch controls with customizable ranges
Configure ADSR envelope settings for natural decay control
Generate proper XML structure for global drum controls
Error Handling:
Validates pitch range values (min/max must be valid numbers)
Ensures envelope times are positive values
Verifies curve values are within -100 to 100 range
Returns detailed error messages for invalid configurations
Success Response: Returns XML structure containing:
Global controls for each drum type
MIDI CC mappings for real-time control
Properly formatted parameter bindings
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| drumControls | Yes |
Implementation Reference
- src/drum-controls.ts:129-153 (handler)The main handler function that executes the tool logic: validates drum control configurations (pitch and envelope settings) and generates an AdvancedDrumKitConfig with global drumControls and empty drumPieces for further processing.export function configureDrumControls(config: DrumControlsConfig): AdvancedDrumKitConfig { // Validate all drum configurations for (const drum of config.drums) { validatePitchSettings(drum); validateEnvelopeSettings(drum); } // Create the drum kit configuration return { globalSettings: { drumControls: config.drums.reduce((acc, drum) => ({ ...acc, [drum.name]: { ...(drum.pitch && { pitch: drum.pitch }), ...(drum.envelope && { envelope: drum.envelope }) } }), {}) }, drumPieces: config.drums.map(drum => ({ name: drum.name, rootNote: drum.rootNote, samples: [] // Let caller provide samples })) }; }
- src/drum-controls.ts:34-60 (schema)TypeScript interfaces defining the input schema for drum controls: DrumPitchConfig, DrumEnvelopeConfig, DrumConfig, DrumControlsConfig. Used for type checking and validation.export interface DrumPitchConfig { default: number; min?: number; max?: number; } export interface DrumEnvelopeConfig { attack: number; decay: number; sustain: number; release: number; attackCurve?: number; decayCurve?: number; releaseCurve?: number; } export interface DrumConfig { name: string; rootNote: number; // Required instead of defaulting pitch?: DrumPitchConfig; envelope?: DrumEnvelopeConfig; } export interface DrumControlsConfig { drums: DrumConfig[]; }
- src/index.ts:123-188 (schema)JSON Schema defining the input validation for the MCP tool 'configure_drum_controls', matching the TypeScript types.inputSchema: { type: "object", properties: { drumControls: { type: "object", additionalProperties: { type: "object", properties: { pitch: { type: "object", properties: { default: { type: "number", description: "Default pitch in semitones (0 = no change)" }, min: { type: "number", description: "Minimum pitch adjustment (e.g. -12 semitones)" }, max: { type: "number", description: "Maximum pitch adjustment (e.g. +12 semitones)" } }, required: ["default"] }, envelope: { type: "object", properties: { attack: { type: "number", description: "Attack time in seconds" }, decay: { type: "number", description: "Decay time in seconds" }, sustain: { type: "number", description: "Sustain level (0-1)" }, release: { type: "number", description: "Release time in seconds" }, attackCurve: { type: "number", description: "-100 to 100, Default: -100 (logarithmic)" }, decayCurve: { type: "number", description: "-100 to 100, Default: 100 (exponential)" }, releaseCurve: { type: "number", description: "-100 to 100, Default: 100 (exponential)" } }, required: ["attack", "decay", "sustain", "release"] } } } } }, required: ["drumControls"] }
- src/index.ts:715-752 (registration)MCP CallToolRequestSchema dispatch case that handles the tool call: transforms input arguments to DrumControlsConfig, invokes the handler, generates XML output via generateGroupsXml, and handles errors.case "configure_drum_controls": { const args = request.params.arguments; if (!args || typeof args !== 'object' || !args.drumControls) { throw new McpError( ErrorCode.InvalidParams, "Invalid arguments: expected object with drumControls" ); } try { // Convert the input format to our DrumControlsConfig format const drumControlsConfig: DrumControlsConfig = { drums: Object.entries(args.drumControls).map(([name, controls]) => ({ name, ...(controls as any) })) }; // Configure and validate the drum controls const config = configureDrumControls(drumControlsConfig); // Generate XML with the validated configuration const xml = generateGroupsXml(config); return { content: [{ type: "text", text: xml }] }; } catch (error: unknown) { if (error instanceof McpError) throw error; const message = error instanceof Error ? error.message : String(error); throw new McpError( ErrorCode.InternalError, `Failed to configure drum controls: ${message}` ); } }
- src/index.ts:103-189 (registration)Tool registration in ListToolsRequestSchema response: defines name, description, and inputSchema for discovery by MCP clients.{ name: "configure_drum_controls", description: `Configure global pitch and envelope controls for each drum type. This tool will: - Add per-drum pitch controls with customizable ranges - Configure ADSR envelope settings for natural decay control - Generate proper XML structure for global drum controls Error Handling: - Validates pitch range values (min/max must be valid numbers) - Ensures envelope times are positive values - Verifies curve values are within -100 to 100 range - Returns detailed error messages for invalid configurations Success Response: Returns XML structure containing: - Global controls for each drum type - MIDI CC mappings for real-time control - Properly formatted parameter bindings`, inputSchema: { type: "object", properties: { drumControls: { type: "object", additionalProperties: { type: "object", properties: { pitch: { type: "object", properties: { default: { type: "number", description: "Default pitch in semitones (0 = no change)" }, min: { type: "number", description: "Minimum pitch adjustment (e.g. -12 semitones)" }, max: { type: "number", description: "Maximum pitch adjustment (e.g. +12 semitones)" } }, required: ["default"] }, envelope: { type: "object", properties: { attack: { type: "number", description: "Attack time in seconds" }, decay: { type: "number", description: "Decay time in seconds" }, sustain: { type: "number", description: "Sustain level (0-1)" }, release: { type: "number", description: "Release time in seconds" }, attackCurve: { type: "number", description: "-100 to 100, Default: -100 (logarithmic)" }, decayCurve: { type: "number", description: "-100 to 100, Default: 100 (exponential)" }, releaseCurve: { type: "number", description: "-100 to 100, Default: 100 (exponential)" } }, required: ["attack", "decay", "sustain", "release"] } } } } }, required: ["drumControls"] } },