Skip to main content
Glama

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
NameRequiredDescriptionDefault
queryYes

Implementation Reference

  • 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 }], }; } );
  • 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), });

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/CaptainCrouton89/mcp-maker'

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