1. Spreadsheet docs
  2. Developers

Excel files for AI agents

Let an AI agent open, read, fill, calculate and save Excel files in Node, with an MCP server built on 8sheets and no Excel or LibreOffice.

An agent that works with spreadsheets has to do three things well: read what is in the file, see what its formulas give after a change, and hand back a file that is otherwise as it was. 8sheets does all of it in plain Node:

  • It calculates. 502 Excel functions, checked against real Excel results, run in the same process. The agent sees a formula's result and its errors right after writing it.
  • It makes reports. Formats, tables, conditional formats, charts and PivotTables it adds are Excel's own: the people who get the file can change them. The same workbook goes out as a PDF.
  • It keeps the file. Charts, pictures, PivotTables, conditional formats, macros and parts 8sheets doesn't use stay in the saved file. Charts follow inserted rows and renamed sheets.
  • Nothing else to install. No Excel, no LibreOffice, no browser, no native modules, and no network.

From your own code

Give your agent a tool that runs code like this:

import { openAsBlob } from 'node:fs';
import { createWorkbook } from '@8sheets/core';

export async function whatIf(path, cell, value, resultCell) {
  const wb = createWorkbook();
  try {
    await wb.openFile(await openAsBlob(path), { name: path });
    wb.activeSheet.range(cell).values = value;
    await wb.whenCalculated();
    return wb.activeSheet.range(resultCell).values[0][0];
  } finally {
    wb.destroy();
  }
}

Workbooks in Node covers opening and saving, and Working with data the rest of the API, which is the same as in a page.

The MCP server

@8sheets/mcp is an MCP server: one readable file that depends on @8sheets/core alone. Start it with the folders it may use (Node 22.3 or newer, or 20.16 or newer of version 20):

npx -y @8sheets/mcp ~/Documents/workbooks

Most clients take a command and its arguments:

{
  "mcpServers": {
    "8sheets": {
      "command": "npx",
      "args": ["-y", "@8sheets/mcp", "/path/to/workbooks"]
    }
  }
}

In Claude Code: claude mcp add 8sheets -- npx -y @8sheets/mcp /path/to/workbooks.

One person may use the server free of charge, on their own computer, for themselves and with their own files. A company that runs it for its staff, use for other people, and use in a product need a licence.

ToolWhat it does
open_workbookOpens an Excel or CSV file and calculates it
new_workbookMakes an empty workbook
read_rangeValues of a range, with the formulas when asked
set_cellsWrites values and formulas, calculates, and returns the results and errors
add_sheetAdds a sheet
format_cellsNumber format, font, fill, alignment, borders, merged cells
set_sizesColumn widths, fitted to the cells when none is given, and row heights
add_tableMakes an Excel table, with a totals row when asked
add_conditional_formatColors cells by value, text or formula; color scales, data bars, icons
set_sheetName, frozen rows and columns, gridlines, tab color, page setup
add_chartAdds a chart of a range, with a title, a place and a size
add_pivot_tableAdds a PivotTable and returns its cells
refresh_pivot_tablesReads the PivotTables' sources again
find_errorsLists formulas that give an error
save_workbookSaves .xlsx or .xlsm, replacing a file only when told to
save_pdfWrites sheets as a PDF, with charts, shapes and PNG or JPEG pictures
close_workbookCloses it

The server reads and writes only in the folders you name and follows no link out of them. --read-only leaves out the tools that write. Formulas reach no other site or file.

Cell contents are data A workbook from someone else can hold text that reads like instructions to an agent. The server tells its client so. Give an agent only folders whose files you would open yourself, and keep a copy of files it may change.

Limits

  • One call reads or writes at most 10,000 cells, and eight workbooks can be open at once.
  • The server refuses password-protected files. From your own code, pass { password } to openFile.
  • Data sheets read as plain cells, and slicers are kept but not made or changed by the tools; see Workbooks in Node.