excel-mcp-server 0.2.1

An MCP server that exposes Excel manipulation tools over stdio and streamable HTTP transports
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
# Excel MCP Server — Detailed Documentation

Complete reference for all 74 tools in the Excel MCP Server.

## Table of Contents

- [Concepts]#concepts
- [Workbook Lifecycle]#workbook-lifecycle
- [Reading Data]#reading-data
- [Writing Data]#writing-data
- [Formatting]#formatting
- [Charts]#charts
- [Pivot Tables]#pivot-tables
- [Interactive Controls]#interactive-controls
- [Tables and Data Features]#tables-and-data-features
- [Images and Shapes]#images-and-shapes
- [Comments and Links]#comments-and-links
- [Named Ranges]#named-ranges
- [Protection]#protection
- [Page Setup and Print]#page-setup-and-print
- [Document Properties]#document-properties
- [Advanced Features]#advanced-features
- [Error Handling]#error-handling

## Concepts

### Workbook IDs

Every workbook operation requires a `workbook_id` — a UUID handle returned by `create_workbook` or `open_workbook`. This handle references an in-memory workbook in the server's store.

### Cell References

Cells use A1 notation: `"A1"`, `"B5"`, `"AA100"`. Ranges use colon notation: `"A1:E10"`. Sheet-qualified references: `"Sheet1!$A$1:$B$10"`.

### Formula Recalculation

The server includes a 58-function formula engine. When you call `save_workbook` or `save_workbook_advanced`, all formulas are automatically recalculated with dependency graph ordering before the file is written. Supported functions include SUM, AVERAGE, IF, VLOOKUP, XLOOKUP, INDEX, MATCH, COUNTIF, SUMIF, and many more.

### Workbook Store

- Maximum 10 concurrent workbooks
- 30-minute inactivity TTL — workbooks are evicted automatically
- Thread-safe with `Arc<RwLock<WorkbookStore>>`
- Always call `save_workbook` before the TTL expires to persist changes

## Workbook Lifecycle

### create_workbook

Create a new empty workbook with one sheet ("Sheet1").

```json
{ }
```

Returns `workbook_id`, engine name, and sheet list.

### open_workbook

Open an existing xlsx file.

```json
{
  "file_path": "/path/to/file.xlsx",
  "read_only": false
}
```

Set `read_only: true` for fast read-only access (cannot save).

### open_workbook_encrypted

Open a password-protected xlsx file.

```json
{
  "file_path": "/path/to/encrypted.xlsx",
  "password": "secret"
}
```

### save_workbook

Save to disk as xlsx. Formulas are recalculated automatically.

```json
{
  "workbook_id": "...",
  "file_path": "/path/to/output.xlsx"
}
```

### save_workbook_advanced

Save in different formats with recalculation.

```json
{
  "workbook_id": "...",
  "file_path": "/path/to/output.xltx",
  "format": "template",
  "password": null
}
```

Formats: `"xlsx"` (default), `"template"` (.xltx), `"encrypted"` (password-protected), `"parallel"` (fast compression for large files).

### close_workbook

Free memory for a workbook.

```json
{ "workbook_id": "..." }
```

### configure_workbook

Set calculation mode, active sheet, and basic properties.

```json
{
  "workbook_id": "...",
  "calc_mode": "auto",
  "active_sheet": 0,
  "title": "Report",
  "author": "AI Assistant"
}
```

## Reading Data

### read_sheet

Read data with optional range and pagination.

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "range": "A1:E10",
  "continuation_token": null
}
```

### read_cell

Read a single cell's value, type, and formula.

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "cell": "B5"
}
```

### read_cell_comment

Read a cell's comment (author and text).

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "cell": "A1"
}
```

### read_cell_format

Read a cell's formatting properties.

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "cell": "A1"
}
```

### read_sheet_metadata

Read structural metadata about a sheet.

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "info": "all"
}
```

`info` options: `"used_range"`, `"hyperlinks"`, `"merge_ranges"`, `"charts"`, `"all"`.

### search_cells

Search for values across sheets.

```json
{
  "workbook_id": "...",
  "query": "Revenue",
  "match_mode": "substring"
}
```

### sheet_to_csv

Export a sheet as a CSV string.

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "delimiter": ","
}
```

