Excel MCP
Enables GitHub Copilot to read, write, and manage Excel workbooks (xlsx/xlsm) programmatically.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Excel MCP Open my budget.xlsx and show me the expenses sheet"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Excel MCP
An MCP (Model Context Protocol) server that lets AI clients — Claude Code, GitHub Copilot CLI, VS Code Copilot, or any MCP-capable agent — read, write, and manage Excel workbooks (.xlsx / .xlsm).
No Excel installation required: workbooks are manipulated directly via openpyxl.
How it works
The server is stateful: open a workbook once, make many edits against the in-memory copy, then save.
open_workbook(path) -> session_id
write_range(session_id, "A1", [["Name","Age"],["Ana",31]])
read_range(session_id, "Sheet1!A1:B10")
save_workbook(session_id)
close_workbook(session_id)Ranges use A1 notation, optionally sheet-qualified: A1, A1:C10, Sheet1!A1:C10, 'My Sheet'!A1:C10.
Related MCP server: Excel MCP Server
Tools
Group | Tools |
Workbook |
|
Sheets |
|
Data |
|
Structure |
|
Search |
|
Formatting |
|
Formulas |
|
Analysis |
|
Charts |
|
Annotations |
|
Transfer |
|
Images |
|
Protection |
|
Calculation |
|
Live Excel |
|
Formatting highlights: colors accept hex (#FF0000) or names (red, light_blue, dark_blue, ...); number formats accept aliases (currency, percent, date, ...) or raw Excel codes; format_as_table applies native Excel table styles; apply_conditional_formatting supports color scales, data bars, cell-value rules, and formula rules; apply_style_preset styles common patterns (header, zebra, title, total_row, highlight) in one call.
Formulas & analysis highlights: fill_formula adjusts relative references across a range like Excel's fill handle; add_data_validation builds dropdowns and numeric/date/length rules; sort_range and remove_duplicates match Excel's ordering and case-insensitive comparison.
Charts: bar, horizontal bar, line, pie, scatter, and area charts with titles, axis labels, and positioning anywhere in the workbook.
Annotations & transfer: cell comments with authors; external and internal (#Sheet2!A1) hyperlinks styled like Excel's; CSV import with automatic number typing; CSV/JSON export of any range or whole sheets.
Images & protection: embed png/jpg/gif/bmp pictures with proportional resizing; protect sheets (optionally with a password), unlocking chosen cells first with set_cell_locked.
Excel bridge (Windows + Microsoft Excel, uv sync --extra com): recalculate_workbook drives a hidden Excel instance to compute formulas and cache the results, then read_calculated_range returns computed values instead of formula text; export_pdf prints a sheet or workbook to PDF; open_in_excel pops the file open in a visible window for the user; run_macro executes VBA in .xlsm files and reloads the session with the macro's changes. On machines without Excel these tools return setup guidance instead of failing silently.
Roadmap: pivot tables, workbook-level protection, richer chart styling.
Setup
Requires Python 3.11+ and uv.
git clone <this-repo>
cd Excel-MCP
uv sync # add --extra com on Windows for the Excel bridgeThen register the server with your client. Quick versions:
# Claude Code (add --scope user to make it global)
claude mcp add excel -- uv --directory C:/path/to/Excel-MCP run excel-mcp// VS Code GitHub Copilot: .vscode/mcp.json (workspace) or user mcp.json (global)
{
"servers": {
"excel": {
"command": "uv",
"args": ["--directory", "C:/path/to/Excel-MCP", "run", "excel-mcp"]
}
}
}For GitHub Copilot CLI, global installs, installing the server as a standalone excel-mcp command, and troubleshooting, see CLIENT_SETUP.md.
Notes & limitations
Formulas are stored, not calculated by the file engine — openpyxl writes formula text; Excel evaluates it on next open. Use
recalculate_workbook(Windows + Excel) to compute results on demand.read_rangecaps responses at 10,000 cells and returns anext_rangecursor for paging through big sheets; per-cell edits (formatting, clearing, replacing) are capped at 100,000 cells.Charts created by this server round-trip through save/load. Workbooks authored in Excel may carry chart formatting details that openpyxl simplifies on resave.
close_workbookrefuses to drop unsaved changes unlessdiscard_changes=true.
Development
uv run pytest # test suite
uv run mcp dev src/excel_mcp/server.py # MCP InspectorAvailable Tools
74 toolsadd_chartA
Embed a chart in a sheet.
chart_type: bar, bar_horizontal, line, pie, scatter, area. data_range holds the value column(s); with data_includes_headers=true (default) the first row provides the series names. categories_range is the label column/row for the axis (or the slice labels for pie). For scatter, categories_range is required and supplies the shared x-values (no header); each data_range column becomes one y-series.
position is the cell of the chart's top-left corner (e.g. 'E2'); it defaults to two columns right of the data. Data and chart may be on different sheets ('Summary!E2'). width_cm/height_cm default to 15 x 7.5.
Inputs: chart_type (required), data_range (required), session_id (required), title, +7 more.
add_commentB
Attach a comment (note) to a cell. Replaces any existing comment.
Inputs: cell (required), text (required), session_id (required), author.
add_data_validationA
Add a data-validation input rule to a range.
validation_type:
'list': in-cell dropdown; pass options=["Yes","No"] (literal values) or formula='=$F$1:$F$5' to source the choices from cells.
'whole', 'decimal', 'date', 'text_length': pass operator (between, notBetween, equal, notEqual, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual) and values (two for between/notBetween, otherwise one). Dates are ISO strings like '2026-01-31'.
'custom': pass formula, e.g. '=ISNUMBER(A2)'.
error_message customizes the rejection dialog; prompt shows a tooltip when the cell is selected. Rules take effect when the file is used in Excel.
Inputs: range (required), session_id (required), validation_type (required), prompt, +6 more.
add_sheetA
Add a new empty sheet. index 0 puts it first; omit to append at the end.
Inputs: name (required), session_id (required), index.
append_rowsA
Append rows after the last used row of a sheet (like adding to a table).
values is a list of rows. Omit sheet to use the active sheet.
Inputs: values (required), session_id (required), sheet.
apply_conditional_formattingA
Add a conditional formatting rule to a range.
rule_type:
'color_scale': gradient by value; colors = 2 or 3 hex/named colors (default red-yellow-green).
'data_bar': in-cell bars; colors = [bar_color] (default blue).
'cell_value': highlight cells matching operator (greaterThan, lessThan, equal, notEqual, between, notBetween, greaterThanOrEqual, lessThanOrEqual) against values (two values for between); uses fill_color/font_color.
'formula': highlight where an Excel formula (relative to the range's top-left cell) is TRUE, e.g. 'ISBLANK(A2)'; uses fill_color/font_color.
Inputs: range (required), rule_type (required), session_id (required), colors, +5 more.
apply_style_presetC
Apply a common style in one call.
Presets: header (bold white on dark blue, centered), title (large bold), zebra (banded rows, first row skipped), currency, percent, highlight (yellow fill), total_row (bold, double top border).
Inputs: range (required), preset (required), session_id (required).
auto_fit_columnsB
Approximate Excel's auto-fit: size each column to its longest value.
columns like 'A:F'; omit to fit every used column. Widths are clamped to the 8-80 range.
Inputs: session_id (required), sheet, columns.
clear_rangeA
Clear values (not formatting) from every cell in a range.
Inputs: range (required), session_id (required).
close_workbookA
Close a workbook session and free its memory.
Refuses to close if there are unsaved changes, unless discard_changes=True.
Inputs: session_id (required), discard_changes.
copy_sheetC
Duplicate a sheet within the workbook, including values and formatting.
Inputs: name (required), session_id (required), new_name.
create_workbookA
Create a new Excel workbook at the given absolute path.
The file is not written to disk until save_workbook. Fails if the file already exists unless overwrite=True. Returns a session_id for editing.
Inputs: path (required), overwrite.
define_named_rangeA
Create a workbook-level named range, e.g. 'SalesData' for 'Sheet1!A1:C10'. The name can then be used in formulas: '=SUM(SalesData)'.
Inputs: name (required), range (required), session_id (required).
delete_chartB
Delete a chart by its index (see list_charts). The data is unaffected.
Inputs: session_id (required), chart_index (required), sheet.
delete_columnsC
Delete columns starting at the given column ('B' or 1-based index).
Inputs: column (required), session_id (required), count, sheet.
delete_commentB
Remove the comment from a cell.
Inputs: cell (required), session_id (required).
delete_imageA
Delete an embedded picture by its index (see list_images).
Inputs: session_id (required), image_index (required), sheet.
delete_named_rangeA
Delete a defined name. The cells it referred to are unaffected.
Inputs: name (required), session_id (required).
delete_rowsB
Delete rows starting at the given 1-based row number. Rows below shift up.
Inputs: row (required), session_id (required), count, sheet.
delete_sheetA
Delete a sheet and all its data. A workbook must keep at least one sheet.
Inputs: name (required), session_id (required).
export_csvA
Export a range (or a sheet's whole used range) to a CSV file.
Formula cells export their formula text; run recalculate_workbook and read from read_calculated_range if you need computed values instead. Dates become ISO strings, empty cells become empty fields.
Inputs: csv_path (required), session_id (required), range, sheet, +2 more.
export_jsonA
Export a range (or a sheet's whole used range) to a JSON file.
With first_row_is_header=true (default) the output is a list of objects keyed by the header row; otherwise a list of row arrays.
Inputs: json_path (required), session_id (required), range, sheet, +2 more.
export_pdfA
Export the workbook (or one sheet) to a PDF file via Excel.
Saves the session first. Requires Microsoft Excel on Windows (uv sync --extra com).
Inputs: pdf_path (required), session_id (required), sheet, overwrite.
fill_formulaA
Fill a range with a formula, adjusting relative references like Excel's fill handle.
The formula is written as given to the range's top-left cell and translated for the rest: '=B22' filled into C2:C4 becomes '=B32' in C3 and '=B42' in C4. Use $ to pin references ('=$B$1B2').
Inputs: range (required), formula (required), session_id (required).
find_in_workbookA
Find cells whose value contains the query text (or matches the regex).
Searches one sheet if given, otherwise the whole workbook. Values are matched against their string form; formulas match on formula text. Returns up to 500 matches with their cell addresses.
Inputs: query (required), session_id (required), regex, sheet, +1 more.
format_as_tableB
Convert a range into a native Excel table with a built-in style.
The first row of the range must be unique, non-empty headers. Styles are Excel's built-ins: TableStyleLight1-21, TableStyleMedium1-28, TableStyleDark1-11.
Inputs: range (required), session_id (required), style, table_name, +1 more.
freeze_panesA
Freeze rows above and columns left of the given cell.
'A2' freezes row 1; 'B1' freezes column A; 'B2' freezes both. Omit cell (or pass 'A1') to unfreeze.
Inputs: session_id (required), cell, sheet.
get_cell_formatA
Inspect a cell's formatting: font, fill, alignment, borders, number format, dimensions, and merge status.
Inputs: cell (required), session_id (required).
get_commentsB
List all comments on a sheet with their cells, text, and authors.
Inputs: session_id (required), sheet.
get_formulaA
Read the formula stored in a cell. formula is null when the cell holds a plain value instead of a formula.
Inputs: cell (required), session_id (required).
get_used_rangeB
Get the bounding range of used cells on a sheet, e.g. 'A1:F120'.
Inputs: session_id (required), sheet.
get_workbook_infoC
Get workbook details: sheet names plus each sheet's used-range dimensions.
Inputs: session_id (required).
import_csvB
Import a CSV file into a sheet, starting at start_cell.
With detect_types=true (default), numeric fields become numbers and empty fields become empty cells; otherwise everything is written as text. Existing cells in the target area are overwritten.
Inputs: csv_path (required), session_id (required), sheet, encoding, +3 more.
insert_columnsB
Insert empty columns before the given column ('B' or 1-based index).
Columns at and right of it shift right. Note: formulas are not re-adjusted.
Inputs: column (required), session_id (required), count, sheet.
insert_imageA
Insert a picture with its top-left corner at the given cell.
Supports png, jpg, gif, bmp. Give width_px and/or height_px to resize; a single dimension scales proportionally. The image file is embedded in the workbook, so the source file is not needed afterwards.
Inputs: cell (required), image_path (required), session_id (required), width_px, +1 more.
insert_rowsA
Insert empty rows before the given 1-based row number.
Rows at and below row shift down. Note: formulas are not re-adjusted.
Inputs: row (required), session_id (required), count, sheet.
list_chartsB
List the charts embedded in a sheet, with the index used by delete_chart.
Inputs: session_id (required), sheet.
list_imagesA
List the pictures embedded in a sheet, with the index used by delete_image.
Inputs: session_id (required), sheet.
list_named_rangesA
List the workbook's defined names and the ranges they refer to.
Inputs: session_id (required).
list_open_workbooksA
List all currently open workbook sessions with their session_ids.
Inputs: no named parameters. Returns: result
list_sheetsB
List all sheets in the workbook, in tab order.
Inputs: session_id (required). Returns: result
merge_cellsB
Merge a range into one cell. Only the top-left value is kept.
Inputs: range (required), session_id (required).
open_in_excelA
Open the workbook in a visible Excel window for the user to see.
Saves the session first so Excel shows the latest edits. Edits the user then makes in Excel do NOT flow back into this session — to continue editing here afterwards, have the user save and close Excel, then close_workbook and open_workbook again to reload.
Inputs: session_id (required).
open_workbookA
Open an existing Excel file (.xlsx or .xlsm) for reading and editing.
Returns a session_id that every other tool requires. Changes are kept in memory until save_workbook is called. Use an absolute file path.
Inputs: path (required).
protect_sheetA
Protect a sheet so locked cells cannot be edited in Excel.
All cells are locked by default — use set_cell_locked(range, locked=false) BEFORE protecting to keep specific cells editable. The allow_* flags let users still format, sort, or filter while protected. A password (optional) is required to unprotect in Excel; note this is Excel's standard sheet protection, a deterrent rather than encryption.
Inputs: session_id (required), sheet, password, allow_sorting, +3 more.
read_calculated_rangeA
Read computed formula results (cached values) from the saved file.
Reads the last saved copy on disk, so run recalculate_workbook first — formula cells that were never calculated come back null with a hint. Non-formula cells return their stored values as usual. Truncates at 10,000 cells with a next_range cursor, like read_range.
Inputs: range (required), session_id (required).
read_cellA
Read one cell's value. cell is A1 notation, e.g. 'B2' or 'Sheet1!B2'.
Returns the stored value; for formula cells this is the formula text (e.g. '=SUM(A1:A5)'), since files edited outside Excel hold no cached result.
Inputs: cell (required), session_id (required).
read_rangeA
Read a rectangular range as a 2D array (rows of cell values).
Large ranges are truncated at 10,000 cells; the response then includes truncated=true and next_range to continue reading from.
Inputs: range (required), session_id (required).
read_sheetA
Read a whole sheet's used range. Omit sheet to read the active sheet.
With first_row_is_header=true, returns records as a list of dicts keyed by the header row. Truncates at 10,000 cells like read_range.
Inputs: session_id (required), sheet, first_row_is_header.
recalculate_workbookA
Recalculate all formulas using a hidden desktop Excel instance and cache the results in the file, so read_calculated_range can return computed values.
Saves the session to disk first (flushing pending edits), then opens the file invisibly in Excel, recalculates, and saves. The in-memory session keeps formulas as text; only the file on disk gains cached results. Requires Microsoft Excel on Windows (uv sync --extra com).
Inputs: session_id (required).
remove_duplicatesA
Delete duplicate rows within a range, keeping each first occurrence.
columns lists the sheet column letters that decide uniqueness, e.g. ["A","C"] (each must fall inside the range); omit to compare whole rows. Text comparison ignores case, like Excel's Remove Duplicates. Set has_header=true to leave the range's first row in place. Remaining rows shift up and the freed rows at the bottom are cleared. Only values are compared and moved, not formatting.
Inputs: range (required), session_id (required), columns, has_header.
remove_hyperlinkA
Remove the hyperlink from a cell. The cell value and formatting stay.
Inputs: cell (required), session_id (required).
rename_sheetB
Rename a sheet. Note: formulas referencing the old name are not rewritten.
Inputs: name (required), new_name (required), session_id (required).
replace_in_rangeA
Replace text in every matching cell within a range.
Only text (string) cells are modified; numbers, dates, and formulas are
left untouched. With regex=True, replace may use groups like \1.
Inputs: find (required), range (required), replace (required), session_id (required), +2 more.
run_macroA
Run a VBA macro in the workbook via Excel, then reload the session so changes the macro made are visible to the other tools.
Only .xlsm workbooks can hold macros. macro_name is the procedure name (e.g. 'FormatReport' or 'Module1.FormatReport'); args are passed through. The workbook is saved after the macro runs. Requires Microsoft Excel on Windows (uv sync --extra com), and macros must be trusted for automation.
Inputs: macro_name (required), session_id (required), args.
save_workbookB
Write the workbook's in-memory changes to its file on disk.
Inputs: session_id (required).
save_workbook_asA
Save the workbook to a new absolute path; the session then points at that file.
Inputs: new_path (required), session_id (required).
set_active_sheetB
Set which sheet unqualified ranges like 'A1:C10' refer to.
Inputs: name (required), session_id (required).
set_alignmentB
Set text alignment on a range.
horizontal: left, center, right, justify. vertical: top, center, bottom. text_rotation: degrees 0-180.
Inputs: range (required), session_id (required), vertical, wrap_text, +2 more.
set_auto_filterA
Add Excel's filter dropdowns to a data range (one filter per sheet).
range should cover the header row plus data, e.g. 'A1:D50'; omit it to use the sheet's whole used range. Pass remove=true to clear the sheet's filter. This adds the filter UI — choosing filter values happens in Excel.
Inputs: session_id (required), range, sheet, remove.
set_bordersA
Draw borders on a range.
edges: ["all"] (default) borders every cell on all sides, ["outline"] only the range perimeter, or any of ["top","bottom","left","right"] applied to every cell. style: thin, medium, thick, double, dashed, dotted, hair.
Inputs: range (required), session_id (required), color, edges, +1 more.
set_cell_lockedA
Mark cells as locked or unlocked. Takes effect only while the sheet is protected (protect_sheet); all cells start locked, so unlock the cells users should edit, then protect the sheet.
Inputs: range (required), locked (required), session_id (required).
set_column_widthB
Set the width of one column ('B') or a span ('B:D'). Width is in Excel character units (default column width is about 8.4).
Inputs: width (required), columns (required), session_id (required), sheet.
set_fill_colorA
Set a solid background fill on every cell in a range.
color accepts hex ('#FFFF00') or names like yellow, light_blue, light_gray. Pass 'none' to remove the fill.
Inputs: color (required), range (required), session_id (required).
set_fontB
Set font properties on every cell in a range. Only the properties you pass are changed; others are preserved.
color accepts hex ('#FF0000') or names like red, blue, white, dark_blue.
Inputs: range (required), session_id (required), bold, size, +5 more.
set_formulaA
Write an Excel formula to one cell, e.g. 'SUM(B2:B10)' (leading '=' optional).
Formulas are stored, not calculated — Excel evaluates them when the file is next opened. Reading the cell back returns the formula text.
Inputs: cell (required), formula (required), session_id (required).
set_hyperlinkA
Turn a cell into a hyperlink.
url can be external ('https://example.com', 'mailto:a@b.com') or internal to the workbook with a '#' prefix ('#Sheet2!A1'). display sets the cell text; if omitted, an empty cell shows the url. The cell is styled as a link (blue, underlined).
Inputs: url (required), cell (required), session_id (required), display.
set_number_formatB
Set the number format for a range.
Accepts an alias — general, integer, decimal, currency, percent, date, datetime, time, text, scientific — or any Excel format code like '#,##0.00 "kg"' or '€#,##0.00'.
Inputs: range (required), session_id (required), number_format (required).
set_row_heightC
Set the height of one row ('2') or a span ('2:5'), in points.
Inputs: rows (required), height (required), session_id (required), sheet.
sort_rangeA
Sort the rows of a range by one column's values.
by_column is the sheet column letter (e.g. 'B') and must fall inside the range. Set has_header=true if the range's first row is a header to keep in place. Numbers and dates sort before text; blank cells always sort last. Only values move — formatting stays put, and formulas move as text (their relative references are NOT adjusted). For multi-key sorts, call once per key from least to most significant column (the sort is stable).
Inputs: range (required), by_column (required), session_id (required), descending, +1 more.
unmerge_cellsA
Unmerge a previously merged range (must match the merged area exactly).
Inputs: range (required), session_id (required).
unprotect_sheetB
Remove sheet protection (no password needed here — this edits the file directly, unlike Excel's UI).
Inputs: session_id (required), sheet.
write_cellA
Write a value to one cell. Strings starting with '=' are stored as formulas.
Pass null to clear the cell. Dates should be ISO strings; they are stored as text unless the cell already has a date number format.
Inputs: cell (required), value (required), session_id (required).
write_rangeA
Write a 2D array of values starting at start_cell (top-left corner).
values is a list of rows, e.g. [["Name","Age"],["Ana",31]]. Strings starting with '=' are stored as formulas. null leaves a gap (clears that cell).
Inputs: values (required), session_id (required), start_cell (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 74 tools
Each tool targets a specific Excel operation or resource (e.g., charts, comments, ranges, sheets) with no apparent overlap. The descriptions clearly differentiate similar actions like reading cells at different granularities.
Most tools follow a consistent verb_noun pattern (add_chart, delete_rows, set_font). Minor deviations like 'define_named_range' and 'format_as_table' do not break the overall predictability.
74 tools is far beyond the typical 3-15 range for a well-scoped server. While Excel is complex, this volume risks overwhelming users and agents, and many tools could be consolidated.
The tool set covers a wide range of Excel operations including CRUD, formatting, charts, data validation, macros, and exports. Minor gaps like pivot tables are understandable given the scope.
Maintenance
Related MCP Connectors
The Excel engine for AI agents: read, check and edit Excel models over MCP.
File tools for your AI chat: PDF tables to Excel, merge PDFs, images to PDF, fill PDF forms.
Open, inspect, filter, edit and convert xlsx and csv files from your AI chat. Processing is local.
Open, inspect, filter, edit and convert xlsx and csv files from your AI chat. Processing is local.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to create, read, and manipulate Excel files without requiring Microsoft Excel installation. Supports comprehensive spreadsheet operations including formulas, formatting, charts, pivot tables, and data validation.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to create, read, and modify Excel workbooks without requiring Microsoft Excel, supporting operations like formulas, charts, pivot tables, formatting, and data validation.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to create, read, and manipulate Excel workbooks without Microsoft Excel installed, supporting formulas, formatting, charts, pivot tables, and data validation operations.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to create, read, write, and manipulate Excel files (.xlsx, .xlsm) without requiring Microsoft Excel, including support for charts, pivot tables, data import/export, and professional formatting across Windows, macOS, and Linux.143 npm35MIT