Excel MCP Skill
When to use
Use this skill when a user needs reliable Excel workbook work across one or more .xlsx files, including:
- Reading workbook structure, sheet data, formulas, and styles
- Writing values, formulas, and derived tables
- Applying formatting (number/date formats, widths, filters, freeze panes, conditional formats)
- Producing repeatable outputs where MCP tools are preferred but Python fallback is required when MCP is unavailable or incomplete
Instructions
- Confirm task scope and output contract.
- Identify input files, target sheets/ranges, expected output path, and any constraints (preserve formulas, keep styles, no structural changes, etc.).
- Restate success criteria in concrete terms before editing.
- Use MCP workflow first for workbook operations.
- Connect to the Excel-capable MCP server and inspect workbook metadata (sheet names, used ranges, headers, table boundaries).
- Read only the ranges needed for the requested task to reduce risk and runtime.
- Apply changes in small, ordered batches: write values/formulas, then apply formatting, then recalculate if supported.
- After each batch, re-read affected ranges to verify values and formulas landed correctly.
- Apply formatting and structure updates through MCP.
- Standardize data presentation: header style, column widths, number/date formats, filters, and freeze panes.
- Preserve existing named ranges, formulas, and chart references unless the user asked to restructure.
- If adding computed columns, keep formulas consistent and verify fill-down behavior.
- Validate workbook integrity before handoff.
- Re-open or re-read the output workbook and check: expected sheet count, key totals, formula cells, and formatting in critical ranges.
- Confirm there are no broken references introduced by edits.
- Report what changed (sheets, ranges, formula columns, formatting actions).
- Use Python fallback when MCP is unavailable or insufficient.
- Use
openpyxlfor cell-level edits, formulas, styles, worksheet structure, and preserving workbook fidelity. - Use
pandasfor tabular transforms (join, group, pivot, cleanup), then write results back withopenpyxl-compatible workflows. - Keep fallback flow deterministic:
- load workbook,
- copy to output path when appropriate,
- apply data edits,
- apply formatting,
- save,
- reopen and verify critical cells/ranges.
- Choose tools by operation type.
- Prefer MCP for direct workbook interactions when available.
- Prefer
openpyxlfor style-sensitive workbook edits and formula-safe updates. - Prefer
pandasfor data reshaping and analytics, then write curated outputs to workbook sheets.
- Communicate execution decisions and limits.
- State whether MCP or Python fallback was used and why.
- Call out limitations explicitly (for example: macro-enabled
.xlsmhandling, external links, unsupported conditional formatting edge cases). - Provide a concise verification summary with concrete cell/range checks.
Examples
- "Open
sales-q1.xlsx, updateForecast!D2:D500with a 7% uplift formula, and keep existing styles." - "Read
pipeline.xlsx, summarize totals by owner into a new sheet namedSummary, and format currency columns." - "Fix date formatting in
Operationssheet toyyyy-mm-dd, auto-fit columns A:F, and freeze the header row." - "Merge
NorthandSouthtabs intoAll_Regionswith pandas, then write the result back to the workbook." - "If MCP fails, use openpyxl to write values to
Budget!B2:G20, preserve formulas in row 21, and verify totals."
Common issues
| Issue | Likely cause | Resolution |
|---|---|---|
| MCP cannot open workbook | Bad path, file lock, or unsupported extension | Verify absolute path, close workbook in other apps, convert to .xlsx if needed |
| Written values not visible | Wrong sheet/range or stale read after write | Re-check target range, re-read affected cells, and confirm write operation order |
| Formulas replaced by static values | Dataframe export overwrote formula cells | Preserve formula columns explicitly; use openpyxl writes for mixed formula/value regions |
| Styles lost after update | Full-sheet overwrite via pandas writer | Write only target ranges, then reapply styles with openpyxl or MCP formatting calls |
| Date/currency formatting inconsistent | Raw values written without number formats | Set explicit number formats after writing data and verify sample cells |
| Totals changed unexpectedly | Partial range updates or missing rows | Validate row counts before/after, recompute checksums/totals, and compare key control cells |
| Fallback script fails on import | Missing openpyxl or pandas |
Install required packages and rerun the workflow |
| Output workbook corrupted | Interrupted save or incompatible writer flow | Save to a new file, reopen for integrity check, and avoid mixing incompatible writers in one pass |