Excel MCP server: Let Claude edit spreadsheets, draw charts, and create pivot tables

Author’s note: This is a walkthrough for connecting to the Excel MCP server. First we tighten permissions, then wire it into Claude Code, Codex, and Gemini CLI. Next we’ll use a sales workbook to demo editing sheets, drawing charts, and building pivot tables — and wrap up with the token cost math.

The usual workflow for getting AI to help with Excel goes something like this: the model hands you an openpyxl or pandas script, you set up the environment yourself, run it, read the error, then paste the error back. For ops and finance people who spend the whole day in spreadsheets, that single step is where most of them give up. Developers can run scripts just fine, but even they don’t want to juggle multiple windows just to fix one pivot table.

The Excel MCP server does it differently: it turns workbook read/write into a set of MCP tools that a Large Language Model like Claude can call directly. The open-source project used here is haris-musa/excel-mcp-server. The repo page shows 4,327 stars, an MIT license, and an implementation built on Python and openpyxl — no Microsoft Excel installation required, and it runs on Windows, macOS, and Linux.

This isn’t another Excel formula tutorial. This article answers just four questions: how far can this MCP server take a workbook, will a table with hundreds of thousands of rows blow out the context window, how many tokens does one complex operation cost, and how do you lock permissions down.

What you’ll get: after reading this, you’ll have one install command, three client setups, the --allow-dir plus --read-only safety combo, and a method for reading large tables in pages along with cost estimates.

excel-mcp-server-claude-edit-chart-pivot-en-image-0


Excel MCP Server: Key Takeaways

The table below organizes the capabilities listed in the repo’s README by “what it can change,” so you can quickly judge whether it covers what you need right now.

Capability Scope supported per the repo What it means for you
Charts Column, bar, line, area, pie, doughnut, radar, scatter, bubble; combo charts, secondary axes, trendlines, error bars; the chart types Excel 2016 added — waterfall, histogram, Pareto, box & whisker, treemap, sunburst, funnel The model can generate the charts you use in weekly and monthly reports directly
PivotTables Grouping, calculated fields, show-values-as settings, layout, filtering, plus slicers and timelines Interactive summary tables without dragging fields by hand
Formulas A calculation engine with 479 built-in functions; FILTER, SORT, UNIQUE, SEQUENCE, LET and other dynamic arrays are written the way Excel stores them and spill Files that have never been opened in Excel still return computed results
Data and formatting Tables, conditional formatting, data validation, sort and filter, find and replace, remove duplicates, text-to-columns, freeze panes, worksheet protection, comments, defined names, and more Covers most of the day-to-day spreadsheet tidying you’d do
Large files Streaming, paginated reads; worksheets whose XML exceeds 1MB only parse the rows that changed No need to stuff the whole big sheet into the context window
File formats .xlsx, .xlsm (macros preserved), .xltx, .xltm Macros survive the edit

Excel MCP Server deep dive: the formula engine and sparklines

The formula capability is the easiest one to underestimate. openpyxl itself only stores formula text — it doesn’t do any calculating. In a file that’s never been opened in Excel, cells often hold just the formula and no cached value. The repo says it ships a calculation engine covering 479 functions and has validated it against more than 25,000 real-world Excel formulas, so the model can read the computed result of =SUMIFS(...) directly — no need to ask you to open the file in Excel and save it first. On top of that, it can trace precedents and dependents, step through evaluation, and run Goal Seek, which makes questions like “where did this number come from?” a lot easier to chase down.

Sparklines come in three flavors: line, column, and win/loss. When rows or columns are inserted or deleted, the references update along with them — which matters especially for financial sheets, because a row the model inserts in the middle won’t throw all the summary formulas below it out of alignment. The macro rules are fairly conservative: VBA code is read-only by default, writing VBA requires explicitly adding --allow-vba-write, and the server itself never runs macros.


Excel MCP server security boundary: lock down permissions before connecting

