list_prompts
Retrieve a comprehensive list of all available prompt templates from the Prompts MCP Server to streamline access and management of structured prompts for workflows.
Instructions
List all available prompts
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:235-259 (handler)The main handler for the 'list_prompts' tool. It retrieves the list of prompts using fileOps.listPrompts(), handles empty case, formats the output using formatPromptsList, and returns it as MCP CallToolResult.private async handleListPrompts(): Promise<CallToolResult> { const prompts = await this.fileOps.listPrompts(); if (prompts.length === 0) { return { content: [ { type: 'text', text: 'No prompts available', } as TextContent, ], }; } const text = this.formatPromptsList(prompts); return { content: [ { type: 'text', text, } as TextContent, ], }; }
- src/tools.ts:59-66 (registration)Tool registration in getToolDefinitions(), including the tool name 'list_prompts', description, and input schema (no required parameters).{ name: 'list_prompts', description: 'List all available prompts', inputSchema: { type: 'object', properties: {}, }, },
- src/tools.ts:62-65 (schema)Input schema definition for list_prompts tool: empty object, indicating no input parameters needed.inputSchema: { type: 'object', properties: {}, },
- src/fileOperations.ts:37-45 (helper)Core helper method listPrompts() in PromptFileOperations class that initializes the prompt cache if necessary and returns the list of all prompts from the cache.async listPrompts(): Promise<PromptInfo[]> { // Initialize cache and file watcher if not already done if (this.cache.isEmpty()) { await this.cache.initializeCache(); this.cache.initializeFileWatcher(); } return this.cache.getAllPrompts(); }
- src/tools.ts:330-347 (helper)Helper function to format the list of prompts into a structured Markdown output with sections for each prompt's metadata and preview.private formatPromptsList(prompts: PromptInfo[]): string { const formatPrompt = (prompt: PromptInfo): string => { let output = `## ${prompt.name}\n`; if (Object.keys(prompt.metadata).length > 0) { output += '**Metadata:**\n'; Object.entries(prompt.metadata).forEach(([key, value]) => { output += `- ${key}: ${value}\n`; }); output += '\n'; } output += `**Preview:** ${prompt.preview}\n`; return output; }; return `# Available Prompts\n\n${prompts.map(formatPrompt).join('\n---\n\n')}`; }