xlsx-tools-mcp

v0.4.0
io.github.ruriazz/xlsx-tools-mcp Checked 6 hours ago Published 9 days ago

MCP server for accurate, structure-preserving read/write access to Excel (.xlsx) files

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

list_configured_files List preloaded files

List workbooks preloaded at startup (XLSX_MCP_FILES) as name -> absolute path. Call this first when unsure which file to use: any tool's `path` accepts these names.

list_sheets List sheets

List every sheet with its approximate row and column count. Fast. For exact dimensions, hidden state and defined names use get_workbook_info.

ParameterTypeDescription
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.

get_workbook_info Get workbook info

Get workbook metadata: exact dimensions and visibility of each sheet, active sheet, defined names. Slower than list_sheets on large files.

ParameterTypeDescription
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.

read_sheet Read sheet values

Return the raw cell values of a sheet or range. Formula cells give their last computed result. Best for small sheets or a known range. On large sheets, filter with query_sheet, summarize with aggregate_sheet, or inspect columns with profile_sheet instead. For a cell's formula text or style use get_cell.

ParameterTypeDescription
sheet *stringSheet name (case-sensitive).
cell_rangeRange to read, e.g. "A1:F500". Omit for the whole sheet.
formatstring"array": 2D list. "records": list of objects keyed by the first row. "markdown": table text.
max_rowsReturn at most this many rows. Omit for no limit.
offset_rowintegerSkip this many rows first (after the header row for records/markdown); use with max_rows to page.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.

get_cell Get cell details

Get everything about one cell: computed value, formula text, number format, font, fill, merge state, comment.

ParameterTypeDescription
cell *stringCell address, e.g. "C5".
sheet *stringSheet name (case-sensitive).
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.

search_workbook Search workbook

Find the cells whose value contains some text. Returns {sheet, cell, value} per match. Use to locate data when you don't know its address; to filter table rows by conditions use query_sheet.

ParameterTypeDescription
query *stringText to look for inside cell values (substring match).
limitReturn at most this many matches. Omit for no limit.
match_casebooleanMatch upper/lower case exactly.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
sheetSearch only this sheet. Omit to search all sheets.

profile_sheet Profile sheet columns

Summarize each column of a table-shaped sheet (first row = headers): type, empty count, min/max, sample values. Use first on an unfamiliar sheet to learn its column names before query_sheet or aggregate_sheet. Returns no cell data beyond the samples.

ParameterTypeDescription
sheet *stringSheet name (case-sensitive).
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
sample_rowsintegerExample values to show per column.

query_sheet Query sheet rows

Return only the rows of a table-shaped sheet (first row = headers) that match a condition. Returns {columns, records, row_count, limited}; row_count counts all matches. Use instead of read_sheet when you need a subset of a large table. For totals per group use aggregate_sheet.

ParameterTypeDescription
filter_query *stringCondition on header names, e.g. "Status == 'PAID' and Amount > 500". Allowed: comparisons, and/or/not, in, arithmetic. Header names must be valid identifiers (no spaces).
sheet *stringSheet name (case-sensitive).
cell_rangeRange to read, e.g. "A1:F500". Omit for the whole sheet.
columnsOnly return these columns. Omit for all.
max_rowsintegerReturn at most this many matching rows.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.

aggregate_sheet Aggregate sheet

Group rows and compute totals per group (e.g. sum of Amount by Region). Returns one record per group. Use for summaries of a table; to list individual matching rows use query_sheet.

ParameterTypeDescription
agg *objectHeader name -> function: sum, mean, min, max, count, median, nunique, first or last. E.g. {"Amount": "sum"}.
group_by *arrayHeader names to group by, e.g. ["Region"].
sheet *stringSheet name (case-sensitive).
cell_rangeRange to read, e.g. "A1:F500". Omit for the whole sheet.
has_headerbooleanFirst row holds column names. When false, columns are named col_0, col_1, ...
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.

create_workbook Create workbook

Create a new, empty workbook file.

ParameterTypeDescription
path *stringFile path for the new .xlsx or .xlsm file (preloaded names do not apply).
overwritebooleanReplace an existing file at path. Refused by default.
sheetsSheet names to create. Default: ["Sheet1"].

write_cells Write cells

Set values or formulas in cells at given addresses, overwriting what is there. To add new records below existing data without computing addresses use append_rows; to make room between rows use insert_rows.

ParameterTypeDescription
cells *arrayCells to set: [{"cell": "A1", "value": 100}, {"cell": "B1", "formula": "=A1*2"}]. Existing content is overwritten.
sheet *stringSheet name (case-sensitive).
allow_external_formulasbooleanAllow WEBSERVICE, HYPERLINK, INDIRECT, RTD, CALL, REGISTER and DDE ('|') in formulas.
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
create_sheet_if_missingbooleanCreate the sheet if missing.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).
recalculatebooleanRecompute formulas with LibreOffice after saving. False: faster, formula results stay empty.

