mcp-server-spreadsheet

v0.3.3
io.github.marekrost/mcp-server-spreadsheet Checked 18 hours ago Published 3 months ago

MCP server for spreadsheet files (.xlsx, .csv, .ods) - cell-level ops + DuckDB SQL engine.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_workbooks

List all spreadsheet files (.xlsx, .csv, .ods) in a directory (non-recursive). Returns the full path of each file found, sorted alphabetically.

ParameterTypeDescription
directory *stringAbsolute or relative path to the directory to scan

create_workbook_file

Create a new empty spreadsheet file at the given path. The file format is determined by the extension (.xlsx, .csv, or .ods). The file must not already exist. Returns the absolute path of the created file.

ParameterTypeDescription
file *stringPath where the new file will be created (.csv, .ods, .xlsx). Must not already exist.
sheet_nameName for the initial sheet. Defaults to 'Sheet' for xlsx/ods, 'default' for csv.

copy_workbook

Copy an existing spreadsheet file to a new location. Performs a full file copy preserving all data. The destination must not already exist. Returns the absolute path of the new file.

ParameterTypeDescription
destination *stringPath for the new copy. Must not already exist.
source *stringPath to the existing spreadsheet file to copy

list_sheets

List all sheet names in a workbook, in workbook order. Returns a list of sheet name strings. CSV files always return a single sheet named 'default'.

ParameterTypeDescription
file *stringPath to the spreadsheet file

add_sheet

Add a new sheet to the workbook. Returns the name of the newly created sheet. Not supported for CSV files.

ParameterTypeDescription
file *stringPath to the spreadsheet file
nameName for the new sheet. Auto-generated if omitted.
position1-based position to insert the sheet. Appended at the end if omitted.

rename_sheet

Rename an existing sheet in the workbook. Returns the new sheet name on success.

ParameterTypeDescription
file *stringPath to the spreadsheet file
new_name *stringNew name for the sheet
old_name *stringCurrent name of the sheet to rename

delete_sheet

Delete a sheet by name from the workbook. All data in the sheet is permanently removed. Not supported for CSV files.

ParameterTypeDescription
file *stringPath to the spreadsheet file
name *stringName of the sheet to delete

copy_sheet

Duplicate a sheet within the same workbook. Copies all cell values. Returns the name of the new sheet. Not supported for CSV files.

ParameterTypeDescription
file *stringPath to the spreadsheet file
source_name *stringName of the existing sheet to duplicate
new_nameName for the copy. Auto-generated if omitted.
position1-based position for the copied sheet. Placed at the end if omitted.

read_sheet

Read an entire sheet (or a bounded sub-region) as a list of rows. Each row is a list of cell values. Empty cells appear as null. Use the optional row/column bounds to limit output for large sheets.

ParameterTypeDescription
file *stringPath to the spreadsheet file
end_columnLast column to include (1-based). Defaults to the last used column.
end_rowLast row to include (1-based). Defaults to the last used row.
sheetSheet name. Defaults to the first sheet if omitted.
start_columnFirst column to include (1-based, e.g. 1 = A). Defaults to the first used column.
start_rowFirst row to include (1-based). Defaults to the first used row.

read_cell

Read the value of a single cell. Returns the cell's value: numbers as int/float, text as string, and empty cells as null.

ParameterTypeDescription
cell *stringCell reference in A1 notation, e.g. 'B3' or '$B$3'
file *stringPath to the spreadsheet file
sheetSheet name. Defaults to the first sheet if omitted.

read_range

Read a rectangular range of cells as a list of rows. Returns a 2D array where each inner list is one row of values. Empty cells return null.

ParameterTypeDescription
file *stringPath to the spreadsheet file
range_str *stringCell range in A1 notation, e.g. 'A1:D10' or '$A$1:$D$10'
sheetSheet name. Defaults to the first sheet if omitted.

get_sheet_dimensions

Get the dimensions of the used range in a sheet. Returns {"rows": N, "columns": M} where N is the number of the last used row and M is the number of the last used column. Both are 0 for an empty sheet.

ParameterTypeDescription
file *stringPath to the spreadsheet file
sheetSheet name. Defaults to the first sheet if omitted.

write_cell

Write a single value to a cell. Overwrites any existing value. The value is type-coerced: numeric strings become numbers, all else is text.

ParameterTypeDescription
cell *stringTarget cell in A1 notation, e.g. 'B3'
file *stringPath to the spreadsheet file
value *Value to write. Numeric strings are coerced to numbers, everything else is stored as text.
sheetSheet name. Defaults to the first sheet if omitted.

write_range

Write a 2D array of values into a rectangular region. Writing starts at start_cell and expands right and down to fit the data. Prefer this over multiple write_cell calls for efficiency.

ParameterTypeDescription
data *array2D array of values (list of rows), e.g. [[1, 2, 3], ['a', 'b', 'c']]. Numeric strings are coerced to numbers.
file *stringPath to the spreadsheet file
start_cell *stringTop-left cell where writing begins, e.g. 'B2'
sheetSheet name. Defaults to the first sheet if omitted.

append_rows

Append one or more rows after the last used row in the sheet. Values are type-coerced (numeric strings to numbers). This is the most efficient way to add data to the end of a sheet.

ParameterTypeDescription
data *arrayList of rows to append, e.g. [['Alice', 30], ['Bob', 25]]. Each inner list is one row.
file *stringPath to the spreadsheet file
sheetSheet name. Defaults to the first sheet if omitted.

