logisheets-mcp
logisheets-mcp
一个真正让您的AI代理能够进行思考的电子表格引擎。
一个MCP服务器,为任何LLM代理提供一个真正的、兼容Excel的计算引擎——具备它可以按语义寻址的结构化内存,以及最终一个人类可以打开、审计并继续使用的真正的.xlsx文件。
基于LogiSheets构建,这是一个用Rust编写的电子表格引擎。MIT许可,可自行托管,无云依赖。
为什么
代理正在做真正的工作,而这些工作往往是电子表格形态的——财务模型、数据核对、分析——而它们恰恰在电子表格引擎擅长的方面表现糟糕。
算术。 代理会算错总和和乘积。在这里它们不必如此:它们编写一个公式,由确定性引擎来求值。
内存。 在三十步的任务中,中间状态必须存在于某个结构化的地方。上下文窗口是有损且昂贵的;代码沙箱的变量会消失。这个服务器为代理提供了一个外部结构化磁盘,它可以在整个任务中读写。
寻址。 代理不擅长空间推理,所以原始网格是一个脆弱的表面——它们会丢失事物的位置,而它们自己的编辑会破坏它们的引用。因此代理不寻址C7。它寻址**(block, row_key, field)**:
设置
revenue块中2025记录的price字段
插入一行,移动块,添加一列——该地址仍然可以解析。这就是全部要点:能够经受住代理自身编辑的内存。
对比Python沙箱
代码解释器可以计算,但你得到的是一个一次性的脚本结果。在这里你得到一个真正的.xlsx,其中仍然包含实时公式——在Excel中打开它,更改一个输入,模型就会重新计算。它可以往返处理人类现有的文件,并且它在你的机器上运行,这在数据不能离开时很重要。
Related MCP server: Excel MCP Server
安装
需要Node 20+。
npm install -g logisheets-mcpClaude Desktop
添加到claude_desktop_config.json:
{
"mcpServers": {
"logisheets": {
"command": "npx",
"args": ["-y", "logisheets-mcp"]
}
}
}在macOS上,该文件位于~/Library/Application Support/Claude/claude_desktop_config.json;在Windows上,位于%APPDATA%\Claude\claude_desktop_config.json。之后重启Claude Desktop。
Cursor / Cline / 其他主机
任何能够启动stdio服务器的MCP主机都可以——将其指向logisheets-mcp命令。对于Cursor,将相同的块添加到~/.cursor/mcp.json。
试试看
为我构建一个三年收入模型:100个单位,单价9.50美元,每年增长40%,销售成本为30%。然后将其保存到~/model.xlsx。
代理创建一个块,填充它,编写公式,并交回一个文件。数字是引擎的,而不是模型的猜测——并且.xlsx中包含真正的公式,因此您可以在Excel中更改一个假设并观察它重新计算。
查看其工作方式
npm run build && npm run demo通过真实的MCP-on-stdio针对dist/cli.js构建一个小型收入模型——与Claude Desktop驱动的相同代码路径——并在进行时检查每个声明:引擎计算的总数、一个能够覆盖后来添加的行的规则、在模型在其下方增长后仍能继续解析的块,以及一个通过读取文件自身字节来验证其公式的真正的.xlsx。不涉及LLM;引擎是主体,硬编码调用是使保证可检查而不是关于聊天会话的故事的原因。
代理循环
list_blocks orient: what do I have?
create_block open a structured workspace
add_block_rows / set_block_cells fill it, addressed by (block, key, field)
eval_formula / a stored formula the engine does the math
describe_block read structured results back
save_workbook hand the human a real .xlsx工具
默认表面故意很小——20个工具。随着列表的增长,工具选择准确性会下降,并且每个描述在每一轮都会消耗上下文。
工具 | 功能 |
| 启动一个新的工作簿,或从磁盘加载现有的 |
| 写入一个真正的 |
| 文件作为base64,适用于没有共享文件系统的主机。 |
| 每个工作表和块,以及下一个块应该去的位置。 |
| 块的模式、键,以及(可选)其当前值。 |
| 评估一个Excel公式并返回值。不存储任何内容。 |
| 创建一个命名的、结构化的表。第一个字段是行键。 |
| 将已经位于普通单元格中的表就地转换为块。 |
| 添加记录——在末尾,或使用 |
| 删除记录。 |
| 按键重新排序行。仅用于展示:不改变任何计算值。 |
| 通过 |
| 为字段提供公式、验证规则或可编辑性规则。 |
| 哪些单元格违反了其字段的验证规则,以及原因。 |
| 编辑将会做什么,而不实际执行。一个假设,或一次调用中的整个场景网格。 |
| 一个单元格读取什么,以及什么读取它——来自引擎的依赖图。 |
| 什么输入使选定的输出等于目标。在引擎内部搜索;不改变任何内容。 |
| 添加一个工作表。 |
| 用于无结构数据的原始单元格逃生舱口。 |
公式与Excel兼容,外加用于语义读取块单元格的BLOCKREF(block, key, field)。在字段规则内部,#FIELD("name")是同一行的兄弟字段,#FIELD("name", "key")是同一块的另一行——即携带该键的那一行,绝不是位置偏移,因此重新排序行不会改变公式的含义。
分析模型,而不仅仅是构建模型
preview_changes接受一个scenarios列表和一个可选的watch,这正是将探索从数十次往返变成一次的原因:
{
"scenarios": [
{"label": "wacc 9%", "changes": [{"block":"assum","row_key":"wacc","field":"v","value":0.09}]},
{"label": "wacc 12%", "changes": [{"block":"assum","row_key":"wacc","field":"v","value":0.12}]}
],
"watch": [{"block":"valuation","row_key":"per_share","field":"v"}]
}每个场景在其自己的临时分支上运行并被丢弃,因此实时模型永远不会被触及——没有变异-回滚,如果扫描中途失败也不会留下任何东西。一个4×4的敏感性网格是一次调用返回十六个数字。
goal_seek反向运行相同的技巧——“什么贴现率使每股价值为30”——搜索在引擎内部而不是作为对话进行,因此它是一次调用而不是每次二分步骤一次。当目标在区间内根本无法达到时,它会说明,而不是返回它恰好停止在的最近数字。
trace从引擎的依赖图回答两个审计问题:一个单元格读取什么,以及什么读取它。第二个是它存在的原因——公式文本可以向前读取但不能向后读取,而“如果我更改这个会破坏什么”是您在触及假设之前想要的问题。
读取模型也是语义化的:describe_block返回每个字段的规则,因此代理无需访问单元格即可了解模型的逻辑,公式返回时命名它们读取的内容(B24 / BLOCKREF("assum","shares","v")),而不是您必须追踪的坐标链。
完整表面
设置LOGISHEETS_MCP_TOOLS=full以获得50个工具:撤销/重做、单元格格式、合并、注释、检查点、块移动/调整大小、跨块链接,以及原始行/列结构。
{
"mcpServers": {
"logisheets": {
"command": "npx",
"args": ["-y", "logisheets-mcp"],
"env": {"LOGISHEETS_MCP_TOOLS": "full"}
}
}
}变异工具使用MCP的readOnlyHint / destructiveHint注释进行标记,因此主机可以在用户批准后对其进行门控。
块,简要说明
块是工作表的一个命名的、结构化的区域——一个具有模式的表。
第一个字段是行键:每个记录的稳定名称。
字段可以携带值公式(引擎计算的,因此代理不能将过时的数字写入其中)、验证规则或可编辑性规则。
一切都按名称寻址。行和列索引永远不会进入代理的推理过程。
因为块是代理在工作时创建的,这不需要预先准备的文件——您可以将其指向一个空白工作簿或某人发送给您的电子表格。
作为库使用
import {createServer} from 'logisheets-mcp'
import {StreamableHTTPServerTransport} from '@modelcontextprotocol/sdk/server/streamableHttp.js'
const {server, session} = createServer({mode: 'full'})
await server.connect(new StreamableHTTPServerTransport(/* … */))createServer返回MCP Server、WorkbookSession和工具映射,因此您可以在任何传输上托管它或将其嵌入到代理框架中。
开发
服务器是三个LogiSheets包之上的一个薄壳:
logisheets-runtime(无头引擎)、logisheets-logician(代理工具定义)以及Rust/WASM核心。单独处理服务器不需要任何特殊操作:
git clone https://github.com/logisky/logisheets-mcp.git
cd logisheets-mcp
npm install
npm test同时处理引擎是另一种模式。将LogiSheets作为同级目录检出,构建其包,然后:
npm run link:local # re-run after any npm install这将三个包符号链接到node_modules中,以便本地引擎更改无需重新安装即可生效。scripts/release-deps.mjs在发布前将注册表范围放回。
发布
一个标签即可完成。.github/workflows/publish.yaml运行测试,使用来源发布到npm,并向MCP注册表注册新版本:
npm version 0.2.0 # bumps both files, commits, tags v0.2.0
npm run check-release # optional; CI runs it too
git push --follow-tags该工作流也可以从Actions选项卡手动运行,此时版本取自package.json而不是标签。npm步骤会跳过已发布的版本,因此在注册表步骤失败的一次运行可以简单地重新运行——两次发布不是事务。
npm version还通过version生命周期脚本重写server.json。注册表在两个地方保留版本——服务器自身的version以及它指向的npm包的版本——而手动编辑它们是最可能被遗漏的步骤。
check-release是门禁。四件事必须一致:标签、package.json以及server.json的两个版本字段。mcpName还必须等于server.json的name,因为注册表通过读取已发布的npm包中的mcpName来证明所有权。npm publish无法撤销——版本号一旦落地就花费了——因此工作流在发布之前运行此检查,而不是之后。
注册表认证不需要秘密:工作流使用GitHub OIDC进行认证,这正是授予io.github.logisky/命名空间的方式。唯一的秘密是NPM_TOKEN。
取回文件
save_workbook写入一个真正的.xlsx,其结果携带一个MCP资源链接——一个uri、媒体类型和大小——而不是文件。工作簿也作为资源列出(workbook://current.xlsx),因此想要字节的主机使用resources/read读取它们并将下载交给人类。
这种分离是重点:工具结果进入模型的上下文,而一个200 KB的工作簿将花费大约280 KB的文本,并且不会教给模型任何东西。链接只花费一行。export_xlsx仍然为根本不实现资源的主机返回base64,但它是后备方案,而不是机制。
读取与工具调用走相同的序列化通道,因此获取文件的主机永远不会捕获到半应用的事务。
open_workbook 和 save_workbook 在服务器进程可访问的任何位置进行读写——这对于本地 stdio 服务器来说是正常的,与官方 filesystem 服务器的姿态相同。两者都被标记为 mutating,以便主机可以在运行前提示;如果需要更严格的限制,请以仅具有预期访问权限的用户身份运行服务器。
状态模型
一个 MCP 会话持有一个活动工作簿,在工具调用之间保持存活——这种持久性使其成为内存而非计算器。open_workbook 会替换它。每个会话多个命名工作簿的功能可能会在以后添加。
无网络
服务器不打开任何套接字,也不监听任何端口。"stdio transport" 是字面意思:您的 MCP 主机将其作为子进程启动,并通过其 stdin 和 stdout 交换换行分隔的 JSON-RPC——与任何命令行程序获得的管道相同。引擎是在同一进程中运行的 WASM,因此公式是函数调用,而不是请求。
检查而非断言。在完整会话之后——创建块、附加字段规则、计算公式、保存 .xlsx——进程持有:
fd types: {CHR: 2, DIR: 4, KQUEUE: 3, PIPE: 6, REG: 13}
network files (lsof -a -i): 0
unix sockets (lsof -a -U): 0
listening ports: 0六个管道,无套接字。不上传任何内容,不收集遥测数据,物理隔离的机器是运行此服务器的受支持方式。它在自身内存之外唯一接触的是您指定的文件——请参阅 Getting the file back 下的文件系统说明。
这就是 logisheets-mcp 二进制文件,即 MCP 主机运行的内容。将其 作为库使用 时,您可以附加任何您喜欢的传输方式,包括 HTTP——但那时套接字是您的,是刻意打开的。
许可证
MIT。属于 LogiSheets 项目的一部分。
Available Tools
32 toolsadd_block_rowsA
Add rows to an existing block. Appends at the end by default; pass after_key or before_key to insert at a position instead. Each row needs a key; values is an object keyed by field name. Fields with a value_formula are auto-materialized by the engine — don't pass them in values. Validation/editability shadows for the new rows are auto-installed by the engine at InsertRowsInBlock time, so no follow-up is needed. Also inserts the matching sheet rows (one block per sheet-row assumption — extends the sheet so downstream rows shift down).
Inputs: rows (required), block (required), after_key, before_key.
chart_deleteADestructive
Delete a chart. Get the chart_id from chart__list. Undoable, but it removes the chart and its formatting.
Inputs: chartId (required), sheetIdx (required).
chart_from_blockA
Chart a block by naming its fields, instead of working out which cells they occupy.
The chart stays bound to the block: it plots whatever the named fields hold, so records added to the block later appear on their own and inserting rows or columns cannot leave it pointing at the wrong cells. A col-schema block works the same way as a row-schema one.
Use edit__describe_block or inspect first if you do not know the field names. Blocks with a "random" schema have no field axis and cannot be charted this way — chart their cell range with chart__insert instead.
Fields are held by name. Renaming one breaks the link (the series goes empty); moving its column does not.
Inputs: blockId (required), sheetIdx (required), valueFields (required), title, +4 more.
chart_insertA
Insert a chart that reads its values live from the given ranges — editing those cells later updates the chart.
Look at the data first so the series are right: a column of labels belongs in categoriesRef, each column of numbers is one series, and its header is that series' name.
References are A1 (B2:B10, or Sheet2!B2:B10 to read another sheet). The chart is placed below the data unless anchor says otherwise.
Inputs: series (required), sheetIdx (required), chartType (required), title, +3 more.
chart_listARead-only
List the charts on a sheet — id, kind, title, the ranges each series reads, and where the chart sits. Call this before updating or deleting one.
Inputs: sheetIdx (required).
chart_updateA
Reconfigure an existing chart in place, keeping its position. Anything left out keeps its current value; an empty string clears a text field (title, axis title, number format). Get the chart_id from chart__list first.
Inputs: chartId (required), sheetIdx (required), title, numFmt, +10 more.
convert_to_blockA
Turn a table that already exists in ordinary cells into a block, in place, without touching its values.
This is how you adopt a workbook someone hands you. create_block is for new tables and refuses to write over existing data; this one takes the data as it stands and gives it a name, fields and row keys, so you can address it as (block, row_key, field) and reference it from formulas by name instead of by coordinate.
Give position and the counts for the DATA only, leaving out any header row. Field names come from the header row — pass header_row, or leave it out and the row directly above the data is used when it looks like titles. fields states them outright instead.
The row key is inferred: the first column whose values are all present and all different. Pass key_field to choose. Whatever is inferred is reported back, so check it — the key is how formulas and later edits name a row.
Converting is a one-time cost: the block and its schema survive saving and reloading, and afterwards the region behaves exactly like one created as a block.
Inputs: name (required), sheet (required), position (required), col_count (required), +4 more.
create_analysis_blockA
Add a block that analyses another one — a totals row, sitting directly below the table it summarises.
It is an ordinary block that declares which block it analyses, so its result is addressable like any other: BLOCKREF("<name>", "<label>", "<field>"). That is the point of it being separate — a total you can only look at is much less useful than one you can reference.
What the engine does with the declaration: it GENERATES each field's formula from it, so renaming a field of the source rebuilds the total instead of breaking it, and the total tracks the source as rows are added. Do not write the formulas yourself.
By default every number field of the source gets a SUM and everything else is left blank; pass aggregates to choose. Removing the source removes this block with it.
Read it back with describe_block: the analysis reports analyzes, the source reports analyzed_by. Never sum an analysis block alongside its source — that counts the same numbers twice.
Inputs: source (required), name, label, aggregates.
create_blockA
Create a structured block (table) on a sheet. fields[0] is the row-key column — the value BLOCKREF matches on, so it has to be unique per record; it is ordinary data you can write. Block ref name (name) is used as the first arg to BLOCKREF/BLOCKREFS in formulas.
Field types supported:
'string' / 'number' — plain text/numeric cells.
'boolean' — cell stores 0/1 or TRUE/FALSE; UI renders ✅/❌ if host has the widget set.
'enum' (+ enum_id) — cell stores variant id; UI renders dropdown if host has the widget set. Watson auto-injects a variant-whitelist validation formula on the field so out-of-set writes light up as warnings even without widget rendering. Requires a prior define_enum_set call with matching id.
Rules (value_formula / validation / editability) are set separately via set_field_rule — this call only declares structure + initial rows. Auto-creates the target sheet if missing.
Inputs: name (required), sheet (required), fields (required), position (required), +3 more.
create_pivotA
Cross-tabulate a table: one row per distinct value of rows, one column per distinct value of columns, each cell aggregating measure.
The result is an ordinary block, so every cell is addressable: BLOCKREF("<name>", "<a rows value>", "<a columns value>"). That is what lets you put one number from it in a sentence or feed it to another calculation.
You declare the recipe; the engine generates every cell from it. Do not write formulas, and do not write into the block — renaming a field of the source rebuilds the pivot rather than breaking it, which is only true because nothing is hand-written.
rows and columns must be fields whose values REPEAT (a region, a quarter, a status). Pointing either at an id gives one row per record, which is the source table again, not a pivot.
IMPORTANT: a pivot's numbers are live but its SHAPE is not. When new values appear in the source, its rows and columns fall behind while every number in it stays correct — call build__refresh_pivot. describe_block reports when that has happened.
Inputs: rows (required), source (required), measure (required), func, +7 more.
create_sheetA
Create a new sheet in the workbook. Returns the new sheet index. Idempotent: if a sheet with the same name exists, returns its index without creating a duplicate. Typically the agent does NOT call this directly — create_block will call it implicitly when the target sheet is missing. Use it only when you want an empty named sheet up front.
Inputs: name (required).
delete_block_rowsADestructive
Delete rows from a block by their key. Missing keys are silently ignored. Also deletes the matching sheet rows (one block per sheet-row assumption). If you try to delete every row, the last one is kept and its cells are cleared instead — the engine doesn't allow rowCnt=0 blocks.
Inputs: keys (required), block (required).
describe_blockARead-only
Return a block's full structure for the LLM: identity (name, sheet, position), per-field schema, and row keys in order. Every field reports both what it IS — type, description, required, unique, default_value, and references for a field pointing at another block — and what currently guards it: the value_formula, validation and editability templates. All of it comes from the Rust schema, the engine's authoritative source, so the answer is the same in every host and survives a save/load.
Read a field's type and description BEFORE writing a value to it: the description is where the unit, the convention, or the thing-not-to-do is written down, and it is the only record of it. A type of null means nobody has claimed one yet.
analyzes and analyzed_by say whether this block is a table or a conclusion drawn from one. A block with analyzes set is an ANALYSIS block — a total row, a set of statistics, a pivot — and its rows are its own, not the source's. Never sum an analysis block alongside the block it analyses: that counts the same numbers twice. A field with aggregates set is engine-computed from the source; writes to it are dropped, and you change it by changing the declaration.
Pass include_rows: true to additionally include current cell values as rows[].values[fieldName]. Off by default to save tokens — use it when the agent actually needs to inspect data, not when it only needs the shape.
Inputs: name (required), include_rows.
edit_analysis_blockA
Change what an existing analysis block computes: which of the source's fields it aggregates, with which function, and the label its row is addressed by.
Use this to arrive at an analysis in STEPS. Summing every number is often nearly right and wrong in one column — a rate wants AVERAGE, a text column wants COUNTA, an id column wants nothing at all. Adjust rather than rebuild: the block keeps its ref name, so formulas pointing at it keep working, and it is one undo.
aggregates REPLACES the set outright — a field you leave out stops being computed and its cell goes blank. Read the current set from describe_block first if you mean to add to it.
This is the simple kind of analysis: one row, one number per column. For one number per GROUP, use build__create_pivot / build__edit_pivot instead.
Inputs: name (required), label, aggregates.
edit_pivotA
Change an existing pivot's recipe — what it groups by, what it measures, how, in what order, over which records — and reshape it to match.
Use this rather than deleting and recreating: the block keeps its ref name, so every formula pointing at it keeps working, and the whole change is one undo.
This is also the way to REPAIR a pivot whose recipe stopped resolving (describe_block reports pivot_is_broken) — for instance after a source field was renamed. A broken pivot reads 0 in every cell rather than erroring, so it must be fixed, not refreshed: a refresh fails the same way.
Everything you omit is UNCHANGED. What you pass replaces that part outright — filters: [] clears the filters, columns: null turns a cross-tab into a simple group-by.
Inputs: name (required), func, rows, order, +6 more.
eval_formulaARead-only
Evaluate an Excel-style formula in a private scratch cell and return the computed value. Nothing is written to user-visible cells. Returns {type, value} where type is one of:
"number" — value is a JS number
"str" — value is a string
"bool" — value is a JS boolean
"error" — value is the Excel error code (e.g. "#REF!", "#NAME?")
"empty" — value is null (formula returned an empty cell)
Use for:
Quick checks: "=SUMIFS(OrderStatus, "amount", "*")" → total
Sanity-test a candidate template before set_field_rule
BLOCKREF / BLOCKREFS lookups against any block in the workbook
Leading "=" is optional — it is added automatically if missing.
Inputs: expr (required).
export_xlsxARead-only
Return the workbook as base64-encoded .xlsx bytes.
Last resort. The bytes land in your context and cost roughly 1.4 KB of text per KB of file. Prefer save_workbook, which writes a real file and hands the host a link to it — the host can give the human the workbook without any of it passing through you.
Inputs: no named parameters.
get_cellsARead-only
Read the values (and formulas) in a rectangular range of cells, addressed by zero-based (sheetIdx, startRow, startCol, endRow, endCol). Returns only the non-empty cells, each with its A1 ref, value, and formula (if any). Use this for ordinary "what is in these cells" questions; for a single computed result you can also use build eval_formula. Reads at most 500 cells per call — narrow the range if it is bigger.
Inputs: endCol (required), endRow (required), sheetIdx (required), startCol (required), +1 more.
goal_seekARead-only
Find the input value that makes a chosen output equal a target — "what discount rate gives a value per share of 30".
Runs entirely on the engine's temp branch, so the workbook is never modified: this is a question, not an edit. The search happens inside the engine rather than as a conversation, so it costs one tool call instead of one per iteration.
Name both cells semantically as (block, row_key, field) or by coordinate as (row, col). Give between when you know a bracket; otherwise it expands outward from the current input value to find one.
Bisection, so it needs the output to move monotonically between the bracket ends and it finds one crossing. If the bracket does not straddle the target it says so rather than returning a number — a non-answer you can act on beats a plausible one you cannot.
Inputs: to (required), set (required), target (required), between, +2 more.
list_blocksARead-only
Orient yourself in a workbook: every sheet, every block, and for each block the fields you can reference. One call is enough to start writing formulas.
Per block you get its ref name (BLOCKREF's first argument), its fields in column order (the third argument), key_field — the column whose values BLOCKREF matches as its second argument — and derived_fields, which are computed by a rule and reject writes.
Use describe_block when you need a field's actual rule, or the row keys and values. next_block_start clears everything already on the sheet, blocks and loose cell content alike, so passing it as create_block's position will not land on top of data.
Omit sheet to scan the whole workbook; passing it restricts to one sheet.
Inputs: sheet.
list_namesARead-only
List the workbook's defined names (named ranges and named constants). Each has a name and what it refers to, sheet-qualified (e.g. "Sheet1!$B$2:$B$20" or "0.08"). A formula can use any of them as a reference: =SUM(Sales).
Inputs: no named parameters.
list_violationsARead-only
Scan validation shadow cells and return every cell whose validation formula currently evaluates FALSE. Validation is advisory — the cell still holds its value, but the host UI renders a warning marker and you should treat it as "something the user/AI got wrong".
A field's rule is what its DECLARATION implies — required, unique, enum membership, reference existence — ANDed with whatever rule its author wrote. rule in the output names the declaration rather than quoting the generated formula, because the generated one is not something anyone typed. So a field with no rule text of its own can still appear here, which is the point: before the engine derived these, a required-but-empty cell raised nothing at all.
Also returns duplicate_keys: blocks where two records carry the same row key. That is not an advisory rule but a broken address — BLOCKREF resolves a key to the FIRST matching record, so the others are unreachable and every aggregate over the block double-counts, silently and without an error anywhere. The engine refuses to create a duplicate, so anything reported here came in with the file. Fix it by giving one of the records a distinct key before trusting any total over that block.
Also returns pivots_needing_attention. A pivot fails in a way no validation rule can see: stale means its numbers are each correct while whole groups are MISSING, and broken means its recipe stopped resolving so every cell reads 0 rather than erroring. Neither shows up as a red cell anywhere. Treat a broken pivot's numbers as unusable and fix the recipe; refresh a stale one before quoting any total from it.
Use this when answering 'why is something red?', 'what's broken after my last edit?', or before quoting any number you did not just compute yourself. It is the one call that answers 'is anything here untrustworthy' — the alternative is describe_block on every block, which is easy to skip and easy to forget.
Filters compose: omit both block and sheet to scan the whole workbook; pass either to narrow.
Pull-based on purpose: the LLM is turn-based, polling at decision points is cheaper than maintaining a live subscription. The host UI has its own per-cell push subscription for canvas warning markers.
Inputs: block, limit, sheet.
move_block_rowA
Reorder a block by moving one row to a new position, addressing both the row and its destination by key. Moves to the end when neither after_key nor before_key is given (same default as add_block_rows). Row order inside a block is presentation only — formulas address rows by key, so reordering never changes a single computed value. Use it to match a reading order someone expects, not to change the model.
Inputs: key (required), block (required), after_key, before_key.
open_workbookA
Start the workbook you will work in. Call with no arguments for a fresh, empty one; pass path to load an existing .xlsx from disk and work on the human's real file.
This replaces whatever workbook the session currently holds, discarding unsaved changes — so call it once at the start, not between steps. You do NOT have to call it at all: an empty workbook appears automatically the moment any other tool touches the session.
Prefer path over xlsx_base64. xlsx_base64 exists for hosts with no shared filesystem and costs enormous context for a file of any size.
Inputs: name, path, xlsx_base64.
preview_changesARead-only
Dry-run edits on the workbook's temp branch and report what they would do. Nothing is committed — the branch is discarded, so this is the safe way to explore a model instead of changing it and putting it back.
Two shapes. changes runs one hypothetical and returns every cell that would move, direct writes and cascaded recalculations alike. scenarios runs several, each on its own branch, and returns one result per scenario in order — that is a sensitivity table or a scenario comparison in a single call.
Add watch to get just the cells you care about instead of the whole cascade. A grid of sixteen scenarios over a model that cascades into 26 cells is 416 rows of diff to answer sixteen questions; watch makes it sixteen numbers. Name a cell semantically ({block, row_key, field}) or by coordinate ({sheet_idx, row, col}).
Inputs: watch, changes, scenarios.
refresh_pivotA
Bring a pivot's rows and columns back in line with its source.
Its NUMBERS were never stale — they are live formulas. Only the set of rows and columns falls behind, because no formula can add a row. That is exactly why this matters: a stale pivot shows correct numbers with whole groups missing, and totals taken from it are short with nothing to say so.
Call it before reading or reporting a pivot that describe_block flagged. Safe and cheap to call when nothing has changed — it reports that it did nothing.
Inputs: name (required).
save_workbookA
Write the workbook to a real .xlsx file the human can open in Excel. This is how you hand your work back — do it when the task is done.
Defaults to the path it was opened from, or last saved to; pass path to write somewhere else. Values, formulas and the block structure are all saved.
IMPORTANT — if the human is going to work on this in Excel, pass resolve_block_refs: true. Formulas that read blocks are written as BLOCKREF/BLOCKREFS, which only LogiSheets understands: Excel shows the saved numbers but turns those cells into #NAME? the moment it recalculates. Resolving rewrites them as ordinary A1 references so Excel can recompute the model. Leave it off when the file is coming back here — the named form is readable and survives rows moving.
The result carries a link to the workbook rather than its bytes, so the host can offer the human the file without any of it passing through your context.
Inputs: path, resolve_block_refs.
set_block_cellsA
Write one or more cells inside any block(s) in a single atomic transaction. Each change addresses a cell by (block ref name, row_key, field) — the LLM never deals with raw (sheet, row, col).
Pass changes as an array; one-cell writes are just length-1 arrays. Batching is the cheap default — putting N writes in one call is one transaction, one calc pass, one undo entry.
Rejected up-front (whole tx aborts) when any change:
targets a non-existent block / row_key / field, or
targets a field with a
value_formulaon its schema (engine-computed; use set_field_rule to change the rule instead).
Value can be a literal (string / number / boolean) or a formula prefixed with '='. null clears the cell.
Inputs: changes (required).
set_block_descriptionA
Write what a block is for, in prose, onto the block itself. Saved in the file and returned by describe_block, so it is how the next agent — or the next you, in a later session — learns what the table means.
Say what one row represents, what any non-obvious field holds, and anything that must not be done to it. Do not restate the field names; they are already visible.
Refused when the block reserves modifyDescription to its owner. Pass an empty string to clear it.
Inputs: name (required), description (required).
set_cellsA
Write one or more arbitrary cells on a sheet in a single atomic transaction (one undo step). Each cell is addressed by zero-based row/col. Content is a literal (string / number / boolean) or a formula prefixed with '='. null or '' clears the cell. For cells that belong to a block, prefer edit set_block_cells (it respects the schema); use this for plain, non-block cells. At most 200 cells per call.
Inputs: cells (required), sheetIdx (required).
set_field_ruleA
Attach declarative rules to a field. All three rule kinds (value_formula, validation, editability) are optional — pass only the ones you want to change. Omit a kind entirely to leave it untouched on this field; pass null to explicitly clear an existing rule.
Placeholders supported in formulas: #FIELD("name") — the same row's cell in field "name" #FIELD("name", "key") — field "name" on the row carrying that key, in THIS SAME block #KEY — the row's key value (quoted as a string literal) #PLACEHOLDER — the cell itself (validation/editability only)
The two-argument #FIELD is the only way to reach another row of the cell's own block: BLOCKREF is refused there (it depends on the whole-block vertex, so it would close a cycle). Use it for share-of-total or index-to-a-base-row columns, e.g. "=#FIELD("amt")/#FIELD("amt","TOTAL")". The other row is named by KEY, never by position — there is no "previous row" form, because rows can be reordered and inserted into, so a positional address would silently come to mean a different row. A running total (each row reading the row above) therefore has no rule form; write that column as ordinary cells outside the block. A rule that resolves onto the cell it is defining is rejected, as is a plain coordinate (A1/C3) landing inside the block — in a template a coordinate does not shift per row, so on the first row it would point at the cell being defined.
Engine behaviour after this call:
value_formula → cells in the field become engine-computed (no direct writes). Every row's formula is re-materialized.
validation → a
ShadowKind::Validationshadow is auto-installed on every row; warning markers refresh.editability → a
ShadowKind::UserEditableshadow is auto-installed on every row; the host permission patch reads it to gate writes.
Leading "=" on the formula body is optional; omit or include either way.
Inputs: block (required), field (required), validation, editability, +1 more.
traceARead-only
Follow a cell's dependencies, in either direction, using the engine's own dependency graph.
precedents— what this cell reads. Use it to audit a number: "why is value-per-share what it is".dependents— what reads this cell, and through which reference. Use it before changing something: "what breaks if I edit this assumption".
Both by default. Name the cell semantically as (block, row_key, field), or by coordinate as (row, col) with an optional sheet_idx. Results come back named the same way whenever the cell sits inside a block, so you get "assumptions.wacc" rather than a coordinate to interpret.
This asks the engine rather than reading formula text, so it sees through BLOCKREF, ranges and whole-column references, and it answers the reverse direction — which formula strings cannot.
Granularity matters when blocks are involved. The engine tracks block dependencies per (block, field), not per row, so dependents of one block cell is everything reading that FIELD — the queried row among them. Each edge carries scope: "cell" is exact, "field" and "block" are over-approximations, and approximate: true is set on the result when any edge is wider than a cell. Treat a field-wide answer as "at least these", not "exactly these".
Inputs: target (required), direction.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 32 tools
The set is large and has several near-neighbour pairs — create_block vs convert_to_block vs create_analysis_block, set_block_cells vs set_cells, get_cells vs describe_block(include_rows) vs eval_formula, save_workbook vs export_xlsx, create_sheet vs the implicit sheet creation in create_block — but every one of these boundaries is explicitly spelled out in the descriptions ('prefer set_block_cells for block cells', 'prefer save_workbook over export_xlsx', 'typically the agent does NOT call create_sheet'). A few remain softer (list_blocks vs describe_block, list_violations vs per-block validation), so an agent could still occasionally pick the coarser tool when the finer one was intended.
Overwhelmingly a verb_noun snake_case pattern (open_workbook, create_block, add_block_rows, set_field_rule, edit_pivot), with chart_delete the one clear inversion against chart_insert/chart_list/chart_update. Descriptions also cross-reference tools by namespaced aliases that do not exist in the surface (chart__list, build__create_pivot, edit__describe_block, inspect), which muddies predictability even though the underlying convention is stable.
At 32 tools this is well past the comfortable range, and the surface spans five or six distinct concerns (workbook I/O, sheets, blocks/fields, analysis blocks, pivots, charts, what-if analysis). Each tool does appear to earn its place — there is little redundancy — but the cognitive and context cost is high and pushes toward the 'heavy' band rather than a well-scoped set.
The modelling core is strong: blocks can be created, converted, described, populated, re-keyed, reordered, ruled and analysed, and pivots/charts/what-if are all covered. But lifecycle gaps are real — there is no way to delete a whole block (only delete_block_rows), no sheet delete/rename/reorder beyond create_sheet, no way to author a defined name (list_names is read-only), and no cell/sheet formatting or sorting surface. These aren't trivial workarounds for an agent asked to clean up or restructure a workbook.
Maintenance
Related MCP Connectors
The Excel engine for AI agents: read, check and edit Excel models over MCP.
AI-native data layer: sheets, databases and apps for every agent, with exact answers and audit.
Call a spreadsheet's real formulas from AI: ReactiveSheets turns workbooks into apps with MCP tools.
A structured financial modeling layer for AI agents. Build, version, and audit financial models without drift, then export to Excel, from Claude or any MCP client. Learn more: https://layerz.cc/for-agents
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to create, read, and manipulate Excel files without requiring Microsoft Excel installation. Supports comprehensive spreadsheet operations including formulas, formatting, charts, pivot tables, and data validation.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to create, read, and modify Excel workbooks without requiring Microsoft Excel, supporting operations like formulas, charts, pivot tables, formatting, and data validation.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to create, read, and manipulate Excel workbooks without Microsoft Excel installed, supporting formulas, formatting, charts, pivot tables, and data validation operations.MIT
- AlicenseAqualityDmaintenanceEnables AI agents to directly create, read, edit, and save Excel (.xlsx) spreadsheets using natural language through the Model Context Protocol, supporting cells, sheets, formatting, and formulas without writing Python code.216MIT