Automate Excel with AI - A Model Context Protocol (MCP) server for comprehensive Excel automation through conversational AI.
MCP Server for Excel enables AI assistants (GitHub Copilot, Claude, ChatGPT) to automate Excel through natural language commands. Automate Power Query, DAX measures, VBA macros, PivotTables, Charts, formatting, and data transformations (25 tools with 225 operations).
๐ก๏ธ 100% Safe - Uses Excel's Native COM API - Zero risk of file corruption. Unlike third-party libraries that manipulate .xlsx files directly, this project uses Excel's official API ensuring complete safety and compatibility.
๐ก Interactive Development - See results instantly in Excel. Create a query, run it, inspect the output, refine and repeat. Excel becomes your AI-powered workspace for rapid development and testing.
๐งช LLM-Tested Quality - Tool behavior validated with real LLM workflows using pytest-aitest. We test that LLMs correctly understand and use our tools.
Technical Requirements:
โ ๏ธ Windows Only - COM interop is Windows-specificโ ๏ธ Excel Required - Microsoft Excel 2016 or later must be installedโ ๏ธ Desktop Environment - Controls actual Excel process (not for server-side processing)
25 specialized tools with 225 operations:
- ๐ Power Query (1 tool, 11 ops) - Atomic workflows, M code management, load destinations
- ๐ Data Model/DAX (2 tools, 18 ops) - Measures with auto-formatted DAX, relationships, model structure
- ๐จ Excel Tables (2 tools, 27 ops) - Lifecycle, filtering, sorting, structured references
- ๐ PivotTables (3 tools, 30 ops) - Creation, fields, aggregations, calculated members/fields
- ๐ Charts (2 tools, 26 ops) - Create, configure, series, formatting, data labels, trendlines
- ๐ VBA (1 tool, 6 ops) - Modules, execution, version control
- ๐ Ranges (4 tools, 42 ops) - Values, formulas, formatting, validation, protection
- ๐ Worksheets (2 tools, 16 ops) - Lifecycle, colors, visibility, cross-workbook moves
- ๐ Connections (1 tool, 9 ops) - OLEDB/ODBC management and refresh
- ๐ท๏ธ Named Ranges (1 tool, 6 ops) - Parameters and configuration
- ๐ Files (1 tool, 6 ops) - Session management and workbook creation
- ๐งฎ Calculation Mode (1 tool, 3 ops) - Get/set calculation mode and trigger recalculation
- ๐๏ธ Slicers (1 tool, 8 ops) - Interactive filtering for PivotTables and Tables
- ๐จ Conditional Formatting (1 tool, 2 ops) - Rules and clearing
- ๐ธ Screenshot (1 tool, 2 ops) - Capture ranges/sheets as PNG for LLM visual verification
- ๐ชง Window Management (1 tool, 9 ops) - Show/hide Excel, arrange, position, status bar feedback
๐ Complete Feature Reference โ - Detailed documentation of all 225 operations
Create & Populate Data:
- "Create a new Excel file called SalesTracker.xlsx with a table for Date, Product, Quantity, Unit Price, and Total with sample data"
- "Put this data in A1:C4 - Name, Age, City / Alice, 30, Seattle / Bob, 25, Portland"
- "Add a formula column that calculates Quantity times Unit Price"
Analysis & Visualization:
- "Create a PivotTable from this data showing total sales by Product, then add a bar chart"
- "Use Power Query to import products.csv, load it to the Data Model, and create a measure for Total Revenue"
- "Create a slicer for the Region field so I can filter the PivotTable interactively"
- "Create a relationship between the Orders and Products tables using ProductID"
Formatting & Styling:
- "Format the Price column as currency and highlight values over $500 in green"
- "Convert this range to an Excel Table with a blue style and add a totals row"
- "Make the headers bold with a dark background and auto-fit column widths"
Automation:
- "Export all Power Query M code to files for version control"
- "Run the UpdatePrices macro"
- "Show me Excel while you work" - watch changes in real-time
๐ช Agent Mode โ Watch AI Work in Excel:
- "Show me Excel side-by-side while you build this dashboard" - real-time visibility
- "Let me watch while you create the chart" - AI asks your preference, then shows Excel
- Status bar shows live progress: "ExcelMcp: Building PivotTable from Sales data..."
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:
- โ Server-side data processing (use libraries like ClosedXML, EPPlus instead)
- โ Linux/macOS users (Windows + Excel installation required)
- โ High-volume batch operations (consider Excel-free alternatives)
| Platform | Installation |
|---|---|
| VS Code | Install Extension (one-click, recommended) |
| Claude Desktop | Download .mcpb from latest release |
| Any MCP Client | dotnet tool install --global Sbroenne.ExcelMcp.McpServer then npx add-mcp "mcp-excel" --name excel-mcp |
| Details | ๐ Installation Guide |
This package provides both CLI and MCP Server interfaces. Choose based on your use case:
| Interface | Best For | Why |
|---|---|---|
CLI (excelcli) |
Coding agents (Copilot, Cursor, Windsurf) | 64% fewer tokens - single tool, no large schemas. Auto-generated from Core code, ensuring 1:1 feature parity. |
| MCP Server | Conversational AI (Claude Desktop, VS Code Chat) | Rich tool discovery, persistent connection. Better for interactive, exploratory workflows. |
โก CLI Commands: Generated automatically from Core service definitions using Roslyn source generators. All 22 command categories maintain exact 1:1 parity with MCP tools through shared code generation. See code generation docs for details.
๐ Benchmark Results (same task, same model)
| Metric | CLI | MCP Server | Winner |
|---|---|---|---|
| Tokens | ~59K | ~163K | ๐ CLI (64% fewer) |
Key insight: MCP sends 23 tool schemas to the LLM on each request (~100K+ tokens).
Manual Installation:
# Step 1: Install MCP Server and CLI
dotnet tool install --global Sbroenne.ExcelMcp.McpServer
dotnet tool install --global Sbroenne.ExcelMcp.CLI
# Step 2: Auto-configure all your coding agents (requires Node.js)
npx add-mcp "mcp-excel" --name excel-mcp
โ ๏ธ Step 2 requires Node.js fornpx. Install withwinget install OpenJS.NodeJS.LTSif needed.
# Optional: Install agent skills for better AI guidance
npx skills add sbroenne/mcp-server-excel --skill excel-cli # Coding agents
npx skills add sbroenne/mcp-server-excel --skill excel-mcp # Conversational AI๐ก Skills provide AI guidance - The CLI skill is highly recommended (agents don't work perfectly with CLI without it). The MCP skill is recommended - it adds workflow best practices and reduces token usage.
ExcelMcp uses Windows COM automation to control the actual Excel application (not just .xlsx files).
Both the MCP Server and CLI communicate with a shared ExcelMCP Service that manages Excel sessions. This unified architecture enables:
โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Server โ โ CLI (excelcli) โ
โ (AI assistants) โ โ (coding agents) โ
โโโโโโโโโโโฌโโโโโโโโโโโโ โโโโโโโโโโโฌโโโโโโโโโโโโ
โ โ
โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ExcelMCP Service โ
โ (shared session mgmt) โ
โโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Excel COM API โ
โ (Excel.Application) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
Key Benefits:
- โ Shared Sessions - CLI and MCP Server can access the same open workbooks
- โ Single Excel Instance - No duplicate Excel processes or file locks
- โ System Tray UI - Monitor active sessions via the ExcelMCP tray icon
๐ก Tip: Watch Excel While AI Works By default, Excel runs hidden for faster automation. To see changes in real-time, just ask:
- "Show me Excel while you work"
- "Let me watch what you're doing"
- "Open Excel so I can see the changes"
The AI will display the Excel window so you can watch every operation happen live - great for learning or verifying changes!
๐ CLI Guide โ | CLI Skill for Agents โ | MCP Server Guide โ | All Agent Skills โ
License: MIT License - see LICENSE file
Privacy: See PRIVACY.md for our privacy policy
Contributing: See CONTRIBUTING.md for guidelines
Built With: This entire project was developed using GitHub Copilot AI assistance - mainly with Claude but lately with Auto-mode.
Acknowledgments:
- Microsoft Excel Team - For comprehensive COM automation APIs
- Model Context Protocol community - For the AI integration standard
- Open Source Community - For inspiration and best practices
Other projects by the author:
- pytest-aitest โ LLM-powered testing framework for AI agents
- Windows MCP Server โ AI-powered Windows automation via MCP
- OBS Studio MCP Server โ AI-powered OBS Studio automation
- HeyGen MCP Server โ MCP server for HeyGen AI video generation