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.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "search_prompts"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Filter by specific category. Available: "development", "content-creation", "business", "ai-prompts", "devops", "documentation", "project-management" | |
| query | No | Search keywords to find in prompt title, description, or content. Examples: "api", "documentation", "code review", "testing" | |
| tags | No | Filter by tags for precise matching. Examples: ["api", "rest"], ["testing", "automation"], ["documentation", "technical-writing"] |
Implementation Reference
- src/mcpPrompts.ts:85-100 (schema)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, }, ], }, - src/mcpPrompts.ts:203-233 (handler)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, }, }, ]; } - src/enhancedCache.ts:124-136 (helper)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; }); }