Before you connect, establish the permission boundary. An MCP server gets local file read/write access on your machine, and one mistaken write from the model can overwrite a report that has no backup. The parameters in the table below all come from the repository README; read through them before you start.

Parameter / variable What it does Recommended use
--allow-dir Only allow access to the specified directory; can be passed multiple times Create a dedicated working directory and put only the copies you want to process there
EXCEL_FILES_PATH Specify allowed directories via an environment variable; separate with : on macOS/Linux and ; on Windows Useful when there are many directories and the command line gets too long
--read-only Read-only mode; blocks all write operations Turn it on for initial setup and when you’re only doing analysis and Q&A
--tools data,charts Expose only selected tool groups When you only need data cleanup and charting, leave the other capabilities disabled
--allow-vba-write Allow VBA writes Don’t add it by default; the server never executes macros
EXCEL_MCP_AUTH_TOKEN Authentication token when HTTP mode is exposed externally HTTP mode only listens on localhost by default; you must set this when exposing it externally

Recommended: loosen permissions gradually in the following three tiers:

  • Tier 1: Read-only analysis. Use both --allow-dir and --read-only so the model can only read, not modify. First confirm that its understanding of the spreadsheet structure is accurate.
  • Tier 2: Scoped write access. Remove --read-only, add --tools data,charts, and expose only the data cleanup and chart tool groups.
  • Tier 3: Full write access. Expose all tools only in the copy directory. Keep the original files outside --allow-dir so the model can’t reach them.

excel-mcp-server-claude-edit-chart-pivot-en-image-1


Excel MCP Server Quick Start: Three Client Setup Methods

The setup commands for the three clients share basically the same structure; the difference is in how registration and scope are written. The table below summarizes the differences, and the exact commands are in the steps that follow.

Client Registration subcommand Scope syntax Best for
Claude Code claude mcp add --scope user, available across all projects Developers already using Claude to write code in the terminal
Codex codex mcp add Default configuration OpenAI ecosystem users
Gemini CLI gemini mcp add -s user Google ecosystem users

Step 0: Confirm uvx is available

  • Run uvx excel-mcp-server stdio in the terminal to start the server directly in stdio mode.
  • Acceptance criteria: After the command runs, it stops at a waiting-for-input state without exiting with an error. That means the dependencies were pulled successfully; press Ctrl+C to exit. If you get a message saying uvx can’t be found, install uv first.

Step 1: Connect Claude Code

  • Run: claude mcp add excel --scope user -- uvx excel-mcp-server stdio --allow-dir /path/to/workbooks
  • For the first run, it’s best to add --read-only at the end, then remove it once you’ve confirmed everything works.
  • Acceptance criteria: Run claude mcp list and you should see a service named excel; in a conversation, ask “List the workbooks under the workbooks directory” and the model should return the file names.

Step 2: Connect Codex

  • Run: codex mcp add excel -- uvx excel-mcp-server stdio --allow-dir /path/to/workbooks
  • Acceptance criteria: In a Codex session, ask the model to read the worksheet names in a workbook, and it should return them correctly.

Step 3: Connect Gemini CLI

  • Run: gemini mcp add -s user excel uvx excel-mcp-server stdio --allow-dir /path/to/workbooks
  • Acceptance criteria: In Gemini CLI, ask the model to read the headers of any sheet, and the result should match the actual file contents.

Step 4: Fill in the uvx path for desktop clients

  • Desktop apps like Claude Desktop and Cursor don’t always inherit the terminal’s PATH when they launch, so they may not find uvx.
  • Run which uvx in the terminal (on Windows, use where uvx) to get the absolute path, then replace uvx in the configuration with that full path.
  • Acceptance criteria: After restarting the client, the MCP status should show the excel service as connected, with no startup failure message.

🚀 Quick start: The MCP server itself doesn’t consume tokens; the cost comes from the Large Language Model driving it. If you also want to test the same workflow with your own script or agent, you can use a single key at APIYI apiyi.com to call Claude, Gemini, DeepSeek, and other models. New users get free testing credits — get a small sheet working first, then move on to real data.


