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.

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

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