Excel MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Excel MCP Serveropen sales.xlsx and write 5000 to cell B2"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Excel MCP Server — v1
An MCP server that exposes Excel operations (open/close files, read/write cells, create sheets, apply formulas, and run existing VBA macros by name) so an AI agent (Claude Desktop, Claude Code, or any MCP client) can call them.
Already tested in this sandbox
python demo/demo_test.pyResult: all 12 tools are registered correctly by the server, and the
full flow open → read/write cell → apply formula → create sheet (copy) → run macro → save → read back from disk to verify runs
correctly end-to-end using MockOpenpyxlBackend.
Important limitation of this demo: it runs on Linux (no Excel
installed), so the "macro" in the demo is a Python function registered
manually to mimic the call-by-name convention — it is not real VBA.
To run your actual .xlsm macros, this needs to run on a Windows
machine with Excel installed (see below).
Related MCP server: Excel MCP Server
Architecture
┌─────────────────────┐
Claude / AI agent │ MCP Client │
(Desktop, Code,...) │ (stdio transport) │
└──────────┬──────────┘
│ JSON-RPC over stdio
┌──────────▼──────────┐
│ server.py │ ← 12 tools: excel_open_workbook,
│ (mcp.MCPServer) │ excel_read_cell, excel_run_macro, ...
└──────────┬──────────┘
│ calls through a shared interface
┌──────────▼──────────┐
│ backends/base.py │ (ABC, OS-independent)
└──────────┬──────────┘
┌───────────┴────────────┐
┌────────────▼───────────┐ ┌─────────▼────────────┐
│ windows_com.py │ │ mock_openpyxl.py │
│ (xlwings + pywin32) │ │ (openpyxl, any OS) │
│ - drives real Excel.exe │ │ - test/dev only, does │
│ - runs real VBA macros │ │ NOT run real VBA │
│ in .xlsm files │ └────────────────────────┘
│ - dedicated COM thread │
│ to avoid STA errors │
└─────────────────────────┘server.py automatically picks the backend: platform.system() == "Windows" → WindowsComBackend, otherwise → MockOpenpyxlBackend
(with a warning printed to stderr).
Why xlwings instead of raw win32com?
You already have experience using pywin32 directly (the Outlook RSVP
Tool). For Excel, xlwings is a better fit because:
wb.macro("MacroName")(*args)calls a VBASub/Functiondirectly by name, whether it lives in a regular Module or inThisWorkbook.The cell/range API (
sheet.range("A1").value) is much cleaner than raw COM'sworksheet.Cells(1,1).Value.It still uses pywin32 under the hood, so you don't lose the ability to "drop down" to raw COM (
wb.api,sheet.api) for advanced operations (pivot tables, charts, the VBA editor...) that xlwings doesn't wrap yet.
Why a dedicated COM thread?
Excel COM is single-threaded apartment (STA). If multiple tool calls
arrive close together (an agent may call tools asynchronously), calling
COM directly from different threads/coroutines will crash or produce
"Application is busy" errors. The fix: a single background thread holds
CoInitialize(), and every command is pushed into a queue and executed
sequentially on that same thread — safe, simple, and fast enough for
the expected scale ("a handful of agents calling tools", not hundreds
of requests per second).
Installation
On a dev/test machine (no Windows required)
pip install -r requirements.txt
python demo/demo_test.pyOn a production Windows machine (with Excel + real macros)
pip install -r requirements.txt
python server.pyThe server will automatically detect Windows and use
WindowsComBackend.
Safety recommendation: restrict which macros can be run via an environment variable, so an AI agent can't call arbitrary macros on a real file:
$env:EXCEL_MCP_ALLOWED_MACROS = "GenerateSummary,RefreshPivot,ExportReport"
python server.pyConfiguring Claude Desktop
Add this to Claude Desktop's MCP config file
(%APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"excel-automation": {
"command": "python",
"args": ["C:\\path\\to\\excel-mcp-server\\server.py"],
"env": {
"EXCEL_MCP_ALLOWED_MACROS": "GenerateSummary,RefreshPivot"
}
}
}
}For Claude Code, add it the same way to the project's MCP server
config (via .claude or the claude mcp add command).
Tool list (v1)
Tool | What it does |
| Opens a file, returns |
| Closes a file |
| Lists currently open files |
| Lists sheet names |
| Reads one cell |
| Reads a range |
| Writes one cell |
| Writes a 2D array |
| Applies a formula |
| Creates/copies a sheet |
| Runs a VBA macro by name |
| Saves / save-as |
Next steps (not part of this v1)
Test with your actual
.xlsmmacros on a Windows machine — need the specific Sub/Function names and argument counts to verifyexcel_run_macroworks as expected.Handling multiple workbooks concurrently more carefully — currently a single shared
xlwings.Appis used; if full isolation is needed (e.g. 2 agents working on 2 independent files without affecting each other's global Excel settings), separateAppinstances could be used instead — at the cost of more RAM/CPU.Idle timeout: automatically close workbooks and shut down the
Appif no command arrives within N minutes, to avoid a hidden Excel process silently eating RAM if an agent forgets to close it.Logging/audit: log every write/macro command (who called it, when, which macro, which arguments) — important since macros are arbitrary code execution.
Retry/file-lock handling: handle the case where you already have the file open manually in Excel while the agent also tries to open it — currently this raises a COM error that should be caught and turned into a clear message.
Consider
streamable-httptransport instead ofstdioif you want multiple different clients/agents to connect to one long-running server process, instead of each Claude Desktop instance spawning its own server process.
Related MCP Connectors
An agent-first office suite Claude & ChatGPT read and write over one MCP URL.
Connect Amazon Seller Central to Claude or ChatGPT via MCP. Orders, inventory, pricing, fees, FBA.
MCP connector that lets ChatGPT list, search, and run your Apple Shortcuts via a local Mac agent
AXL MCP lets AI assistants create and manage landing pages, courses, email campaigns, CRM records, and marketing workflows inside AXL. Built for growing expert businesses, it turns chat requests into real work across sales, marketing, and course delivery. An AXL account is required. Sign in securely with OAuth 2.1. Website: https://axl.tech/developers/mcp . Setup guide: https://docs.axl.tech/mcp . Watch AXL in 77 seconds: pages, courses, CRM, and automation. Product overview: https://www.youtube.com/watch?v=jlhR9CafIww
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceA thin wrapper around the OpenPyXl Python library that exposes Excel file operations as a Model Context Protocol (MCP) server, allowing Claude and other MCP clients to fetch and analyze data from Excel files.19MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to perform comprehensive Microsoft Excel operations including data analysis, cell editing, advanced formatting, and VBA execution on Windows systems. It provides a structured workflow for managing workbooks and worksheets through a dedicated Model Context Protocol interface.595 npm4MIT
- AlicenseCqualityAmaintenanceLocal-first Excel MCP server for AI agents enabling structured reads, workbook introspection, and safer .xlsx mutation without Microsoft Excel or LibreOffice.7823 PyPI2MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server that lets you manipulate Excel files without needing Microsoft Excel installed. Create, read, and modify Excel workbooks with your AI agent.MIT