LogiSheets

v0.7.0
io.github.logisky/logisheets-mcp Checked 1 hour ago Published 13 days ago

An Excel-compatible spreadsheet engine for agents: deterministic formulas, block memory, real .xlsx.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

open_workbook

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.

ParameterTypeDescription
namestringFile name to report to the engine when loading from base64.
pathstringPath to an existing .xlsx to load. Omit for an empty workbook.
xlsx_base64stringA .xlsx as base64, for when no shared filesystem exists. Use `path` when you can.

save_workbook

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 a…

ParameterTypeDescription
pathstringDestination .xlsx path. Defaults to the path the workbook was opened from.
resolve_block_refsbooleanRewrite BLOCKREF/BLOCKREFS as ordinary A1 references. Set this when the human will open the file in Excel; Excel has no BLOCKREF function and would show #NAME? on recalculation. One-way: a resolved fi…

export_xlsx

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.

list_blocks

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,…

ParameterTypeDescription
sheetstring

describe_block

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…

ParameterTypeDescription
name *stringBlock ref name (the `name` of create_block).
include_rowsbooleanWhen true, include current cell values. Off by default to save tokens.

eval_formula

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 lookup…

ParameterTypeDescription
expr *stringFormula, with or without leading "=". E.g. "SUM(A1:A10)" or "=BLOCKREF(\"orders\", \"O001\", \"amount\")".

create_block

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 val…

ParameterTypeDescription
fields *arrayColumn definitions in order. fields[0] is the row-key column.
name *stringBlock ref name. Used as the first arg to BLOCKREF/BLOCKREFS in formulas. Must be unique within the workbook.
position *objectTop-left cell of the block (0-indexed).
sheet *stringTarget sheet name.
descriptionstringWhat this table is for, in a sentence or two: what a row represents, what the fields mean where the names are not obvious, and anything a later reader must not do to it (e.g. a field the craft maintai…
initial_rowsarrayOptional initial rows.
unique_togetherarrayField groups whose values must not repeat in COMBINATION — a rule about the TABLE, not about one cell. `unique` on a field covers one column; this covers several together, which nothing else can say…

convert_to_block

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…

ParameterTypeDescription
col_count *integerNumber of columns.
name *stringRef name for the new block — BLOCKREF's first argument. Must be unique.
position *objectTop-left cell of the data, excluding the header row.
row_count *integerNumber of data rows.
sheet *stringSheet the table is on.
fieldsarrayField names, when there is no header row. Length must equal col_count.
header_rowintegerRow holding the column titles; field names are read from it. Omit it and the row directly above `position` is used when it looks like a header — all text, over data that is not.
key_fieldstringWhich field identifies a row. Omit and the first column whose values are all present and all different is used.

set_block_description

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.

ParameterTypeDescription
description *string
name *stringBlock ref name.

add_block_rows

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).

ParameterTypeDescription
block *stringBlock ref name.
rows *array
after_keystringInsert directly after the row with this key, instead of appending at the end. Mutually exclusive with before_key.
before_keystringInsert directly before the row with this key. Use the first key to insert at the top. Mutually exclusive with after_key.

delete_block_rows

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.

ParameterTypeDescription
block *string
keys *array

move_block_row

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.

ParameterTypeDescription
block *stringBlock ref name.
key *stringRow key of the row to move.
after_keystringLand the row directly after the row with this key. Mutually exclusive with before_key.
before_keystringLand the row directly before the row with this key. Pass the first key to move it to the top. Mutually exclusive with after_key.

