search_prompts
Search AI prompts by keyword, type, category, or tag to find community-curated prompts for AI coding assistants.
Instructions
Search for AI prompts by keyword. Returns matching prompts with title, description, content, author, category, and tags.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query to find relevant prompts | |
| limit | No | Maximum number of prompts to return (default 10, max 50) | |
| type | No | Filter by prompt type | |
| category | No | Filter by category slug | |
| tag | No | Filter by tag slug |
Implementation Reference
- src/index.ts:148-173 (handler)Handler function that executes the search_prompts tool by forwarding the request to the prompts.chat upstream API via tools/call.async ({ query, limit, type, category, tag }) => { try { const response = await callPromptsChatMcp("tools/call", { name: "search_prompts", arguments: { query, limit, type, category, tag }, }); if (response.error) { return { content: [{ type: "text" as const, text: JSON.stringify({ error: response.error.message }) }], isError: true, }; } const result = response.result as { content: Array<{ type: string; text: string }> }; return { content: [{ type: "text" as const, text: result.content[0].text }], }; } catch (error) { const message = error instanceof Error ? error.message : String(error); return { content: [{ type: "text" as const, text: JSON.stringify({ error: message }) }], isError: true, }; } }
- src/index.ts:132-146 (schema)Input schema for search_prompts tool defining parameters like query, limit, type, category, and tag using Zod.inputSchema: { query: z.string().describe("Search query to find relevant prompts"), limit: z .number() .min(1) .max(50) .default(10) .describe("Maximum number of prompts to return (default 10, max 50)"), type: z .enum(["TEXT", "STRUCTURED", "IMAGE", "VIDEO", "AUDIO"]) .optional() .describe("Filter by prompt type"), category: z.string().optional().describe("Filter by category slug"), tag: z.string().optional().describe("Filter by tag slug"), },
- src/index.ts:126-174 (registration)Registration of the search_prompts tool with server.registerTool, including schema and handler.server.registerTool( "search_prompts", { title: "Search Prompts", description: "Search for AI prompts by keyword. Returns matching prompts with title, description, content, author, category, and tags.", inputSchema: { query: z.string().describe("Search query to find relevant prompts"), limit: z .number() .min(1) .max(50) .default(10) .describe("Maximum number of prompts to return (default 10, max 50)"), type: z .enum(["TEXT", "STRUCTURED", "IMAGE", "VIDEO", "AUDIO"]) .optional() .describe("Filter by prompt type"), category: z.string().optional().describe("Filter by category slug"), tag: z.string().optional().describe("Filter by tag slug"), }, }, async ({ query, limit, type, category, tag }) => { try { const response = await callPromptsChatMcp("tools/call", { name: "search_prompts", arguments: { query, limit, type, category, tag }, }); if (response.error) { return { content: [{ type: "text" as const, text: JSON.stringify({ error: response.error.message }) }], isError: true, }; } const result = response.result as { content: Array<{ type: string; text: string }> }; return { content: [{ type: "text" as const, text: result.content[0].text }], }; } catch (error) { const message = error instanceof Error ? error.message : String(error); return { content: [{ type: "text" as const, text: JSON.stringify({ error: message }) }], isError: true, }; } } );
- src/index.ts:26-70 (helper)Helper function callPromptsChatMcp used by the search_prompts handler to make API calls to prompts.chat.async function callPromptsChatMcp( method: string, params?: Record<string, unknown> ): Promise<McpResponse> { const response = await fetch(PROMPTS_CHAT_API, { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json, text/event-stream", "User-Agent": USER_AGENT, ...(PROMPTS_API_KEY && { "PROMPTS-API-KEY": PROMPTS_API_KEY }), }, body: JSON.stringify({ jsonrpc: "2.0", id: Date.now(), method, params, }), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const contentType = response.headers.get("content-type") || ""; // Handle SSE response format if (contentType.includes("text/event-stream")) { const text = await response.text(); const lines = text.split("\n"); for (const line of lines) { if (line.startsWith("data: ")) { const jsonStr = line.slice(6); if (jsonStr.trim()) { return JSON.parse(jsonStr) as McpResponse; } } } throw new Error("No valid JSON data found in SSE response"); } return (await response.json()) as McpResponse; }