Graph Excel

v0.7.0
io.github.mickey-ichi/graph-excel-mcp Checked 2 days ago Published 5 days ago

Read and edit Excel workbooks on SharePoint/OneDrive via Microsoft Graph, with verified writes.

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

login_status

Check the Microsoft Graph sign-in. If not signed in, starts a device code login and returns the URL + code: give them to the user (never sign in for them), then call login_status again once they say they're done.

resolve

Workbook info: driveId/itemId, last modified (when/by whom), and every sheet with its used range.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"

read_range

Read one contiguous range (e.g. H60:J60). Each cell comes with sha256:<hash> to pass back as `expected` when writing. fills=true adds each cell's fill color (≤400 cells). hashOnly=true omits the text (just hash + length).

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
range *string
sheet *stringWorksheet name exactly as listed by resolve
fillsboolean
hashOnlyboolean

write_values

Write blocks of cell values. Each block is one contiguous range with a 2D `values` array (a scalar for one cell). `expected` (same shape; exact text, sha256:<hash>, or null to skip a cell) is the base check: a block whose current content differs is skipped as a conflict, never half-written. After writing, every block is read back and compared (status written-verified / written-mismatch). Values are interpreted like typed input: text that looks like a number/date may be converted — mismatches report it.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
sheet *stringWorksheet name exactly as listed by resolve
writes *array
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

append_update

