Skip to main content
Glama

searchDocs

Search Markdown, MDX, and text documentation files in your workspace to quickly find developer information and technical content.

Instructions

Search developer documentation files (Markdown, MDX, text) in the workspace

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch term or phrase to find in documentation
includeNoCustom glob patterns to include (default: markdown and docs files)

Implementation Reference

  • Handler function for the 'searchDocs' tool. It defines specific glob patterns for documentation files and calls the searchFiles helper with a max of 50 results.
    async ({ query, include }: { query: string; include?: string[] }) => { try { const patterns = include ?? ["**/*.md", "**/*.mdx", "**/*.txt", "docs/**/*", "**/README.*"]; const results = await searchFiles(query, patterns, { maxResults: 50 }); return { content: results }; } catch (error) { return { content: [{ type: "text", text: `Error searching docs: ${error}` }], isError: true }; } }
  • Input schema for the 'searchDocs' tool using Zod, defining 'query' and optional 'include' parameters.
    { query: z.string().describe("Search term or phrase to find in documentation"), include: z .array(z.string()) .optional() .describe("Custom glob patterns to include (default: markdown and docs files)"), },
  • src/index.ts:10-29 (registration)
    Registration of the 'searchDocs' MCP tool on the McpServer instance, including name, description, schema, and handler.
    mcp.tool( "searchDocs", "Search developer documentation files (Markdown, MDX, text) in the workspace", { query: z.string().describe("Search term or phrase to find in documentation"), include: z .array(z.string()) .optional() .describe("Custom glob patterns to include (default: markdown and docs files)"), }, async ({ query, include }: { query: string; include?: string[] }) => { try { const patterns = include ?? ["**/*.md", "**/*.mdx", "**/*.txt", "docs/**/*", "**/README.*"]; const results = await searchFiles(query, patterns, { maxResults: 50 }); return { content: results }; } catch (error) { return { content: [{ type: "text", text: `Error searching docs: ${error}` }], isError: true }; } } );
  • The searchFiles helper function used by searchDocs (and other tools) to glob files, read contents, and search for the query term, returning formatted results.
    export async function searchFiles( query: string, include: string[], options: SearchOptions = {} ): Promise<SearchResultItem[]> { const { maxResults = 100, listOnly = false } = options; const files = await fg(include, { dot: false, ignore: ["**/node_modules/**", "**/.git/**", "**/dist/**"], unique: true, }); const results: SearchResultItem[] = []; for (const file of files) { if (listOnly) { results.push({ type: "text", text: file }); if (results.length >= maxResults) break; continue; } try { const content = await fs.readFile(file, "utf8"); if (!query || content.toLowerCase().includes(query.toLowerCase())) { const preview = content.slice(0, 2000); results.push({ type: "text", text: `# ${file}\n\n${preview}` }); } if (results.length >= maxResults) break; } catch { // ignore unreadable files } } return results; }

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/cloud-aspect/Config-MCP-Server'

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