insert_rows

Insert rows at a given position, shifting existing rows down. If data is provided, the inserted rows are filled with those values (type-coerced). Otherwise the rows are left blank.

ParameterTypeDescription
file *stringPath to the spreadsheet file
row *integer1-based row index where new rows will be inserted. Existing rows at and below this index shift down.
countintegerNumber of rows to insert. If data is provided and longer, enough rows are inserted to fit the data.
dataOptional 2D array of values to fill the inserted rows. Leave empty for blank rows.
sheetSheet name. Defaults to the first sheet if omitted.

delete_rows

Delete one or more rows, shifting remaining rows up. All data in the deleted rows is permanently removed.

ParameterTypeDescription
file *stringPath to the spreadsheet file
row *integer1-based index of the first row to delete
countintegerNumber of consecutive rows to delete starting from row
sheetSheet name. Defaults to the first sheet if omitted.

clear_range

Clear all cell values in a range without removing rows or columns. Sets every cell in the range to null. Row/column structure is preserved.

ParameterTypeDescription
file *stringPath to the spreadsheet file
range_str *stringRange to clear in A1 notation, e.g. 'A1:D10'. Only values are removed.
sheetSheet name. Defaults to the first sheet if omitted.

copy_range

Copy a rectangular block of cells to another location. Copies raw values only. The destination can be on the same sheet or a different sheet in the same workbook. Existing values at the destination are overwritten.

ParameterTypeDescription
dest_start *stringTop-left cell of the destination, e.g. 'E1'. The copied block expands right and down from here.
file *stringPath to the spreadsheet file
source_range *stringRange to copy from in A1 notation, e.g. 'A1:C5'
dest_sheetDestination sheet name. Defaults to the same sheet as the source if omitted.
sheetSource sheet name. Defaults to the first sheet if omitted.

insert_columns

Insert one or more blank columns, shifting existing columns right.

ParameterTypeDescription
column *integer1-based column index where new columns will be inserted (e.g. 1 = A, 2 = B). Existing columns at and to the right shift right.
file *stringPath to the spreadsheet file
countintegerNumber of blank columns to insert
sheetSheet name. Defaults to the first sheet if omitted.

delete_columns

Delete one or more columns, shifting remaining columns left.

ParameterTypeDescription
column *integer1-based index of the first column to delete (e.g. 1 = A, 2 = B)
file *stringPath to the spreadsheet file
countintegerNumber of consecutive columns to delete starting from column
sheetSheet name. Defaults to the first sheet if omitted.

search_sheet

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.

ParameterTypeDescription
file *stringPath to the spreadsheet file
pattern *stringRegular expression pattern to search for. Matched against the string representation of each cell value.
sheetSheet name. Defaults to the first sheet if omitted.

describe_table

Inspect the structure of a sheet treated as a database table. Returns column names, inferred data types (text, integer, number, boolean, date), total row count, and sample values from the first 3 data rows. Use this before writing SQL queries to understand the available columns and their types. When sheet is omitted, returns a list of descriptions for all sheets.

ParameterTypeDescription
file *stringPath to the spreadsheet file
data_start_row1-based row where data begins. Use this to skip rows (e.g. a units row) between the header and data. Int or per-sheet mapping. Defaults to header_row + 1.
header_row1-based row number containing column headers, or a per-sheet mapping like {"Sales": 1, "Forecast": 4}. Sheets not listed default to 1.
sheetSheet name to describe. If omitted, describes all sheets in the workbook.

sql_query

Execute a read-only SQL SELECT query against the spreadsheet data. Every sheet in the workbook is loaded as a database table, with the header row defining column names and data rows below it. Returns results as a list of {column: value} objects. Only SELECT (and WITH ... SELECT) statements are accepted. Use sql_execute for INSERT, UPDATE, or DELETE.

ParameterTypeDescription
file *stringPath to the spreadsheet file
sql *stringSQL SELECT statement to execute. Each sheet is a table (quote names with double quotes if they contain spaces). Supports WHERE, ORDER BY, LIMIT, GROUP BY, HAVING, JOINs across sheets, DISTINCT, UNION,…
data_start_row1-based row where data begins. Use this to skip rows (e.g. a units row) between the header and data. Int or per-sheet mapping. Defaults to header_row + 1.
header_row1-based row number containing column headers, or a per-sheet mapping like {"Sales": 1, "Forecast": 4}. Sheets not listed default to 1.

sql_execute

Execute a mutating SQL statement and write changes back to the file. Supports INSERT INTO (adds rows), UPDATE (modifies cell values), and DELETE FROM (removes rows). The target sheet is determined from the SQL statement. After execution, the modified table is written back to the file atomically. Returns {"affected_rows": N}.

ParameterTypeDescription
file *stringPath to the spreadsheet file
sql *stringSQL mutation statement to execute: INSERT INTO, UPDATE, or DELETE FROM. Sheet names are table names. Example: UPDATE Sales SET status = 'Closed' WHERE quarter = 'Q1' AND revenue < 1000
data_start_row1-based row where data begins. Use this to skip rows (e.g. a units row) between the header and data. Int or per-sheet mapping. Defaults to header_row + 1.
header_row1-based row number containing column headers, or a per-sheet mapping like {"Sales": 1, "Forecast": 4}. Sheets not listed default to 1.