append_rows Append rows

Add rows below the last used row of a sheet. Never overwrites existing cells. To change existing cells use write_cells.

ParameterTypeDescription
rows *arrayRows to add, each a list of values from column A, e.g. [["INV-3", 7, "=B5*2"]]. Strings starting with "=" become formulas.
sheet *stringSheet name (case-sensitive).
allow_external_formulasbooleanAllow WEBSERVICE, HYPERLINK, INDIRECT, RTD, CALL, REGISTER and DDE ('|') in formulas.
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
create_sheet_if_missingbooleanCreate the sheet if missing.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).
recalculatebooleanRecompute formulas with LibreOffice after saving. False: faster, formula results stay empty.

clear_range Clear range

Empty the cells in a range (values and/or formatting). Rows and columns stay in place. To remove rows or columns and shift the rest, use delete_rows or delete_columns.

ParameterTypeDescription
cell_range *stringA1-style range, e.g. "A1:D10".
sheet *stringSheet name (case-sensitive).
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
clear_stylesbooleanReset formatting to the Normal style.
clear_valuesbooleanRemove values and formulas.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).

recalculate_workbook Recalculate workbook

Recompute every formula with LibreOffice and report formula errors. Writes already do this. Needed only after writes with recalculate=false or after the file was edited outside this server.

ParameterTypeDescription
mode"inject": write only computed values, keep every other part. "roundtrip": replace the file with LibreOffice's export (may drop pivots, charts, validation). Default: XLSX_MCP_RECALC_MODE (inject).
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.

restore_backup Restore backup

Replace a workbook with one of its .bak backups, atomically.

ParameterTypeDescription
backup_path *stringThe .bak file to restore from (created by writes with backup enabled).
target_path *stringThe .xlsx/.xlsm workbook to overwrite.

create_sheet Create sheet

Add a new empty sheet. To duplicate an existing sheet use copy_sheet.

ParameterTypeDescription
sheet *stringName for the new sheet; must not exist yet.
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
indexZero-based position. Omit to add at the end.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).

copy_sheet Copy sheet

Duplicate a sheet with its values, formulas and styles, inside the same workbook.

ParameterTypeDescription
source_sheet *stringSheet to duplicate.
target_sheet *stringName for the copy (1-31 chars, must not exist yet).
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).

rename_sheet Rename sheet

Rename a sheet. Formulas in other sheets that use the old name are NOT updated and will break.

ParameterTypeDescription
new_name *stringNew sheet name (1-31 chars, none of \ / ? * : [ ]).
old_name *stringCurrent sheet name.
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).

delete_sheet Delete sheet

Delete a sheet and everything on it. Refused when it is the only sheet.

ParameterTypeDescription
sheet *stringSheet to delete.
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).

insert_rows Insert rows

Insert blank rows before start_row; rows below move down.

ParameterTypeDescription
sheet *stringSheet name (case-sensitive).
start_row *integer1-based row number.
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
countintegerHow many to insert or delete.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).
recalculatebooleanRecompute formulas with LibreOffice after saving. False: faster, formula results stay empty.

delete_rows Delete rows

Delete rows starting at start_row; rows below move up. To empty cells without shifting use clear_range.

ParameterTypeDescription
sheet *stringSheet name (case-sensitive).
start_row *integer1-based row number.
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
countintegerHow many to insert or delete.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).
recalculatebooleanRecompute formulas with LibreOffice after saving. False: faster, formula results stay empty.

insert_columns Insert columns

Insert blank columns before start_column; columns to the right move right.

ParameterTypeDescription
sheet *stringSheet name (case-sensitive).
start_column *integer1-based column number (A=1, B=2, ...).
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
countintegerHow many to insert or delete.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).
recalculatebooleanRecompute formulas with LibreOffice after saving. False: faster, formula results stay empty.

delete_columns Delete columns

Delete columns starting at start_column; columns to the right move left. To empty cells without shifting use clear_range.

ParameterTypeDescription
sheet *stringSheet name (case-sensitive).
start_column *integer1-based column number (A=1, B=2, ...).
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
countintegerHow many to insert or delete.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).
recalculatebooleanRecompute formulas with LibreOffice after saving. False: faster, formula results stay empty.

merge_cells Merge cells

Merge a rectangular range into one cell. Only the top-left value is kept.

ParameterTypeDescription
cell_range *stringA1-style range, e.g. "A1:D10".
sheet *stringSheet name (case-sensitive).
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).

unmerge_cells Unmerge cells

Split a merged range back into separate cells.

ParameterTypeDescription
cell_range *stringThe merged range exactly as merged, e.g. "A1:C1".
sheet *stringSheet name (case-sensitive).
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).

set_cell_style Set cell style

Apply font, fill, alignment, border or number format to every cell in a range. Values are not changed.

