Skip to main content
Glama
marekrost

mcp-server-spreadsheet

search_sheet

Search spreadsheet cells for values matching a regex pattern to find specific data across sheets and return matches with cell references.

Instructions

Search all cells in a sheet for values matching a regex pattern.

Returns a list of matches, each with the cell reference and value, e.g. [{"cell": "B3", "value": "hello"}, ...]. Returns an empty list if no matches are found.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesPath to the spreadsheet file
patternYesRegular expression pattern to search for. Matched against the string representation of each cell value.
sheetNoSheet name. Defaults to the first sheet if omitted.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The implementation of the search_sheet tool, which searches for a regex pattern within a spreadsheet and returns matching cell references and values.
    def search_sheet(
        file: Annotated[str, Field(description="Path to the spreadsheet file")],
        pattern: Annotated[str, Field(description="Regular expression pattern to search for. Matched against the string representation of each cell value.")],
        sheet: Annotated[str | None, Field(description="Sheet name. Defaults to the first sheet if omitted.")] = None,
    ) -> list[dict]:
        """Search all cells in a sheet for values matching a regex pattern.
    
        Returns a list of matches, each with the cell reference and value,
        e.g. [{"cell": "B3", "value": "hello"}, ...]. Returns an empty list
        if no matches are found.
        """
        wb = load_workbook(file)
        ws = _resolve_sheet(wb, sheet)
        regex = re.compile(pattern)
        results = []
        for r in range(1, ws.max_row + 1):
            for c in range(1, ws.max_column + 1):
                val = ws.cell_value(r, c)
                if val is None:
                    continue
                if regex.search(str(val)):
                    results.append({
                        "cell": f"{get_column_letter(c)}{r}",
                        "value": val,
                    })
        return results
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it returns a list of matches with cell references and values, returns an empty list for no matches, and searches all cells (implying comprehensive scanning). However, it does not mention performance implications, rate limits, or authentication needs, leaving some gaps.

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 front-loaded with the core purpose in the first sentence, followed by concise details on return format and edge cases. Every sentence adds value without redundancy, making it efficient and well-structured for quick comprehension.

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

Completeness5/5

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

Given the tool's moderate complexity, 100% schema coverage, and presence of an output schema (implied by return format details), the description is complete enough. It covers purpose, behavior, and output, addressing key aspects without needing to reiterate schema details or explain return values extensively.

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 already documents all parameters (file, pattern, sheet) thoroughly. The description does not add meaning beyond the schema, such as regex syntax details or file format constraints. Baseline 3 is appropriate as the schema does the heavy lifting.

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 the specific action ('search all cells'), target resource ('in a sheet'), and method ('for values matching a regex pattern'), distinguishing it from sibling tools like read_cell, read_range, or read_sheet which retrieve data without pattern matching. It precisely defines the tool's function without ambiguity.

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

Usage Guidelines3/5

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

The description implies usage for regex-based searches across entire sheets, but does not explicitly state when to use this tool versus alternatives like read_sheet (for full data retrieval) or sql_query (for structured queries). It provides context but lacks explicit guidance on exclusions or comparisons with sibling tools.

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/marekrost/mcp-server-spreadsheet'

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