## Writing Data

### write_cells

Batch write to multiple cells. Types are auto-detected: strings starting with `=` become formulas, numbers stay numeric, ISO dates are parsed, booleans are preserved.

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "cells": [
    { "cell": "A1", "value": "Name" },
    { "cell": "B1", "value": 42 },
    { "cell": "C1", "value": "=SUM(B1:B10)" }
  ]
}
```

### write_row / write_column

Write a sequence of values starting from a cell.

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "start_cell": "A1",
  "values": ["Product", "Q1", "Q2", "Q3", "Q4"]
}
```

### write_rich_text

Write text with mixed formatting runs.

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "cell": "A1",
  "runs": [
    { "text": "Bold ", "bold": true },
    { "text": "and ", "italic": true },
    { "text": "red", "color": "#FF0000" }
  ]
}
```

### write_json_rows

Write JSON objects as spreadsheet rows. Keys become headers.

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "start_cell": "A1",
  "write_headers": true,
  "rows": [
    { "name": "Alice", "age": 30, "active": true },
    { "name": "Bob", "age": 25, "active": false }
  ]
}
```

### write_formula

Write formulas with type control.

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "cell": "A1",
  "formula": "SUM(B1:B10)",
  "formula_type": "regular",
  "cached_result": 150.0
}
```

`formula_type`: `"regular"` (default), `"array"` (CSE — cell should be a range like `"A1:C3"`), `"dynamic"` (Excel 365 spill).

## Formatting

### set_cell_format

Apply formatting to a range.

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "range": "A1:E1",
  "bold": true,
  "italic": false,
  "font_size": 12,
  "font_color": "#FFFFFF",
  "background_color": "#4472C4",
  "number_format": "#,##0.00",
  "horizontal_alignment": "center",
  "vertical_alignment": "center",
  "border_style": "thin"
}
```

Alignments: `left`, `center`, `right`, `fill`, `justify`. Borders: `thin`, `medium`, `thick`, `dashed`, `dotted`, `double`, `none`.

### merge_cells

```json
{ "workbook_id": "...", "sheet_name": "Sheet1", "range": "A1:E1" }
```

### set_dimensions

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "target": "column_width",
  "column": "A",
  "value": 20.0
}
```

Targets: `"column_width"`, `"row_height"`, `"column_range_width"` (needs `first_column` + `last_column`), `"default_row_height"`.

## Charts

### add_chart

Full-featured chart with 7 base types and extensive customization.

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "chart_type": "column",
  "series": [
    {
      "values": "Sheet1!$B$2:$B$10",
      "categories": "Sheet1!$A$2:$A$10",
      "name": "Revenue",
      "color": "#4472C4",
      "data_labels": true,
      "trendline": "linear",
      "marker": "circle",
      "line_width": 2.0,
      "dash_style": "solid",
      "error_bars": { "bar_type": "both", "value_type": "percentage", "value": 5.0 }
    }
  ],
  "cell": "E2",
  "title": "Revenue by Quarter",
  "x_axis_label": "Quarter",
  "y_axis_label": "Revenue ($)",
  "legend_position": "bottom",
  "width": 600,
  "height": 400,
  "show_data_table": true,
  "view_3d": { "rot_x": 15, "rot_y": 20, "perspective": 30 },
  "style": 26,
  "alt_text": { "title": "Revenue Chart", "description": "Quarterly revenue bar chart" },
  "y_axis_min": 0,
  "y_axis_max": 1000,
  "y_axis_format": "$#,##0",
  "plot_area_fill": "#F5F5F5"
}
```

Chart types: `bar`, `column`, `line`, `pie`, `scatter`, `area`, `doughnut`.

Trendlines: `linear`, `exponential`, `power`, `logarithmic`.

Markers: `circle`, `diamond`, `square`, `triangle`, `none`.

Dash styles: `solid`, `dash`, `dot`, `dash_dot`, `long_dash`, `long_dash_dot`.

