Skip to main content
Glama

search_docs

Search across Laravel documentation files to find specific content and code examples for development tasks.

Instructions

Search for content across all documentation files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query

Implementation Reference

  • Complete implementation of the search_docs tool: registration, input schema definition, and the handler function that searches for content across all documentation files. The handler reads all markdown files, performs case-insensitive line-by-line search, limits results to 50 matches, and returns JSON with query, match count, and results array containing file path, line number, and matching content.
    // Register tool: Search documentation
    server.registerTool(
      'search_docs',
      {
        description: 'Search for content across all documentation files',
        inputSchema: {
          query: z.string().describe('Search query'),
        },
      },
      async ({ query }) => {
        const files = getDocFiles(DOCS_PATH);
        const queryLower = query.toLowerCase();
        const results = [];
    
        for (const file of files) {
          const content = fs.readFileSync(file.full_path, 'utf-8');
          const lines = content.split('\n');
    
          lines.forEach((line, index) => {
            if (line.toLowerCase().includes(queryLower)) {
              results.push({
                file: file.path,
                line: index + 1,
                content: line.trim(),
              });
            }
          });
    
          if (results.length >= 50) break;
        }
    
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              query,
              matches: results.length,
              results: results.slice(0, 50),
            }, null, 2),
          }],
        };
      }
    );
  • Input schema for search_docs tool: defines the 'query' parameter as a required string using zod validation.
    inputSchema: {
      query: z.string().describe('Search query'),
    },
  • Helper function getDocFiles() recursively scans the documentation directory for all markdown files, skipping hidden directories and node_modules. Returns array of objects with file metadata including relative path, full path, and filename. Used by search_docs to get files to search through.
    // Helper function to get all markdown files recursively
    function getDocFiles(dir, basePath = dir) {
      const files = [];
    
      if (!fs.existsSync(dir)) {
        return files;
      }
    
      const entries = fs.readdirSync(dir, { withFileTypes: true });
    
      for (const entry of entries) {
        const fullPath = path.join(dir, entry.name);
        const relativePath = path.relative(basePath, fullPath);
    
        if (entry.isDirectory()) {
          // Skip node_modules and hidden directories
          if (!entry.name.startsWith('.') && entry.name !== 'node_modules') {
            files.push(...getDocFiles(fullPath, basePath));
          }
        } else if (entry.name.endsWith('.md')) {
          files.push({
            path: relativePath,
            full_path: fullPath,
            name: entry.name,
          });
        }
      }
    
      return files;
    }
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. It states what the tool does but lacks critical details: it doesn't specify the search scope (e.g., full-text, metadata), result format, pagination, or any limitations (e.g., rate limits, authentication needs). This leaves significant gaps for an agent to understand how the tool behaves.

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, clear sentence with zero wasted words. It's front-loaded with the core action ('search') and resource, making it highly efficient and easy to parse at a glance.

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 lack of annotations and output schema, the description is incomplete for a search tool. It doesn't explain what the search returns (e.g., list of documents, snippets), how results are ordered, or any behavioral traits like error handling. This makes it inadequate for an agent to fully understand the tool's context and usage.

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%, with the single parameter 'query' fully documented in the schema. The description adds no additional meaning beyond implying a search operation, which aligns with the schema but doesn't provide extra context like query syntax or examples. This meets the baseline for high schema coverage.

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 verb ('search') and resource ('content across all documentation files'), making the purpose immediately understandable. However, it doesn't distinguish this tool from sibling tools like 'read_doc' or 'get_doc_structure' beyond the general search functionality, which prevents a perfect 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. With sibling tools like 'read_doc' (likely for reading specific documents) and 'get_doc_structure' (likely for structural information), there's no indication of when searching is preferred over direct retrieval or structural queries.

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/pujandan/mcp-laravel'

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