Skip to main content
Glama

search_docs

Search documentation by query to find relevant information, with options to filter by document category and control result quantity.

Instructions

Search documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
max_resultsNoMaximum number of results
doc_nameNoFilter by document category
offsetNoNumber of results to skip

Implementation Reference

  • MCP tool handler for 'search_docs': extracts query parameters, calls SearchEngine.search(), and formats results as text content blocks.
    case "search_docs": {
      const query = String(request.params.arguments?.query);
      const maxResults = Number(request.params.arguments?.max_results) || 3;
      const docName = request.params.arguments?.doc_name ?
        String(request.params.arguments.doc_name) : undefined;
      const offset = Number(request.params.arguments?.offset) || 0;
      const results = await searchEngine.search(query, maxResults, docName, 0.2, offset);
      return {
        content: results.map(result => ({
          type: "text",
          text: `[${result.score.toFixed(2)}] ${result.title}\n${result.excerpt}\n---`
        }))
      };
    }
  • src/index.ts:461-488 (registration)
    Registers the 'search_docs' tool in ListToolsRequestSchema response, including name, description, and input schema definition.
    {
      name: "search_docs",
      description: "Search documentation",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Search query"
          },
          max_results: {
            type: "number",
            description: "Maximum number of results",
            default: 3
          },
          doc_name: {
            type: "string",
            description: "Filter by document category"
          },
          offset: {
            type: "number",
            description: "Number of results to skip",
            default: 0
          }
        },
        required: ["query"]
      }
    },
  • SearchEngine.search(): Performs full-text search using Lunr index, applies filters for docName and minimum score, paginates results, and generates highlighted excerpts.
    async search(query: string, maxResults = 3, docName?: string, minScore = 0.2, offset = 0) {
      if (!this.index) {
        throw new Error('Index not initialized');
      }
    
      let results = this.index.search(query);
      
      // 按文档分类筛选
      if (docName) {
        results = results.filter(result => {
          const doc = this.docStore[result.ref];
          return doc.title.startsWith(`${docName}/`);
        });
      }
    
      // 按分数筛选
      results = results.filter(result => result.score >= minScore);
    
      return results.slice(offset, offset + maxResults).map(result => {
        const doc = this.docStore[result.ref];
        return {
          path: doc.path,
          score: result.score,
          title: doc.title,
          excerpt: this.createExcerpt(doc.content, query)
        };
      });
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Search documentation' implies a read-only operation but doesn't specify permissions, rate limits, pagination behavior, or what the search covers (e.g., full-text, titles only). It lacks details on return format or error handling, leaving significant gaps for a tool with no annotation support.

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 extremely concise with just two words, 'Search documentation,' which is front-loaded and wastes no space. It efficiently conveys the core function without unnecessary elaboration, making it easy to scan and understand quickly.

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 tool's complexity (4 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain what the search returns, how results are ordered, or any behavioral traits. For a search tool with multiple parameters and siblings, more context is needed to guide effective use, especially without annotations or output schema to fill in gaps.

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?

Schema description coverage is 100%, so the schema fully documents all four parameters (query, max_results, doc_name, offset) with descriptions and defaults. The description adds no additional meaning beyond what's in the schema, such as examples or usage tips. This meets the baseline for high schema coverage but doesn't enhance parameter understanding.

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

Purpose3/5

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

The description 'Search documentation' states the basic action (search) and resource (documentation), which is clear but vague. It doesn't specify what kind of documentation or differentiate from siblings like list_all_docs or list_enabled_docs. The purpose is understandable but lacks specificity about scope or format.

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. With siblings like list_all_docs and list_enabled_docs available, there's no indication that this tool is for searching content rather than listing metadata, or when to prefer it over other tools. No context or exclusions are mentioned.

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/askme765cs/open-docs-mcp'

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