create_loop
Generate a loop with a specified type and rhythm to define iterative cycles for strategic or creative workflows.
Instructions
Create a loop - an iterative cycle
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the loop | |
| type | Yes | Type of loop pattern | |
| rhythm | No | Rhythm pattern of iterations |
Implementation Reference
- index.js:430-486 (handler)The createLoop() method - the actual implementation of the 'create_loop' tool. It validates name/type inputs, checks for duplicate loops, creates a loop object with name/type/rhythm/iterations/phase, stores it in the loops Map, generates a rhythm pattern, and returns a formatted success response.
createLoop(args) { const { name, type, rhythm = 'constant' } = args; if (!name || name.trim().length === 0) { return { content: [ { type: 'text', text: `❌ Loop name is required. Please provide a name for the loop.`, }, ], }; } if (!type || type.trim().length === 0) { return { content: [ { type: 'text', text: `❌ Loop type is required. Please specify a type: infinite, convergent, divergent, spiral, or oscillating.`, }, ], }; } if (this.loops.has(name)) { return { content: [ { type: 'text', text: `⚠️ Loop "${name}" already exists. Use a different name or iterate the existing loop.`, }, ], }; } const loop = { name, type, rhythm, iterations: [], created_at: new Date().toISOString(), phase: 0, }; this.loops.set(name, loop); this.rhythms.set(`loop_${name}`, this.generateRhythm(rhythm)); return { content: [ { type: 'text', text: `🔄 Loop "${name}" created!\n\nType: ${type}\nRhythm: ${rhythm}\n\n${this.visualizeLoopPattern(type)}\n\nThe ${type} loop is ready with ${rhythm} rhythm.`, }, ], }; } - index.js:72-95 (schema)The input schema for the 'create_loop' tool registered in the ListToolsRequestHandler. Defines the tool name, description, and input schema with required fields 'name' (string) and 'type' (enum: infinite, convergent, divergent, spiral, oscillating), plus optional 'rhythm' (enum: constant, variable, fibonacci, exponential, harmonic).
{ name: 'create_loop', description: 'Create a loop - an iterative cycle', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the loop', }, type: { type: 'string', enum: ['infinite', 'convergent', 'divergent', 'spiral', 'oscillating'], description: 'Type of loop pattern', }, rhythm: { type: 'string', enum: ['constant', 'variable', 'fibonacci', 'exponential', 'harmonic'], description: 'Rhythm pattern of iterations', }, }, required: ['name', 'type'], }, }, - index.js:333-334 (registration)The routing/case statement in the CallToolRequestSchema handler that dispatches 'create_loop' calls to this.createLoop(args).
case 'create_loop': return this.createLoop(args); - index.js:465-476 (helper)The loop object construction and storage: creates the loop state object (with name, type, rhythm, iterations array, created_at timestamp, and phase), stores it in this.loops Map, and registers a generated rhythm under 'loop_{name}' in this.rhythms Map. Also used by the createLoop handler.
const loop = { name, type, rhythm, iterations: [], created_at: new Date().toISOString(), phase: 0, }; this.loops.set(name, loop); this.rhythms.set(`loop_${name}`, this.generateRhythm(rhythm));