ParameterTypeDescription
cell_range *stringA1-style range, e.g. "A1:D10".
sheet *stringSheet name (case-sensitive).
style *objectAny of: bold, italic (bool); font_size (number); font_color, bg_color (hex RGB, e.g. "FF0000"); horizontal, vertical (alignment, e.g. "center"); border ("thin", "medium", "thick", ...); number_format…
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).

autofit_columns Autofit columns

Set each column's width to fit its longest value, within min_width..max_width.

ParameterTypeDescription
sheet *stringSheet name (case-sensitive).
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
max_widthintegerWidest width, in characters.
min_widthintegerNarrowest width, in characters.
paddingintegerCharacters added to the longest value.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).

create_table Create table

Turn a range into a formatted Excel Table (ListObject) with optional filter buttons.

ParameterTypeDescription
cell_range *stringRange including the header row, e.g. "A1:D10". Headers must be non-empty and unique.
sheet *stringSheet name (case-sensitive).
table_name *stringWorkbook-unique name: letters, digits, _ or ., starting with a letter or _.
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).
show_filterbooleanShow filter buttons in the header row.
show_row_stripesbooleanShade alternate rows.
style_namestringExcel table style, e.g. "TableStyleMedium9".

create_chart Create chart

Add a native Excel chart built from ranges on the same sheet.

ParameterTypeDescription
chart_type *stringChart kind: "bar", "line", "pie" or "scatter".
data_range *stringSeries values with the series name in the first row, e.g. "B1:B10".
sheet *stringSheet name (case-sensitive).
backupSave a .bak copy first. Default: XLSX_MCP_AUTO_BACKUP (true).
categories_rangeCategory labels, e.g. "A2:A10".
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
reasonWhy; kept in the change log (XLSX_MCP_CHANGE_LOG=true).
target_cellstringCell where the chart's top-left corner is placed.
titlestringChart title.

set_rules Set rules

Replace the workbook's rules and check them once; later value-changing writes are checked automatically. A write that makes a passing rule fail (or a failing one worse) is rolled back; rules already failing never block. Stored as "<file>.rules.json". Each rule has an "id" plus one of: {"type": "cells_equal", "left": "S!B40", "right": "S!C40", "tolerance": 0.01} {"type": "cell_compare", "cell": "S!D4", "op": "<=", "value": 1000} (or "cell_ref") {"type": "column_check", "sheet": "Data", "expr": "Qty >= 0", "cell_range": "A1:F500"} {"type": "column_unique", "sheet": "Data", "column": "I…

ParameterTypeDescription
rules *arrayRule objects, each with a unique id and a type (see tool description). An empty list removes all rules.
on_unverifiablestringWhat to do when a rule cannot be checked (e.g. LibreOffice missing): "warn" or "rollback".
on_violationstring"rollback": undo a write that breaks a rule. "warn": keep it and report.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.

check_rules Check rules

Check the workbook's rules (from set_rules) against its current values without writing.

ParameterTypeDescription
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.

export_review_copy Export review copy

Write a copy for a human reviewer: cells changed since a baseline are highlighted with a Before/After comment. A `_Changes` sheet lists every change with a link. The workbook itself is not modified.

ParameterTypeDescription
baseline_pathWorkbook to compare against. Default: this file's newest .bak backup.
highlight_colorstringHex RGB fill for changed cells.
include_recalc_changesbooleanAlso mark formulas whose text is the same but whose result changed.
max_annotated_cellsintegerHighlight at most this many cells; all changes are still listed in _Changes.
output_pathWhere to write the copy. Default: "<name>.review.xlsx" next to the file.
overwritebooleanReplace an existing output file.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.

inspect_for_sharing Inspect for sharing

Report hidden or sensitive content to review before sharing a workbook. Covers hidden sheets, rows and columns, comments, document properties, external links, pivot caches, invisible text, embedded objects, macros, custom XML and the change log. Each finding says whether sanitize_copy can remove it.

ParameterTypeDescription
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.

sanitize_copy Sanitize copy

Write a cleaned copy of the workbook for sharing (run inspect_for_sharing first). The source is not modified.

ParameterTypeDescription
output_path *stringPath for the cleaned copy; must differ from the source.
overwritebooleanReplace an existing output file.
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
removeWhat to strip. Default: comments, document_properties, change_log. Hidden sheets are removed only when nothing refers to them; external links become their cached values.

get_change_log Get change log

Read the change log stored inside the workbook, newest first: time, tool, cell, before/after, reason. Entries exist only for writes made while XLSX_MCP_CHANGE_LOG=true.

ParameterTypeDescription
cellOnly entries for this cell, including ranges that contain it.
limitintegerMaximum entries (1-1000).
pathFile path or preloaded name (list_configured_files). Omit if only one file is preloaded.
sheetOnly entries for this sheet.