Skip to main content
Glama

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
NameRequiredDescriptionDefault
limitNoMaximum number of prompts to return

Implementation Reference

  • 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.', }, ], }; } }, );
  • 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'), }, },

Other Tools

Related Tools

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/seungwonme/prompt-new-mcp'

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