Error bar types: `both`, `plus`, `minus`. Value types: `fixed`, `percentage`, `std_dev`, `std_error`.

### ChartEx Types

`add_waterfall_chart`, `add_funnel_chart`, `add_treemap_chart`, `add_sunburst_chart`, `add_histogram_chart`, `add_box_whisker_chart`, `add_map_chart` — see README for parameters.

### add_chart_sheet

Create a dedicated chart-only sheet.

```json
{
  "workbook_id": "...",
  "sheet_name": "Revenue Chart",
  "chart_type": "line",
  "series": [{ "values": "Data!$B$2:$B$10", "name": "Revenue" }],
  "title": "Annual Revenue"
}
```

## Pivot Tables

### add_pivot_table

```json
{
  "workbook_id": "...",
  "sheet_name": "PivotSheet",
  "cell": "A1",
  "name": "SalesPivot",
  "source_range": "'Data'!$A$1:$E$100",
  "row_fields": ["Region", "Product"],
  "column_fields": ["Quarter"],
  "value_fields": [
    { "field": "Revenue", "aggregation": "sum" },
    { "field": "Units", "aggregation": "count" }
  ],
  "filter_fields": ["Year"],
  "style": "PivotStyleMedium9",
  "layout": "tabular",
  "calculated_fields": [
    { "name": "AvgPrice", "formula": "Revenue/Units" }
  ],
  "date_groups": [
    { "field": "OrderDate", "levels": ["years", "quarters"] }
  ],
  "range_groups": [
    { "field": "Revenue", "start": 0, "end": 10000, "interval": 1000 }
  ],
  "value_formats": [
    { "field": "Revenue", "format": "$#,##0" }
  ],
  "subtotals": [
    { "field": "Region", "show": true }
  ],
  "grand_total_rows": true,
  "grand_total_cols": false,
  "show_row_headers": true,
  "show_row_stripes": true
}
```

Aggregations: `sum`, `count`, `average`, `max`, `min`, `product`, `count_nums`, `std_dev`, `var`.

Layouts: `compact`, `outline`, `tabular`.

Date group levels: `years`, `quarters`, `months`, `days`, `hours`, `minutes`, `seconds`.

## Interactive Controls

### add_slicer

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "pivot_table_name": "SalesPivot",
  "field_name": "Region",
  "cell": "H1",
  "width": 200,
  "height": 300
}
```

### add_timeline

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "pivot_table_name": "SalesPivot",
  "field_name": "OrderDate",
  "cell": "H15"
}
```

### add_form_control

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "cell": "A1",
  "control_type": "checkbox",
  "text": "Include tax",
  "cell_link": "$F$1"
}
```

Control types: `button`, `checkbox`, `dropdown`, `spinner`.

## Tables and Data Features

### add_table

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "range": "A1:E10",
  "columns": ["Name", "Q1", "Q2", "Q3", "Q4"],
  "style": "Table Style Medium 2",
  "autofilter": true,
  "totals_row": true
}
```

### add_conditional_format

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "range": "B2:B100",
  "rule": {
    "type": "color_scale_3",
    "min_color": "#FF0000",
    "mid_color": "#FFFF00",
    "max_color": "#00FF00"
  }
}
```

Rule types: `cell_value` (with operator, value, value2), `color_scale_2`, `color_scale_3`, `data_bar`, `icon_set`.

### add_data_validation

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "range": "C2:C100",
  "validation": {
    "type": "list",
    "values": ["Low", "Medium", "High"]
  },
  "input_message": { "title": "Priority", "body": "Select a priority level" },
  "error_alert": { "style": "stop", "title": "Invalid", "message": "Pick from the list" }
}
```

Validation types: `list`, `list_range`, `whole_number`, `decimal`, `date_range`, `text_length`, `custom_formula`.

## Images and Shapes

### add_image

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "cell": "A1",
  "image_path": "/path/to/logo.png",
  "width": 200,
  "height": 100
}
```

### add_shape

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "cell": "B2",
  "shape_type": "rounded_rectangle",
  "width": 200,
  "height": 100,
  "text": "Click here",
  "fill_color": "#4472C4",
  "outline_color": "#2F5496",
  "font_size": 14,
  "bold": true
}
```

