Skip to main content
Glama

grep_docs

Search documents using grep with regular expression patterns. Optionally ignore case to broaden results.

Instructions

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

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYes
ignore_caseNo

Implementation Reference

  • MCP tool handler for grep_docs: accepts a regex pattern and ignore_case flag, delegates to DocumentManager.grep_search()
    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)
  • Registration of grep_docs as an MCP tool via FastMCP's @mcp.tool() decorator
    @mcp.tool()
    async def grep_docs(pattern: str, ignore_case: bool = True) -> str:
  • Helper method grep_search in DocumentManager: performs regex search across all loaded documents, returns formatted results with file:line:preview format, limited to 100 results
    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)
  • Type annotations define the input schema: pattern (str) is required, ignore_case (bool, default True) is optional. Returns a string.
    async def grep_docs(pattern: str, ignore_case: bool = True) -> str:
        """ドキュメント内をgrepで検索
    
        Args:
            pattern: 検索パターン(正規表現対応)
            ignore_case: 大文字小文字を無視するか(デフォルト: True)
        """
Behavior3/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 discloses the search behavior, regex support, and case sensitivity option, but does not mention return format or any side effects. Adequate but not rich.

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?

Very concise: two sentences for purpose and an Args list for parameters. No wasted words, front-loaded with the main action.

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

Completeness4/5

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

For a simple two-parameter tool with no output schema, the description covers the essential behavior and parameter meanings. Could optionally mention what is returned, but not a major gap.

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?

Schema coverage is 0%, but the description adds meaningful explanations: pattern is 'search pattern (regex supported)' and ignore_case is 'whether to ignore case (default: True)'. This goes beyond the schema's type/default fields.

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

Purpose5/5

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

The description clearly states 'Search inside documents using grep' and mentions regex support. It contrasts with sibling tools like get_doc, list_docs, and semantic_search by specifying a regex-based search.

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?

No guidance on when to use this tool versus alternatives like semantic_search. No exclusion criteria or prerequisites are provided.

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

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