list
Retrieve saved prompts from the prompts directory for Claude Desktop, with optional limit to control the number of results returned.
Instructions
List saved prompts in the prompts directory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of prompts to return |
Implementation Reference
- src/index.ts:86-128 (handler)The handler function for the 'list' tool. It reads the 'prompts' directory, filters for .md files containing '_', sorts them newest first, limits to the specified number, and returns a formatted list or appropriate messages if no files or directory missing.async ({ limit = 20 }) => { const promptsDir = path.join(process.cwd(), 'prompts'); try { const files = await fs.readdir(promptsDir); const promptFiles = files .filter((file) => file.endsWith('.md') && file.includes('_')) .sort((a, b) => b.localeCompare(a)) // Sort by newest first .slice(0, limit); if (promptFiles.length === 0) { return { content: [ { type: 'text', text: 'No prompts found in prompts directory.', }, ], }; } return { content: [ { type: 'text', text: `Found ${promptFiles.length} prompts:\n${promptFiles .map((f) => `- ${f}`) .join('\n')}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: 'Prompts directory not found. Create your first prompt to initialize.', }, ], }; } }, );
- src/index.ts:79-84 (schema)Zod input schema defining the optional 'limit' parameter (number) for the number of prompts to list.inputSchema: { limit: z .number() .optional() .describe('Maximum number of prompts to return'), },
- src/index.ts:75-85 (registration)Registration of the 'list' tool on the MCP server, providing name, description, input schema, and handler reference.mcpServer.registerTool( 'list', { description: 'List saved prompts in the prompts directory', inputSchema: { limit: z .number() .optional() .describe('Maximum number of prompts to return'), }, },