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,
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'cached documentation', implying a read-only operation, but doesn't specify aspects like search scope (e.g., full-text, titles only), performance, rate limits, or error handling. This leaves significant gaps for a search tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It's front-loaded and wastes no space, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a search operation with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., search behavior, caching implications) and output expectations, which are crucial for effective tool use in this context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, clearly documenting the three required parameters. The description adds no additional meaning beyond the schema (e.g., it doesn't explain how 'query' is processed or what 'owner' and 'repo' refer to), so it meets the baseline but doesn't enhance understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Search within cached documentation') and the resource ('for a repository'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'search_repository' or 'get_repository_docs', which likely have overlapping domains, so it misses the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search_repository' or 'get_repository_docs'. It mentions 'cached documentation' but doesn't clarify prerequisites (e.g., if docs must be pre-cached) or exclusions, leaving usage context vague.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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