Excel COM Automation

数据与存储

by sbroenne

面向 Excel COM 自动化的工具,支持 Power Query、DAX measures、VBA,以及 Tables、ranges 与 connections 管理。

做Excel深度自动化时很顺手,能统一管理Power Query、DAX、VBA及表格连接,比只处理单元格的脚本工具更全面。

什么是 Excel COM Automation

面向 Excel COM 自动化的工具,支持 Power Query、DAX measures、VBA,以及 Tables、ranges 与 connections 管理。

README

ExcelMcp - MCP Server for Microsoft Excel

VS Code Marketplace Installs Downloads

Build MCP Server Build CLI Release

License: MIT .NET Platform Built with Copilot

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 230 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-skill-engineering. 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)

🎯 What You Can Do

25 specialized tools with 230 operations:

  • 🔄 Power Query (1 tool, 12 ops) - Atomic workflows, M code management, load destinations
  • 📊 Data Model/DAX (2 tools, 19 ops) - Measures, 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, 29 ops) - Create, configure, series, formatting, data labels, trendlines
  • 📝 VBA (1 tool, 6 ops) - Modules, execution, version control
  • 📋 Ranges (4 tools, 46 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, workbook creation, IRM/AIP-protected file support
  • 🧮 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 230 operations

💬 Example Prompts

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"
  • "Apply the same section-header styling to A1:G1, A12:G12, and A24:G24 in one step"

Formatting split: number display formats use the range tool, while visual styling and auto-fit use range_format.

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..."

👥 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:

  • ❌ 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)

🚀 Quick Start

PlatformInstallation
VS CodeInstall Extension (one-click, recommended)
Claude DesktopDownload .mcpb from latest release
Any MCP ClientDownload mcp-excel.exe from latest release and add to PATH
Details📖 Installation Guide

⚠️ Important: Close all Excel files before using. The server requires exclusive access to workbooks during automation.

🔧 CLI vs MCP Server

This package provides both CLI and MCP Server interfaces. Choose based on your use case:

InterfaceBest ForWhy
CLI (excelcli)Coding agents (Copilot, Cursor, Windsurf) + Scripting64% fewer tokens - single tool, no large schemas. Auto-generated from Core code, ensuring 1:1 feature parity. Bundled with excel-cli skill.
MCP ServerConversational AI (Claude Desktop, VS Code Chat)Rich tool discovery, persistent connection. Better for interactive, exploratory workflows.

Installation:

  • CLI via Copilot plugin (Recommended for Copilot CLI): Install the excel-cli plugin for skill guidance, then install excelcli separately
  • CLI Standalone: Download ZIP from releases or install via NuGet
  • Skill only: Install the excel-cli skill separately when your agent already has excelcli available on PATH
  • MCP Server: Download from releases or install VS Code Extension

⚡ 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.

📦 GitHub Copilot Plugins

ExcelMcp is available as two GitHub Copilot CLI plugins in the Copilot plugin marketplace:

powershell
# Register the plugin marketplace (one-time)
copilot plugin marketplace add sbroenne/mcp-server-excel-plugins

# Install one or both plugins
copilot plugin install excel-mcp@mcp-server-excel-plugins      # For conversational AI
copilot plugin install excel-cli@mcp-server-excel-plugins      # For scripting / coding agents
  • excel-mcp — MCP server for conversational workflows
  • excel-cli — Skill for coding agents (install excelcli separately if you want the CLI tool)

Note: After each release, there may be a short delay before plugins appear in the marketplace. You may need to wait a few moments for updates to sync.

📖 Full Installation Guide →

<details> <summary>📊 Benchmark Results (same task, same model)</summary>
MetricCLIMCP ServerWinner
Tokens~59K~163K🏆 CLI (64% fewer)

Key insight: MCP sends 23 tool schemas to the LLM on each request (~100K+ tokens).

</details>

Manual Installation:

powershell
# Primary: Download standalone executables from latest release (no .NET runtime required)
# https://github.com/sbroenne/mcp-server-excel/releases/latest
# - ExcelMcp-MCP-Server-{version}-windows.zip → extract mcp-excel.exe
# - ExcelMcp-CLI-{version}-windows.zip → extract excelcli.exe (optional, for scripting)

# Secondary: Install via .NET tool (requires .NET 10 runtime)
dotnet tool install --global Sbroenne.ExcelMcp.McpServer
dotnet tool install --global Sbroenne.ExcelMcp.CLI

# After installing either way, auto-configure all your coding agents:
npx add-mcp "mcp-excel" --name excel-mcp

⚠️ Step 2 requires Node.js for npx. Install with winget install OpenJS.NodeJS.LTS if needed.

powershell
# 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.

⚙️ How It Works - COM Automation & Unified Service Architecture

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:

code
┌─────────────────────┐     ┌─────────────────────┐
│   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!

📋 Additional Information

📚 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

Related Projects

Other projects by the author:

常见问题

Excel COM Automation 是什么?

面向 Excel COM 自动化的工具,支持 Power Query、DAX measures、VBA,以及 Tables、ranges 与 connections 管理。

相关 Skills

技术栈评估

by alirezarezvani

Universal
热门

对比框架、数据库和云服务,结合 5 年 TCO、安全风险、生态活力与迁移复杂度做量化评估,适合技术选型、栈升级和替换路线决策。

帮你系统比较技术栈优劣,不只看功能,还把TCO、安全性和生态健康度一起量化,选型和迁移决策更稳。

数据与存储
未扫描15.4k

资深数据科学家

by alirezarezvani

Universal
热门

覆盖实验设计、特征工程、预测建模、因果推断与模型评估,适合用 Python/R/SQL 做 A/B 测试、时序分析和生产级 ML 落地,支撑数据驱动决策。

从 A/B 测试、因果分析到预测建模一条龙搞定,既有硬核统计方法也懂业务沟通,特别适合把数据结论真正落地。

数据与存储
未扫描15.4k

资深架构师

by alirezarezvani

Universal
热门

适合系统设计评审、ADR记录和扩展性规划,分析依赖与耦合,权衡单体或微服务、数据库与技术栈选型,并输出Mermaid、PlantUML、ASCII架构图。

搞系统设计、技术选型和扩展规划时,用它能更快理清架构决策与依赖关系,还能直接产出 Mermaid/PlantUML 图,方案讨论效率很高。

数据与存储
未扫描15.4k

相关 MCP Server

SQLite 数据库

编辑精选

by Anthropic

热门

SQLite 是让 AI 直接查询本地数据库进行数据分析的 MCP 服务器。

这个服务器解决了 AI 无法直接访问 SQLite 数据库的问题,适合需要快速分析本地数据集的开发者。不过,作为参考实现,它可能缺乏生产级的安全特性,建议在受控环境中使用。

数据与存储
85.9k

by Anthropic

热门

PostgreSQL 是让 Claude 直接查询和管理你的数据库的 MCP 服务器。

这个服务器解决了开发者需要手动编写 SQL 查询的痛点,特别适合数据分析师或后端开发者快速探索数据库结构。不过,由于是参考实现,生产环境使用前务必评估安全风险,别指望它能处理复杂事务。

数据与存储
85.9k

by Firecrawl

热门

Firecrawl 是让 AI 直接抓取网页并提取结构化数据的 MCP 服务器。

它解决了手动写爬虫的麻烦,让 Claude 能直接访问动态网页内容。最适合需要实时数据的研究者或开发者,比如监控竞品价格或抓取新闻。但要注意,它依赖第三方 API,可能涉及隐私和成本问题。

数据与存储
6.3k

评论