search_mcp_docs
Find relevant Model Context Protocol (MCP) documentation by querying stored resources to aid in server creation and project scaffolding.
Instructions
Search through stored MCP documentation for relevant information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- src/tools/search-docs.ts:17-56 (handler)Core handler function that executes the search_mcp_docs tool: validates input using Zod schema, initializes documentation storage, searches for relevant docs using query, handles errors, and returns structured results.export async function searchMcpDocs( options: DocSearchOptions ): Promise<{ success: boolean; message: string; results?: Array<{ key: string; content: string; relevance: number }>; }> { try { // Validate options const validatedOptions = searchDocsSchema.parse(options); // Initialize docs storage if it doesn't exist yet await initDocsStorage(); // Search the documentation const searchResults = await searchDocumentation(validatedOptions.query); if (searchResults.length === 0) { return { success: true, message: "No matching documentation found.", results: [], }; } return { success: true, message: `Found ${searchResults.length} matching documentation entries.`, results: searchResults, }; } catch (error: any) { console.error(chalk.red("Error searching documentation:"), error); return { success: false, message: `Error searching documentation: ${ error.message || String(error) }`, }; } }
- src/server.ts:130-159 (registration)Registers the 'search_mcp_docs' tool with the MCP server, providing tool name, description, input schema (query: string), and a wrapper async handler that invokes searchMcpDocs and formats the response as MCP content.// Register the search_mcp_docs tool server.tool( "search_mcp_docs", "Search through stored MCP documentation for relevant information", { query: z.string().min(1), }, async (params: DocSearchOptions) => { const result = await searchMcpDocs(params); if (!result.success || !result.results) { return { content: [{ type: "text", text: result.message }], }; } // Return formatted search results let responseText = result.message + "\n\n"; for (const doc of result.results) { responseText += `## ${doc.key}\n${doc.content.substring(0, 500)}${ doc.content.length > 500 ? "..." : "" }\n\n`; } return { content: [{ type: "text", text: responseText }], }; } );
- src/tools/search-docs.ts:10-12 (schema)Zod input schema for the search_mcp_docs tool parameters, ensuring 'query' is a non-empty string. Used for internal validation in the handler.export const searchDocsSchema = z.object({ query: z.string().min(1), });