Skip to main content
Glama

search_documentation

Search cached documentation for GitHub repositories to find relevant information using specific queries.

Instructions

Search within cached documentation for a repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYesRepository owner/organization
repoYesRepository name
queryYesSearch query within the documentation

Implementation Reference

  • src/server.ts:78-99 (registration)
    Registers the 'search_documentation' tool in the ListTools handler, including name, description, and input schema.
    { name: 'search_documentation', description: 'Search within cached documentation for a repository', inputSchema: { type: 'object', properties: { owner: { type: 'string', description: 'Repository owner/organization', }, repo: { type: 'string', description: 'Repository name', }, query: { type: 'string', description: 'Search query within the documentation', }, }, required: ['owner', 'repo', 'query'], }, },
  • MCP CallTool handler for 'search_documentation': validates input arguments, invokes CodeWikiClient.searchDocumentation, and returns JSON-formatted results.
    case 'search_documentation': { const { owner, repo, query } = args as any; if (!owner || !repo || !query) { throw new Error('Owner, repo, and query are required'); } const results = await codeWikiClient.searchDocumentation(owner, repo, query); return { content: [ { type: 'text', text: JSON.stringify(results, null, 2), }, ], }; }
  • Core implementation of search logic: retrieves documentation (from cache or fetches), performs keyword search across sections and subsections, computes relevance scores, sorts results, and returns top 10 matches.
    async searchDocumentation(owner: string, repo: string, query: string): Promise<{ repository: RepositoryInfo; results: Array<{ section: string; content: string; relevance: number }>; query: string; }> { const docs = await this.getRepositoryDocs(owner, repo); const results: Array<{ section: string; content: string; relevance: number }> = []; // Simple text search through sections for (const section of docs.sections) { const content = `${section.title} ${section.content}`.toLowerCase(); const queryLower = query.toLowerCase(); if (content.includes(queryLower)) { // Calculate simple relevance score const titleMatches = section.title.toLowerCase().includes(queryLower) ? 2 : 0; const contentMatches = (section.content.toLowerCase().match(new RegExp(queryLower, 'g')) || []).length; const relevance = titleMatches + contentMatches; results.push({ section: section.title, content: section.content.substring(0, 500) + (section.content.length > 500 ? '...' : ''), relevance, }); } // Search subsections if (section.subsections) { for (const subsection of section.subsections) { const subContent = `${subsection.title} ${subsection.content}`.toLowerCase(); if (subContent.includes(queryLower)) { const titleMatches = subsection.title.toLowerCase().includes(queryLower) ? 2 : 0; const contentMatches = (subsection.content.toLowerCase().match(new RegExp(queryLower, 'g')) || []).length; const relevance = titleMatches + contentMatches; results.push({ section: `${section.title} > ${subsection.title}`, content: subsection.content.substring(0, 500) + (subsection.content.length > 500 ? '...' : ''), relevance, }); } } } } // Sort by relevance results.sort((a, b) => b.relevance - a.relevance); return { repository: docs.repository, results: results.slice(0, 10), // Return top 10 results query, }; }

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/cbuntingde/codewiki-mcp-server'

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