Hands-On with an Excel MCP Server: A Sales Workbook

Below, we’ll walk through a fictional sales_2026.xlsx. It has a “Details” sheet with 8 columns — date, region, product, salesperson, quantity, unit price, amount, channel — and about 1,000 rows. Every instruction is sent to Claude Code in natural language, without writing a single script.

Editing the sheet: cleaning and formulas

  • Instruction: “Check whether Amount in the Details sheet equals Quantity times Unit Price, highlight mismatched rows in yellow; delete fully duplicate rows; freeze the top row.”
  • The model first reads the data page by page, then calls the tools for conditional formatting, deleting duplicates, and freezing panes.
  • Acceptance criteria: Open the file in Excel and the first row stays put; the number of duplicate rows matches what the model reported; spot-check 3 of the yellow-highlighted rows and confirm they really are miscalculated.

  • Instruction: “In the Summary sheet, use UNIQUE in A2 to list all regions, and use SUMIFS in B2 to total the amount for each region.”

  • Acceptance criteria: The dynamic array spills normally with no #SPILL!; with Excel not even open, the model can still read the calculated values in column B directly.

Charting: a combo chart with a secondary axis

  • Instruction: “Total the amount and order count by month, generate a combo chart with columns plus a line, put the order count on a secondary axis, and add a trendline to the amount.”
  • Acceptance criteria: The two series in the chart use different axes, the trendline displays correctly, and the chart’s data source points to the summary range rather than hard-coded values.

Building a pivot table: slicer and timeline

  • Instruction: “Create a new worksheet with region as rows, product as columns, and sum of amount as values, with values shown as a percentage of row totals; add a channel slicer and a date timeline.”
  • Acceptance criteria: Clicking different channels on the slicer in Excel refreshes the pivot table accordingly; the timeline can filter by month; each row’s percentage adds up to 100%.

Wrapping up: sparklines

  • Instruction: “Add a line sparkline column after each region in the Summary sheet, showing the 12-month trend.”
  • Acceptance criteria: Each row has its own sparkline, the data ranges correspond row by row, and nothing is misaligned so that everything points to the same row.

Handling Large Tables with the Excel MCP Server: Paged Reads and Context Control

“Will hundreds of thousands of rows blow up the context?” That depends on how you read them. The server’s read API returns results in a streaming, page-by-page manner. According to the repository’s own description, for worksheets whose XML exceeds 1MB, only the changed rows are parsed, and inserting, deleting, sorting, copying, and creating pivot tables on a 200,000-row worksheet all take seconds. In other words, server-side processing speed isn’t the bottleneck—what you really need to control is how much content you let the model read.

It’s a good idea to spell out three constraints in your instructions:

  1. Read the header and the first few dozen rows first, so the model understands the structure before deciding what to do next. Don’t start by “reading the entire sheet.”
  2. Only read the changed range, for example, “only look at October 2026 data,” so the model filters before reading.
  3. Leave aggregation to Excel: have the model write SUMIFS formulas or create a pivot table, let the server do the calculation, and have the model read only the summary results.

excel-mcp-server-claude-edit-chart-pivot-en-image-2

How the token math works for an Excel MCP server

MCP calls consume three kinds of tokens: tool definitions, the model’s reasoning and instructions, and the table contents returned by the tools — with table contents making up the biggest share. The table below lists a few models from the APIYI pricing page (docs.apiyi.com/models) that suit this kind of task. Prices are in USD per million tokens, data as of 2026-11-27. Model IDs follow the apiyi.com model list.

Model ID Input Output Cache read Good fit for Excel tasks
claude-opus-5-5 $4 $20 $0.2 Complex pivot table design, cross-sheet formula debugging
claude-haiku-5-5 $0.1 (0–100,000 tier) / $0.5 (above 100,000 tier) $0.5 $0.01 Batch formatting, cleanup, read-and-answer
qwen3.8-flash $0.114 $0.3876 $0.01425 Simple reads, classification and labeling
deepseek-v4.1-flash $0.3 $1.2 $0.006 Formula generation, moderately complex sheet edits

