Building mcp-server-xlsx: A Data-First MCP Server for Excel
I needed a stateless MCP server with dual-mode Excel file access: cell-level and SQL. Nothing quite fit my requirements. As I was forming the specification of what exactly I needed - the simplest path was to build one.
Before writing any code, I sat down and declared what I actually needed: a stateless MCP server that can do both precise cell-level operations and SQL-powered queries on .xlsx files, with both modes working interleaved on the same workbook.
With the spec in hand, I looked at what already exists - mostly utilizing Gemini. I tested excel-mcp-server and localdata-mcp. Both are functional, but neither fit. They burned through context window with verbose outputs and long tool descriptions. They also lacked the dual operational mode I was after. When your LLM agent wastes tokens on session management or reformatting data it already has, you feel it in every conversation.
So I built my own. mcp-server-xlsx is a single-file Python server offering 26 tools across two modes:
- direct cell operations via openpyxl (read, write, copy, search) and
- a DuckDB-powered SQL interface supporting JOINs, aggregates, and even INSERT/UPDATE/DELETE with atomic
writeback.
The worksheet mode deals with raw content and ignores graphics. The SQL mode is as raw as it can get. Every LLM understands the language out of the box, so why provide plethora of tools with needless descriptions. Every call is stateless: explicit file and sheet parameters, no handles, no sessions. Writes go through temp files with os.replace() for crash safety. Formulas come back as actual formula strings, not cached values. The design is deliberately minimal: data in, data out, no formatting side-effects, no wasted tokens.