Skip to main content
Glama

search

Find cells containing specific values in Excel or CSV files to locate data quickly. Use exact or partial matching across sheets for efficient data analysis.

Instructions

Search for cells containing a specific value

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the CSV or Excel file
searchValueYesValue to search for
exactNoWhether to match exactly or contains (default: false)
sheetNoSheet name for Excel files (optional)

Implementation Reference

  • The handler function that implements the core logic of the 'search' tool. It reads the file content, iterates through all cells, checks for exact or partial matches against the searchValue, and returns a list of matching cells with their positions.
    async search(args: ToolArgs): Promise<ToolResponse> { try { const { filePath, searchValue, exact = false, sheet } = args; const data = await readFileContent(filePath, sheet); const matches = []; for (let row = 0; row < data.length; row++) { for (let col = 0; col < (data[row]?.length || 0); col++) { const cellValue = String(data[row][col]); const isMatch = exact ? cellValue === searchValue : cellValue.toLowerCase().includes(searchValue.toLowerCase()); if (isMatch) { const colLetter = String.fromCharCode(65 + (col % 26)); matches.push({ cell: `${colLetter}${row + 1}`, value: data[row][col], row: row + 1, column: col + 1, }); } } } return { content: [ { type: 'text', text: JSON.stringify({ success: true, searchValue, found: matches.length, matches, }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ success: false, error: error instanceof Error ? error.message : 'Unknown error occurred', }, null, 2), }, ], }; } }
  • The input schema definition for the 'search' tool in the ListTools response, specifying the parameters, types, descriptions, and required fields.
    name: 'search', description: 'Search for cells containing a specific value', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'Path to the CSV or Excel file', }, searchValue: { type: 'string', description: 'Value to search for', }, exact: { type: 'boolean', description: 'Whether to match exactly or contains (default: false)', }, sheet: { type: 'string', description: 'Sheet name for Excel files (optional)', }, }, required: ['filePath', 'searchValue'], }, },
  • src/index.ts:1207-1208 (registration)
    The dispatch registration in the CallToolRequestSchema handler's switch statement, mapping the tool name 'search' to the DataOperationsHandler.search method.
    case 'search': return await this.dataOpsHandler.search(toolArgs);

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/ishayoyo/excel-mcp'

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