Here’s a rough estimate: a 1,000-row × 8-column worksheet has about 8,000 cells. At 5 tokens per cell, that’s roughly 40,000 tokens. Reading the whole thing once with claude-opus-5-5 costs about $0.16; with claude-haiku-5-5 it’s about $0.004. If you use the paginated reading approach from the previous section, read only the changed regions, and filter before computing, a single operation can shrink to a few thousand tokens. At the same unit prices, even Opus comes out to just a few cents per read.

The tiered pricing on claude-haiku-5-5 is worth noting: once a single request’s input exceeds 100,000 tokens, the unit price jumps from $0.1 to $0.5. Cramming a big sheet into one request doesn’t just strain the context window — it also pushes you into the higher tier. That’s one more reason to stick with paginated reading. Cache reads are priced far below input, so if your client supports prompt caching, the recurring tool definitions and system prompt get billed at the cache rate.

excel-mcp-server-claude-edit-chart-pivot-en-image-3

If you want to reproduce this workflow in your own scripts, or run model comparisons, you can set it up like this:

  • Set the OpenAI SDK’s base_url to https://api.apiyi.com/v1, and put an API key generated in the APIYI dashboard into api_key.
  • To switch models, you only change the model parameter — say, from claude-haiku-5-5 to deepseek-v4.1-flash. The protocol and endpoint stay the same.

💰 Cost tip: Send routine cleanup and formatting to the Haiku or Flash family. Only switch to Opus when you need to design pivot table structures or troubleshoot complex formulas. Switching models under the same API key lets you directly compare what the two tiers cost on your own spreadsheets.


Common Errors and Troubleshooting for the Excel MCP Server

Symptom Cause What to do
Desktop client says it can’t find uvx The desktop app doesn’t inherit your terminal’s PATH Get the absolute path with which uvx or where uvx and put it in the config
Model says it doesn’t have permission to access a file The file isn’t inside the --allow-dir allowlist Copy the file into an allowed directory, or add another --allow-dir
Every write operation fails The server was started with --read-only Once you’ve confirmed the analysis phase is done, drop that flag and re-register
Model says it can’t find the charting or PivotTable tools --tools doesn’t include the matching tool group Adjust the --tools value, or remove the flag altogether
VBA writes get rejected --allow-vba-write wasn’t added Only turn it on explicitly after you’ve confirmed you really need it
The macro was written but never runs The server never executes macros — that’s by design Run the macro manually in Excel
.xls files can’t be processed That format isn’t on the supported list Save as .xlsx or .xlsm in Excel
Other machines can’t connect in HTTP mode By default it only listens on localhost Set EXCEL_MCP_AUTH_TOKEN before exposing it to the network
Conversations get slower and more expensive The whole big sheet was read in one shot Switch to reading the header plus a sample of rows, and let formulas or PivotTables handle the aggregation

FAQ

Q1: What is the Excel MCP server?

It’s an MCP protocol service that wraps Excel workbook reading and writing, charts, pivot tables, and formula calculation into tools that Large Language Models in clients like Claude Code, Codex, and Gemini CLI can call directly. It’s built on openpyxl, so it doesn’t rely on a locally installed copy of Excel.

Q2: How is it different from having the AI write a Python script to handle Excel?

With the script approach, you’re the one running it and debugging it — great for one-off batch jobs. The Excel MCP server has the model call tools directly and read the result of each step, which suits interactive scenarios where you tweak as you go. On top of that, its built-in formula engine can read formula values from uncalculated files — something plain openpyxl can’t do.

Q3: Can it handle sheets with hundreds of thousands of rows?

Server-side, yes. The repo’s README claims that insert, sort, and pivot table operations on a 200k-row worksheet all complete in seconds. What you need to control is how much data the model reads: page through headers and samples, and let pivot tables or formulas handle the statistics, so you don’t blow out the context window.

