compose_prompts
Combine multiple existing prompts into a single prompt to create complex multi-step workflows. Use search_prompts first to find prompt names, then compose them with custom separators.
Instructions
π Combine Prompts: Combine multiple existing prompts into a single prompt. Perfect for creating complex multi-step workflows. π WORKFLOW: Use search_prompts to find prompt names first, then compose them.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompts | Yes | List of exact prompt names to combine in order. Get these names from search_prompts results. Examples: ["code_review_assistant", "documentation_generator"] | |
| separator | No | Text to insert between prompts. Defaults to "\n\n---\n\n". Can use "\n\nNext Step:\n\n" or custom separators. |
Implementation Reference
- src/enhancedTools.ts:702-734 (handler)The primary handler function for the 'compose_prompts' tool. It validates the input prompts array, retrieves each prompt from the cache, handles missing prompts with errors, joins the contents with a customizable separator, and returns a formatted composed prompt.private handleComposePrompts(args: EnhancedToolArguments): CallToolResult { if (!args.prompts || args.prompts.length === 0) { throw new Error('At least one prompt name is required. π‘ TIP: Use search_prompts to find prompt names, then list them here.'); } const separator = args.separator || '\n\n---\n\n'; const composedParts: string[] = []; const notFound: string[] = []; for (const promptName of args.prompts) { const prompt = this.cache.getPrompt(promptName); if (prompt && prompt.content) { composedParts.push(prompt.content); } else { notFound.push(promptName); } } if (notFound.length > 0) { throw new Error(`Prompts not found: ${notFound.join(', ')}\n\nπ Use search_prompts to find the correct prompt names. Make sure to use exact names from search results.`); } const composed = composedParts.join(separator); return { content: [ { type: 'text', text: `# Composed Prompt\n\nCombined ${args.prompts.length} prompts:\n${args.prompts.map(p => `- ${p}`).join('\n')}\n\n## Result:\n\n${composed}`, } as TextContent, ], }; }
- src/enhancedTools.ts:223-241 (schema)Input schema definition for the compose_prompts tool, specifying the prompts array (required) and optional separator string.inputSchema: { type: 'object', properties: { prompts: { type: 'array', items: { type: 'string' }, description: 'List of exact prompt names to combine in order. Get these names from search_prompts results. Examples: ["code_review_assistant", "documentation_generator"]', }, separator: { type: 'string', description: 'Text to insert between prompts. Defaults to "\\n\\n---\\n\\n". Can use "\\n\\nNext Step:\\n\\n" or custom separators.', }, }, required: ['prompts'], examples: [ { prompts: ["code_review_assistant", "documentation_generator"], description: "Review code then generate docs" }, { prompts: ["api_documentation_generator", "testing_framework"], separator: "\\n\\nNext Task:\\n\\n", description: "Document API then create tests" } ], },
- src/enhancedTools.ts:221-242 (registration)Registration of the compose_prompts tool in the getToolDefinitions() method, including name, description, and full input schema.name: 'compose_prompts', description: 'π Combine Prompts: Combine multiple existing prompts into a single prompt. Perfect for creating complex multi-step workflows. π WORKFLOW: Use search_prompts to find prompt names first, then compose them.', inputSchema: { type: 'object', properties: { prompts: { type: 'array', items: { type: 'string' }, description: 'List of exact prompt names to combine in order. Get these names from search_prompts results. Examples: ["code_review_assistant", "documentation_generator"]', }, separator: { type: 'string', description: 'Text to insert between prompts. Defaults to "\\n\\n---\\n\\n". Can use "\\n\\nNext Step:\\n\\n" or custom separators.', }, }, required: ['prompts'], examples: [ { prompts: ["code_review_assistant", "documentation_generator"], description: "Review code then generate docs" }, { prompts: ["api_documentation_generator", "testing_framework"], separator: "\\n\\nNext Task:\\n\\n", description: "Document API then create tests" } ], }, },
- src/enhancedTools.ts:276-277 (registration)Switch case in handleToolCall that routes compose_prompts calls to the handler method.case 'compose_prompts': return this.handleComposePrompts(toolArgs);
- src/index-original.ts:135-154 (handler)Alternative simpler inline handler for compose_prompts in what appears to be an original or backup entry point file.case 'compose_prompts': { const promptNames = request.params.arguments?.prompts as string[]; const separator = (request.params.arguments?.separator as string) || '\n\n---\n\n'; const composed = promptNames .map(name => { const prompt = cache.getPrompt(name); return prompt ? prompt.content : null; }) .filter(Boolean) .join(separator); return { content: [ { type: 'text', text: composed, }, ], }; }