Skip to main content
Glama

grep_docs

Search documents using regex patterns with case-insensitive options enabled by default. Integrates with the Docs-MCP server for efficient document retrieval and analysis.

Instructions

ドキュメント内をgrepで検索

Args:
    pattern: 検索パターン(正規表現対応)
    ignore_case: 大文字小文字を無視するか(デフォルト: True)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ignore_caseNo
patternYes

Implementation Reference

  • MCP tool handler for 'grep_docs'. Registers the tool via @mcp.tool() decorator and delegates execution to DocumentManager.grep_search method.
    @mcp.tool()
    async def grep_docs(pattern: str, ignore_case: bool = True) -> str:
        """ドキュメント内をgrepで検索
    
        Args:
            pattern: 検索パターン(正規表現対応)
            ignore_case: 大文字小文字を無視するか(デフォルト: True)
        """
        return doc_manager.grep_search(pattern, ignore_case)
  • Core implementation of the grep search functionality. Compiles the regex pattern, searches all loaded documents line-by-line, collects matches with file path and line number, limits to 100 results, and formats the output.
    def grep_search(self, pattern: str, ignore_case: bool = True) -> str:
        """正規表現でドキュメントを検索"""
        try:
            flags = re.IGNORECASE if ignore_case else 0
            regex = re.compile(pattern, flags)
        except re.error as e:
            return f"Error: Invalid regex pattern: {e}"
    
        results = []
        for doc_path, content in sorted(self.docs_content.items()):
            lines = content.split("\n")
            for i, line in enumerate(lines, 1):
                if regex.search(line):
                    line_preview = line.strip()
                    if len(line_preview) > 120:
                        line_preview = line_preview[:117] + "..."
                    results.append(f"{doc_path}:{i}: {line_preview}")
    
        if not results:
            return "No matches found"
    
        # 結果が多すぎる場合は制限
        if len(results) > 100:
            total = len(results)
            results = results[:100]
            results.append(f"\n... and {total - 100} more matches")
    
        return "\n".join(results)
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. It mentions regex support and case-insensitivity, but doesn't disclose critical behaviors like whether it searches all documents or specific ones, output format, error handling, or performance implications. For a search tool with zero annotation coverage, this leaves significant gaps.

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

Conciseness4/5

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

The description is concise and well-structured: a clear purpose statement followed by parameter explanations. Every sentence adds value, though it could be more front-loaded with key usage details. No wasted text.

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 tool with no annotations, no output schema, and 2 parameters, the description is incomplete. It lacks information on what documents are searched, output format, error cases, and how results are returned. More context is needed for effective use.

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

Parameters4/5

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

The description adds meaningful semantics beyond the schema: it explains that 'pattern' supports regex and 'ignore_case' has a default of True. With 0% schema description coverage, this compensates well for both parameters, though it doesn't detail regex syntax or scope limitations.

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 tool's purpose: 'ドキュメント内をgrepで検索' (search within documents using grep). It specifies the verb (grep/search) and resource (documents), though it doesn't explicitly differentiate from sibling tools like 'semantic_search' or 'get_doc'. The purpose is clear but lacks sibling distinction.

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 'semantic_search' or 'list_docs'. It doesn't mention prerequisites, context, or exclusions. Usage is implied by the purpose but not explicitly stated.

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

Related 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/herring101/docs-mcp'

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