Q4: Roughly how much does one complex operation cost?

At an estimated 5 tokens per cell, fully reading a 1,000-row × 8-column table takes about 40k tokens. With claude-opus-5-5 that’s roughly $0.16; with claude-haiku-5-5 it’s about $0.004 (prices from the APIYI apiyi.com pricing page, data date 2026-11-27). Once you switch to paged reading, a single operation usually only needs a few thousand tokens.

Q5: Which model should drive it?

Use Opus for reasoning-heavy work like designing pivot table structures and debugging cross-sheet formulas. Haiku or the Flash series is enough for formatting, cleaning, and simple Q&A. A good approach: run both tiers against the same copy of the workbook, compare actual token consumption in the APIYI dashboard, then decide which one to use as your daily default.

Q6: Will it accidentally delete my original files?

As long as the original files aren’t inside the `–allow-dir` whitelist, the service can’t reach them. It’s best to do all your work inside a copy directory, and add `–read-only` the first time you set it up.

Q7: Are .xlsm files with macros safe?

The service preserves macros. By default it can only read VBA code; writing VBA requires explicitly adding `–allow-vba-write`, and the service never executes macros. Whether a macro runs is always your call inside Excel.


Excel MCP Server: Key Takeaways

  • Works without Excel installed: it’s built on Python and openpyxl, so it runs on all three desktop platforms.
  • Broad capability coverage: charts, pivot tables, slicers, and dynamic array formulas can all be written directly by the model.
  • Security first: start with --allow-dir plus --read-only for a read-only connection, then open up write access gradually.
  • The three integration paths share the same structure: Claude Code, Codex, and Gemini CLI all use mcp add plus a uvx launch command.
  • Paginate large tables: read the header and a sample, hand aggregation off to a pivot table, and keep the whole sheet out of the context window.
  • Costs are predictable: roughly 5 tokens per cell — you can compare input, output, and cached-read pricing across models at APIYI apiyi.com.

Summary

The value of the Excel MCP server is that it turns “AI writes the script, a human runs it” into “AI edits the workbook directly, a human signs off on it.” Let’s recap the key points:

  1. Draw the boundaries first: point --allow-dir at a copy directory, add --read-only for the first connection, and then use --tools to limit capabilities once you need write access.
  2. Then connect the client: a single uvx excel-mcp-server stdio gets it running, each of the three CLIs registers it with one mcp add command, and desktop clients should remember to supply the full uvx path.
  3. Do the math last: read in pages, let Excel handle aggregation, use a lightweight model for everyday tasks, and only switch to a flagship model for complex design work.

Cases where this setup isn’t the right fit: online spreadsheets that multiple people need to edit together in real time; audit working papers where a human has to sign off on every single number; workflows that depend on macros running automatically (the server doesn’t run macros); and batch jobs that a fixed script can run on a schedule with no interaction — for those, writing a script saves you tokens.

If you want to test the waters with a small table first, you can claim free trial credits through APIYI apiyi.com, switch between models on the same endpoint, and see which tier gives you the best balance of quality and cost for your spreadsheets.


📚 References

  1. GitHub – excel-mcp-server: Project repository and README

    • Link: github.com/haris-musa/excel-mcp-server
    • Notes: For installation commands, the full parameter list, and capability descriptions, refer to the latest version in the repository
  2. APIYI Model Pricing: Input, output, and cache-read prices for each model

    • Link: docs.apiyi.com/models
    • Notes: The pricing data in this article is dated 2026-11-27. Before making calls, please refer to the live data on the page
  3. Model Context Protocol Official Docs: MCP protocol documentation

    • Link: modelcontextprotocol.io
    • Notes: Explains the difference between the stdio and HTTP transport methods

Author: APIYI Technical Team
Technical Discussion: Feel free to contact us via the APIYI homepage. For more integration resources, visit the docs.apiyi.com documentation center

Leave a Comment