Files
sbroenne__mcp-server-excel/vscode-extension
Stefan Broenner 1e996bea6d Remove file-based operations and refactor VBA to accept code strings (#191)
* Remove file-based operations and refactor VBA to accept code strings

Fixes #190

Changes:
- Removed Connection.Import and Connection.UpdateProperties (JSON file-based operations)
- Removed DataModel.ExportMeasure (DAX file export)
- Refactored VBA Import/Update to accept code strings instead of file paths
  - Core layer now accepts vbaCode string parameter
  - CLI layer handles file I/O (reads files and passes code strings)
  - MCP Server layer accepts vbaCode parameter directly
- Deleted PathValidator.cs and removed Security namespace references
- Updated all documentation (READMEs, GitHub Pages) to reflect 163 operations (down from 168)

Build status: ✅ 0 warnings, 0 errors

Breaking changes:
- VBA Import/Update signature changed in Core layer (file path → code string)
- Connection and DataModel commands removed (file-based operations)

* Fix VBA tests to pass code strings instead of file paths

The VBA command signature changed to accept code strings directly rather
than file paths. Updated all VBA trust tests to pass vbaCode strings
instead of creating temporary files and passing file paths.

Tests fixed:
- ScriptCommands_Import_WithTrustEnabled_WorksCorrectly
- ScriptCommands_Export_WithTrustEnabled_WorksCorrectly
- ScriptCommands_Run_WithTrustEnabled_WorksCorrectly
- ScriptCommands_Delete_WithTrustEnabled_WorksCorrectly
- ScriptCommands_View_WithTrustEnabled_WorksCorrectly
- ScriptCommands_Update_WithTrustEnabled_WorksCorrectly

All 7 VBA tests now pass.
2025-11-17 17:00:46 +00:00
..
2025-11-17 09:27:59 +00:00

Excel MCP Server - AI-Powered Excel Automation

Installs GitHub License: MIT

Control Microsoft Excel with AI through GitHub Copilot - just ask in natural language!

Instead of clicking through Excel menus, simply ask:

Data Transformation & Analysis:

  • "Optimize all my Power Queries in this workbook for better performance"
  • "Create a PivotTable from SalesData table showing top 10 products by region"
  • "Build a DAX measure calculating year-over-year growth with proper time intelligence"

Formatting & Styling (No Programming Required):

  • "Format revenue columns as currency, make headers bold with blue background"
  • "Apply conditional formatting to highlight values above $10,000 in red"
  • "Convert this range to an Excel Table with filters and totals row"

Workflow Automation:

  • "Find all cells containing 'Q1 2024' and replace with 'Q1 2025'"
  • "Add data validation dropdowns to Status column with options: Active, Pending, Completed"

Quick Example:

You: "Create a Power Query named 'SalesData' that loads from data.csv"

Copilot uses Excel MCP Server to:
1. Create/open an Excel workbook
2. Add the Power Query with proper M code
3. Load the data to a worksheet
4. Save and return confirmation

Result: A working Excel file with the query ready to use

🛡️ 100% Safe - Uses Excel's Native API

Unlike third-party libraries that manipulate .xlsx files directly (risking file corruption), Excel MCP Server uses Excel's official COM API. This ensures:

  • ✅ Zero risk of document corruption - Excel handles all file operations safely
  • ✅ Interactive development - See changes in real-time as you work with live Excel files
  • ✅ Comprehensive automation - Currently supports 163 operations across 12 specialized tools

👥 Who Should Use This?

Perfect for:

  • ✅ Data analysts automating repetitive Excel workflows
  • ✅ Developers building Excel-based data solutions
  • ✅ Business users managing complex Excel workbooks
  • ✅ Teams maintaining Power Query/VBA/DAX code in Git

Not suitable for:

  • ❌ Linux/macOS users (Windows + Excel installation required)
  • ❌ High-volume batch operations (consider Excel-free alternatives)

Quick Start

  1. Install this extension (you just did!)
  2. Ask Copilot in the chat panel:
    • "List all Power Query queries in workbook.xlsx"
    • "Create a DAX measure for year-over-year revenue growth"
    • "Export all VBA modules to .vba files for version control"

That's it! The extension automatically installs .NET 8 runtime and includes a bundled MCP server.

➡️ Learn more and see examples

Requirements

  • Windows OS - Excel COM automation requires Windows
  • Microsoft Excel 2016+ - Must be installed on your system
  • .NET 8 Runtime - Automatically installed by the extension

What's Included

Features

The Excel MCP Server provides 12 specialized tools for comprehensive Excel automation:

Tool Operations Purpose
excel_powerquery 11 actions Power Query M code: create, view, update, delete, load configuration, list sources
excel_datamodel 14 actions Power Pivot (Data Model): DAX measures, relationships, discover structure (tables, columns), refresh
excel_table 26 actions Excel Tables: lifecycle, columns, filters, sorts, structured references, number formatting
excel_pivottable 20 actions PivotTables: create, field management, aggregations, filters, sorting, extract data
excel_range 43 actions Ranges: get/set values/formulas, formatting, validation, clear, copy, insert/delete, find/replace, merge, cell protection
excel_conditionalformat 2 actions Conditional Formatting: add rules (cell value, expression-based), clear rules
excel_vba 7 actions VBA: list, view, export, import, update, run, delete modules
excel_connection 9 actions Connections: OLEDB/ODBC/Text/Web management, properties, refresh, test
excel_worksheet 13 actions Worksheets: lifecycle, tab colors, visibility (list, create, rename, copy, delete, show/hide, very-hide)
excel_namedrange 7 actions Named ranges: list, get, set, create, delete, update, bulk create
excel_querytable 8 actions QueryTables: create from connections/queries, refresh, update properties, delete
excel_file 6 actions File operations: create empty, open, save, close, close-workbook, test
Total 163 actions

Troubleshooting

"Excel is not installed" error:

  • Ensure Microsoft Excel 2016+ is installed on your Windows machine
  • Try opening Excel manually to verify it works

"VBA access denied" error:

  • VBA operations require one-time manual setup in Excel
  • Go to: File → Options → Trust Center → Trust Center Settings → Macro Settings
  • Check "Trust access to the VBA project object model"

Copilot doesn't see Excel tools:

  • Restart VS Code after installing the extension

  • Troubleshooting

  • Check Output panel → "Excel MCP Server" for connection status

Documentation & Support

License

MIT License - see LICENSE


Built with GitHub Copilot | Powered by Model Context Protocol