Skip to main content
Glama
tanker327

Prompts MCP Server

by tanker327

list_prompts

Display available prompt templates to help users find and select pre-configured prompts for their AI workflows.

Instructions

List all available prompts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler function for the 'list_prompts' tool. Fetches prompts from file operations, handles empty list, formats the list, and returns 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,
        ],
      };
    }
  • Tool schema definition including name, description, and empty input schema (no parameters required).
    {
      name: 'list_prompts',
      description: 'List all available prompts',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
  • Core helper function that lists all prompts by initializing and querying the prompt 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:142-143 (registration)
    Tool registration in the switch dispatcher within handleToolCall method.
    case 'list_prompts':
      return await this.handleListPrompts();
  • Helper function to format the list of prompts into a readable markdown display.
    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')}`;
    }

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/tanker327/prompts-mcp-server'

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