set_block_cells

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_formula` on its schema (engine-computed; use set_field_rule to change the rule…

ParameterTypeDescription
changes *array

set_field_rule

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 o…

ParameterTypeDescription
block *string
field *string
editabilitystring | nullBoolean formula, e.g. "=#FIELD(\"status\")<>\"locked\"". Pass null to clear; omit to leave existing untouched.
validationstring | nullBoolean formula, e.g. "#PLACEHOLDER>=0". Pass null to clear; omit to leave existing untouched.
value_formulastring | nullFormula template, e.g. "=#FIELD(\"qty\")*#FIELD(\"price\")", or "=#FIELD(\"amt\")/#FIELD(\"amt\",\"TOTAL\")" to divide by a named row of the same block. Pass null to clear; omit to leave existing unto…

create_analysis_block

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 w…

ParameterTypeDescription
source *stringRef name of the block to analyse.
aggregatesarrayWhich source fields to aggregate and how. Omit to SUM every field the source declares as `number`.
labelstringWhat goes in the key column, and therefore the key the result is addressed by. Defaults to "TOTAL".
namestringRef name for the new block. Defaults to "<source>_analysis".

edit_analysis_block

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 curren…

ParameterTypeDescription
name *stringRef name of the analysis block.
aggregatesarrayReplaces the whole set. Omit to leave the functions alone and change only `label`.
labelstringNew row label, which is also the key the result is addressed by. Omit to keep it.

create_pivot

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…

ParameterTypeDescription
measure *stringField being aggregated. Normally a number field.
rows *stringField of the source whose distinct values become the ROWS. Its values must repeat.
source *stringRef name of the table to pivot.
columnsstringField whose distinct values become the COLUMNS. Omit for a simple group-by with one value column.
extra_measuresarrayExtra columns with their own function and measure, for showing more than one number per group.
filtersarrayWhich source records count at all. Omit to count every one. Applied to the rows AND the numbers, so a group left with no records gets no row rather than a row reading 0.
funcstringHow to aggregate. Defaults to SUM. COUNT counts matching RECORDS and ignores `measure`; COUNTA counts the records whose `measure` is filled in, which is how you ask how complete a column is.
namestringRef name for the new block. Defaults to "<source>_pivot".
orderstringOrder of the rows. `ascending` (default) sorts; `firstSeen` keeps the source's own sequence; `custom` uses `order_values`.
order_valuesarrayThe row sequence for `order: custom`. A value you omit is placed after the listed ones, never hidden.
row_totalstringName for a column totalling each row across EVERY value of `columns` — e.g. "Total". Omit for no total column.

edit_pivot

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. Everythi…

ParameterTypeDescription
name *stringRef name of the pivot block.
columnsstringNew column dimension. Pass null to drop the columns and make it a simple group-by. Omit to keep the current one.
extra_measuresarrayReplaces the declared extra columns outright, together with `row_total`. Omit BOTH to keep the ones the pivot has.
filtersarrayReplaces the current filters outright. Pass an empty array to count every record again.
funcstringNew aggregate. Omit to keep the current one.
measurestringNew field to aggregate. Omit to keep the current one.
orderstringNew row order. Omit to keep the current one.
order_valuesarrayThe row sequence for `order: custom`.
row_totalstringName for a column totalling each row across every column value. Replaces the declared columns along with `extra_measures`.
rowsstringNew row dimension. Its values must repeat. Omit to keep the current one.

refresh_pivot

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.

ParameterTypeDescription
name *stringRef name of the pivot block.

create_sheet

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.

ParameterTypeDescription
name *stringSheet name.

get_cells

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.

ParameterTypeDescription
endCol *integerZero-based last column (inclusive).
endRow *integerZero-based last row (inclusive).
sheetIdx *integerZero-based sheet index.
startCol *integerZero-based first column.
startRow *integerZero-based first row.

set_cells

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.

ParameterTypeDescription
cells *array
sheetIdx *integerZero-based sheet index.

list_violations

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 it…

ParameterTypeDescription
blockstringBlock ref name. Omit to scan all blocks.
limitinteger
sheetstringSheet name. Omit to scan all sheets.

list_names

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).

preview_changes

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 gr…

ParameterTypeDescription
changesarrayOne hypothetical. Use `scenarios` for more than one.
scenariosarraySeveral hypotheticals, each evaluated independently. Results come back in this order.
watcharrayReport only these cells' values instead of the full diff. Name each one semantically or by coordinate.

trace

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 co…

ParameterTypeDescription
target *objectThe cell to trace. Either (block, row_key, field) or (row, col).
directionstring

goal_seek

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 mo…

ParameterTypeDescription
set *objectThe input cell to vary.
target *objectThe output cell to drive to `to`.
to *numberThe value `target` should reach.
betweenarraySearch bracket [low, high]. Omit to expand outward from the current input value.
max_iterationsinteger
tolerancenumberHow close to `to` counts as solved. Default 1e-6 relative.

chart_from_block

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. Renamin…

ParameterTypeDescription
blockId *integer
sheetIdx *integerZero-based sheet index.
valueFields *arrayField names to plot, one series each, in order.
anchorstringTop-left cell of the chart. Defaults to two rows below the block.
categoryFieldstringField whose values label the categories (the X axis). The block's key column is not addressable as a range, so name the field that reads as a label. Omitted, the categories are just 1..n.
chartTypestringDefaults to col.
sizeInCellsobject
titlestringDefaults to the block's schema name.

chart_insert

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.

ParameterTypeDescription
chartType *stringcol = vertical bars, bar = horizontal. pie/doughnut plot one series. scatter/bubble take numeric X from categoriesRef. stock needs 4 series (open/high/low/close) or 3 (high/low/close). surface plots a…
series *arrayOne entry per data series. Each valueRef is an A1 range of the values to plot.
sheetIdx *integerSheet the chart is placed on (zero-based).
anchorstringTop-left cell of the chart, e.g. 'H2'. Defaults to two rows below the data.
categoriesRefstringA1 range of the category labels (the X axis), e.g. A2:A10. For scatter/bubble these are the numeric X values.
sizeInCellsobjectChart size in cells. Defaults to 15 × 8.
titlestringChart title.

chart_list

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.

ParameterTypeDescription
sheetIdx *integerZero-based sheet index.

chart_update

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.

ParameterTypeDescription
chartId *stringFrom chart__list.
sheetIdx *integer
catAxisTitlestring
categoriesRefstringRe-point the category labels (A1 range).
chartTypestring
legendPosstring
numFmtstringExcel number-format code for the value axis and labels, e.g. "#,##0.00" or "0%". Empty falls back to the source cells' own format.
seriesarrayOne entry per data series. Each valueRef is an A1 range of the values to plot.
showDataLabelsbooleanPrint each point's value next to it.
showPercentLabelsbooleanAdd the percentage to labels (pie-like charts).
stackedbooleanStack the series. Ignored by pie and scatter.
titlestringEmpty string clears it.
valAxisScaleobjectReplaces the whole value-axis scale — fields left out become automatic, which is how a fixed bound is cleared.
valAxisTitlestring

chart_delete

Delete a chart. Get the chart_id from chart__list. Undoable, but it removes the chart and its formatting.

ParameterTypeDescription
chartId *stringFrom chart__list.
sheetIdx *integer