Skip to main content
Glama
jezweb

Smart Prompts MCP Server

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
NameRequiredDescriptionDefault
promptsYesList of exact prompt names to combine in order. Get these names from search_prompts results. Examples: ["code_review_assistant", "documentation_generator"]
separatorNoText to insert between prompts. Defaults to "\n\n---\n\n". Can use "\n\nNext Step:\n\n" or custom separators.

Implementation Reference

  • 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,
        ],
      };
    }
  • 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" }
      ],
    },
  • 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" }
        ],
      },
    },
  • Switch case in handleToolCall that routes compose_prompts calls to the handler method.
    case 'compose_prompts':
      return this.handleComposePrompts(toolArgs);
  • 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,
          },
        ],
      };
    }

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/jezweb/smart-prompts-mcp'

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