Write the 「-----update-----」 part of cells in one row (e.g. H/I/J) and keep the original part byte-identical. No separator yet: appends blank line + separator + text. Separator present: mode=replace (default) swaps the update part, mode=append adds after it. Pass `expected` per column (sha256 from read_range) as the base check. After writing it verifies the original part is intact, then fills `fillRange` (default the updated columns of that row) with `fill` (default #FFFF00; null = no fill).

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
row *integer
sheet *stringWorksheet name exactly as listed by resolve
update *objectColumn letter -> update text, e.g. {"H": "1. ...", "J": "..."}
expectedobjectColumn letter -> exact current text or sha256:<hash>
fillstring | null
fillRangestring
modestring
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

set_fill

Set or clear the fill color of one or more contiguous ranges (non-contiguous rows = several ranges; sent in one batch). color "#FFFF00" etc., or null to clear. Verified by reading the fill back.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
ranges *array
sheet *stringWorksheet name exactly as listed by resolve
colorstring | null
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

find

Search cell text across every sheet (or one `sheet`): case-insensitive substring by default, regex=true for a JavaScript regular expression. Returns sheet, address, a preview and the sha256 hash per hit (≤ limit, default 50, max 500).

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
text *string
limitinteger
matchCaseboolean
regexboolean
sheetstringWorksheet name exactly as listed by resolve

add_sheet

Add an empty worksheet (Excel name rules, no duplicate names), optionally at `position` (0 = first). Verified by listing the sheets afterwards.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
name *string
positioninteger
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

rename_sheet

Rename a worksheet (Excel name rules, no duplicate names). Formulas that refer to it follow the new name. Verified by listing the sheets afterwards.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
newName *string
sheet *stringWorksheet name exactly as listed by resolve
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

insert_rows

Insert `count` empty rows above `row`; everything from `row` down shifts down. The dry run shows the row that will move. Verified afterwards: that row is found at row+count and the new rows are empty.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
row *integer
sheet *stringWorksheet name exactly as listed by resolve
countinteger
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

append_rows

Append rows below the last used row of a sheet, starting at `column` (default A). `values` is a 2D array, one array per row. Base check: the target cells must still be empty; read back and verified like write_values.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
sheet *stringWorksheet name exactly as listed by resolve
values *array
columnstring
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

set_format

Format one or more contiguous ranges: bold, italic, fontColor (#RRGGBB), fontSize, wrapText, horizontalAlignment (General/Left/Center/Right/Justify), verticalAlignment (Top/Center/Bottom/Justify/Distributed), numberFormat (e.g. "yyyy-mm-dd", "0.00", "@" for text). Font changes are read back and verified. Fill colors: use set_fill.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
ranges *array
sheet *stringWorksheet name exactly as listed by resolve
boldboolean
fontColorstring
fontSizenumber
horizontalAlignmentstring
italicboolean
numberFormatstring
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)
verticalAlignmentstring
wrapTextboolean

set_layout

Column widths, row heights, autofit and hiding. columns: [{columns: "B" or "C:E", width (characters, as in Excel's Column Width dialog) | widthPt | autofit | hidden}]. rows: [{rows: "5" or "1:18", height (points) | autofit | hidden}]. Applied in order: widths/hidden, heights, then autofit (row autofit depends on column widths and wrapText — set wrap with set_format first). Excel does not autofit rows for merged cells. Widths, heights and hidden are read back and verified.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
sheet *stringWorksheet name exactly as listed by resolve
columnsarray
rowsarray
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

merge_cells

Merge or unmerge cells. Either `ranges` (each merged into one cell; across=true merges each row separately) or `groupBy`: one column (B3:B18) or row range split into groups — a value starts a group, equal values and blanks below extend it — and every group longer than one cell is merged (e.g. a category column). Refuses when a merge would drop data (Excel keeps only the top-left value; equal copies are fine). Graph can't read merges back: the result reports the request status and that the kept value is intact.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
sheet *stringWorksheet name exactly as listed by resolve
acrossboolean
groupBystring
rangesarray
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)
unmergeboolean

set_borders

Draw or clear borders on one or more ranges. sides default to the outline plus inside lines (EdgeTop, EdgeBottom, EdgeLeft, EdgeRight, InsideVertical, InsideHorizontal; DiagonalDown/DiagonalUp also allowed). style Continuous (default), Dash, DashDot, DashDotDot, Dot, Double, SlantDashDot or None to clear; weight Hairline, Thin (default), Medium, Thick; color #RRGGBB (default #000000). Read back and verified.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
ranges *array
sheet *stringWorksheet name exactly as listed by resolve
colorstring
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)
sidesarray
stylestring
weightstring

insert_columns

Insert `count` empty columns left of `column`; everything from `column` rightwards shifts right. Verified: the shifted column is intact and the new columns are empty.

ParameterTypeDescription
column *string
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
sheet *stringWorksheet name exactly as listed by resolve
countinteger
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

delete_rows

Delete whole rows ("7" or "7:9"); rows below shift up. The dry run shows what holds data there and a contentHash; deleting needs send=true AND expected = that contentHash, so a change made in between is caught. Verified: the next row moved up intact.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
rows *string
sheet *stringWorksheet name exactly as listed by resolve
expectedstring
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

delete_columns

Delete whole columns ("C" or "C:E"); columns to the right shift left. The dry run shows what holds data there and a contentHash; deleting needs send=true AND expected = that contentHash. Verified: the next column moved left intact.

ParameterTypeDescription
columns *string
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
sheet *stringWorksheet name exactly as listed by resolve
expectedstring
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

clear_range

Clear one or more ranges without shifting cells. applyTo Contents (default: values and formulas), Formats, or All. When clearing contents, the dry run returns a contentHash per block; pass them as `expected` (same order) with send=true. Verified: the cells are empty.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
ranges *array
sheet *stringWorksheet name exactly as listed by resolve
applyTostring
expectedarray
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

set_sheet_visibility

Hide (visible=false) or show (visible=true) a worksheet. At least one sheet must stay visible.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
sheet *stringWorksheet name exactly as listed by resolve
visible *boolean
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

delete_sheet

Delete a worksheet. The dry run shows how much data it holds; deleting needs send=true AND confirmName equal to the sheet name. Formulas elsewhere that refer to it turn into #REF!. The last sheet can't be deleted. Only when the user asked to delete that exact sheet.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
sheet *stringWorksheet name exactly as listed by resolve
confirmNamestring
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

bridge_status

Status of the Excel add-in bridge, which the tools below need: whether it's on (GRAPH_EXCEL_BRIDGE=1), paired, and which workbooks have the graph-excel bridge task pane open. If not paired yet (or pair=true) it returns a 6-digit pairing code: give it to the user to type in the task pane. Never pair on their behalf.

ParameterTypeDescription
pairboolean

get_validation

Read the data validation (dropdown list, number/date/length limits, custom formula) of a range. Needs the add-in task pane open on that workbook.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
range *string
sheet *stringWorksheet name exactly as listed by resolve

set_validation

Set or clear data validation on a range — through the Excel add-in (Graph has no API for it). Exactly one of: list {values: ["OK","NG"]} or {source: "=Lists!$A$2:$A$20"} (a dropdown), wholeNumber / decimal / date / time / textLength {operator, formula1, formula2?}, custom {formula: "=..."}; or clear=true. Optional prompt {title, message}, errorAlert {style Stop|Warning|Information, title, message}, ignoreBlanks. The dry run shows the current rule and, for a list, cells whose value isn't in it. A range that already has a rule needs replace=true. Read back after writing.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
range *string
sheet *stringWorksheet name exactly as listed by resolve
clearboolean
customobject
dateobject
decimalobject
errorAlertobject
ignoreBlanksboolean
listobject
promptobject
replaceboolean
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)
textLengthobject
timeobject
wholeNumberobject

list_conditional_formats

List the conditional formats that apply to a range (id, type, priority, applies-to range). Needs the add-in task pane open.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
range *string
sheet *stringWorksheet name exactly as listed by resolve

set_conditional_format

Add, delete (deleteIds from list_conditional_formats) or clear all conditional formats on a range — through the Excel add-in. Each `add` item: {kind, rule, format {fill, fontColor, bold}}. kinds: cellValue {operator, formula1, formula2?} (text in quotes, e.g. formula1 "\"NG\""), containsText {text, operator?}, custom {formula "=$H5=\"NG\""}, colorScale {criteria {minimum, midpoint?, maximum: {type: "LowestValue"|"HighestValue"|"Number"|"Percent"|"Percentile", formula?, color}}}, dataBar {color?}, topBottom {rank, type?}, duplicates {unique?}. Verified by listing again.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
range *string
sheet *stringWorksheet name exactly as listed by resolve
addarray
clearAllboolean
deleteIdsarray
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

set_view

Freeze panes and the sheet's filter buttons — through the Excel add-in. freeze {rows, columns} (e.g. {rows: 1} keeps the header visible) or null to unfreeze; autoFilter a range with headers (e.g. A4:L500) or null to remove. Changes everyone's view of the sheet.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
sheet *stringWorksheet name exactly as listed by resolve
autoFilterstring | null
freezeobject | null
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

copy_sheet

Duplicate a sheet right after it, with everything (values, formulas, formats, validation, conditional formats, charts), and name the copy. Through the Excel add-in.

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
newName *string
sheet *stringWorksheet name exactly as listed by resolve
sendbooleanfalse (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it)

get_merged_areas

List the merged areas inside a range (e.g. to check merge_cells). Through the Excel add-in (needs ExcelApi 1.13).

ParameterTypeDescription
file *stringWorkbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId"
range *string
sheet *stringWorksheet name exactly as listed by resolve