Skip to main content
Glama
jezweb

Smart Prompts MCP Server

search_prompts

Search for prompts by keyword, category, or tags to find existing prompts and avoid duplicates before creating new ones.

Instructions

🔍 ALWAYS START HERE: Search for prompts by keyword, category, or tags. Returns matching prompts with their metadata. This is the recommended first step before using get_prompt or creating new prompts. Helps avoid duplicates and find exactly what you need.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNoFilter by specific category. Available: "development", "content-creation", "business", "ai-prompts", "devops", "documentation", "project-management"
queryNoSearch keywords to find in prompt title, description, or content. Examples: "api", "documentation", "code review", "testing"
tagsNoFilter by tags for precise matching. Examples: ["api", "rest"], ["testing", "automation"], ["documentation", "technical-writing"]

Implementation Reference

  • Defines the MCP tool schema for 'search_prompts' including name, description, and input parameters (query: required string, limit: optional number). This is returned by listPrompts() for tool discovery.
    {
      name: 'search_prompts',
      description: 'Search for prompts by keyword',
      arguments: [
        {
          name: 'query',
          description: 'Search query',
          required: true,
        },
        {
          name: 'limit',
          description: 'Maximum number of results (default: 5)',
          required: false,
        },
      ],
    },
  • Main handler for search_prompts tool invocation. Validates inputs, performs search via cache, limits results, and returns formatted assistant message listing matching prompts with metadata.
      private async handleSearchPrompts(args?: Record<string, string>): Promise<PromptMessage[]> {
        if (!args?.query) {
          throw new Error('query argument is required');
        }
    
        const limit = parseInt(args.limit || '5', 10);
        const results = this.cache.searchPrompts(args.query).slice(0, limit);
    
        const content = `# Search Results for "${args.query}"
    
    Found ${results.length} prompts:
    
    ${results.map((prompt, i) => `
    ${i + 1}. **${prompt.metadata.title || prompt.name}**
       - Category: ${prompt.metadata.category || 'general'}
       - Tags: ${prompt.metadata.tags?.join(', ') || 'none'}
       - Description: ${prompt.metadata.description || 'No description'}
    `).join('\n')}
    
    To use a prompt, ask for it by name.`;
    
        return [
          {
            role: 'assistant',
            content: {
              type: 'text',
              text: content,
            },
          },
        ];
      }
  • Helper method implementing prompt search logic: case-insensitive matching of query against prompt title, description, content, and tags.
    searchPrompts(query: string): PromptInfo[] {
      const lowerQuery = query.toLowerCase();
      return this.getAllPrompts().filter(prompt => {
        const inTitle = prompt.metadata.title?.toLowerCase().includes(lowerQuery);
        const inDescription = prompt.metadata.description?.toLowerCase().includes(lowerQuery);
        const inContent = prompt.content?.toLowerCase().includes(lowerQuery);
        const inTags = prompt.metadata.tags?.some(tag => 
          tag.toLowerCase().includes(lowerQuery)
        );
        
        return inTitle || inDescription || inContent || inTags;
      });
    }

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