Shape types: `rectangle`, `rounded_rectangle`, `ellipse`, `triangle`, `diamond`, `arrow`, `callout`, `text_box`.

## Comments and Links

### manage_comments

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "action": "add",
  "cell": "A1",
  "text": "Review this value",
  "author": "Analyst"
}
```

### add_threaded_comment

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "cell": "A1",
  "author": "Alice",
  "text": "Is this number correct?",
  "timestamp": "2025-07-25T10:00:00.000",
  "replies": [
    { "author": "Bob", "text": "Yes, verified against source." }
  ]
}
```

### add_link

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "cell": "A1",
  "link_type": "url",
  "target": "https://example.com",
  "display_text": "Example Site"
}
```

For internal links: `"link_type": "internal"`, `"target": "Sheet2!A1"`.

## Named Ranges

### manage_named_ranges

```json
{
  "workbook_id": "...",
  "action": "add_scoped",
  "name": "TaxRate",
  "formula": "Sheet1!$F$1",
  "sheet_index": 0
}
```

Actions: `add` (workbook scope), `add_scoped` (sheet scope), `update`, `remove` (needs `sheet_index` for scoped), `list`.

## Protection

### protect

Basic protection for sheets, workbooks, or unprotect ranges.

```json
{
  "workbook_id": "...",
  "target": "sheet",
  "sheet_name": "Sheet1",
  "password": "secret"
}
```

### protect_sheet_advanced

Granular protection with per-feature control.

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "password": "secret",
  "allow_format_cells": true,
  "allow_sort": true,
  "allow_insert_rows": false,
  "allow_delete_rows": false
}
```

All `allow_*` fields default to locked (not allowed). Set to `true` to permit that action.

## Page Setup and Print

### set_page_setup

```json
{
  "workbook_id": "...",
  "sheet_name": "Sheet1",
  "landscape": true,
  "paper_size": 1,
  "margins": { "top": 0.75, "bottom": 0.75, "left": 0.7, "right": 0.7 },
  "fit_to_pages": { "width": 1, "height": 0 },
  "print_area": "A1:E50",
  "header": "&LCompany&C&D&R&P of &N",
  "footer": "&CConfidential",
  "print_gridlines": true
}
```

## Document Properties

### set_doc_properties

```json
{
  "workbook_id": "...",
  "title": "Q3 Report",
  "author": "Finance Team",
  "company": "Acme Corp",
  "keywords": "quarterly, finance"
}
```

### set_custom_property

```json
{
  "workbook_id": "...",
  "name": "Department",
  "value": "Engineering",
  "value_type": "text"
}
```

Value types: `text`, `number`, `integer`, `bool`, `datetime`.

## Advanced Features

### manage_custom_xml

```json
{
  "workbook_id": "...",
  "action": "add",
  "namespace": "http://example.com/schema",
  "content": "<data><item>value</item></data>"
}
```

### add_connection

```json
{
  "workbook_id": "...",
  "connection_string": "Provider=SQLOLEDB;Data Source=server;...",
  "command": "SELECT * FROM sales"
}
```

### set_sst_threshold

Controls when the shared string table is used. Lower values use more memory but write faster.

```json
{
  "workbook_id": "...",
  "threshold": 100
}
```

## Error Handling

All tools return structured JSON responses.

### Error Categories

| Category | Description |
|---|---|
| `not_found` | Workbook ID or sheet name not found |
| `io_error` | File system or I/O error |
| `engine_unsupported` | Operation not supported (e.g., saving read-only workbook) |
| `capacity_exceeded` | Workbook store is full (max 10) |

### Error Response

```json
{
  "status": "error",
  "category": "not_found",
  "message": "Workbook 'abc-123' not found",
  "suggestion": "Check the workbook_id. Open workbooks: [\"def-456\"]"
}
```

The `suggestion` field provides actionable guidance. For `not_found` errors, it lists currently open workbook IDs.