Skip to main content
Glama
xlsx-for-ai

xlsx-for-ai

by senoff

xlsx_write

Create or update .xlsx workbooks from a structured sheet and cell spec; formatting is optional and the spec is validated before writing.

Instructions

Use this when you need to create or update a spreadsheet from a structured spec ({sheets: [{name, cells: [{address, value | formula, style?, hyperlink?, comment?}], columns?, freeze?, merges?, conditionalFormats?, dataValidations?}]}) — formatting is optional; server-validated before writing. A value sent beside a formula is stored as that formula's cached result (the reply says how many: _meta.cached_formula_cells).

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "xlsx_write"
  }
}

Input Schema

NameRequiredDescriptionDefault
specNoWorkbook spec. Shape: {sheets: [{name: string, cells: [{address, value | formula}]}]}. Each cell has an A1-style `address` (regex ^[A-Za-z]+\d+$) and EXACTLY ONE of `value` (string|number|boolean|null) or `formula` (string WITHOUT leading "=" — e.g. "SUM(A1:A10)" not "=SUM(A1:A10)"). Example: {"sheets":[{"name":"Sheet1","cells":[{"address":"A1","value":"id"},{"address":"A2","value":1},{"address":"B2","formula":"A2*2"}]}]}
out_pathNoDestination .xlsx path. Required when the caller wants the file saved to disk.
spec_pathNoAbsolute path to a .json file carrying the spec (alternative to inline spec for large workbooks). Pass the path string AS-IS — do NOT base64-encode; the client reads it.
base_file_b64NoNARROW EXCEPTION — xlsx_write ONLY accepts a base64-encoded base workbook here for edit-in-place. Every OTHER tool in this connector takes a file PATH (`file_path`), not bytes. When omitted, a fresh workbook is created.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changedv4.3.1
    • addedInput schema / properties / base_file_b64 / description
      Added value: +"NARROW EXCEPTION — xlsx_write ONLY accepts a base64-encoded base workbook here for edit-in-place. Every OTHER tool in this connector takes a file PATH (`file_path`), not bytes. When omitted, a fresh workbook is created."
    • addedInput schema / properties / out_path
      Added value: +{
      +  "description": "Destination .xlsx path. Required when the caller wants the file saved to disk.",
      +  "type": "string"
      +}
    • addedInput schema / properties / spec / description
      Added value: +"Workbook spec. Shape: {sheets: [{name: string, cells: [{address, value | formula}]}]}. Each cell has an A1-style `address` (regex ^[A-Za-z]+\\d+$) and EXACTLY ONE of `value` (string|number|boolean|null) or `formula` (string WITHOUT leading \"=\" — e.g. \"SUM(A1:A10)\" not \"=SUM(A1:A10)\"). Example: {\"sheets\":[{\"name\":\"Sheet1\",\"cells\":[{\"address\":\"A1\",\"value\":\"id\"},{\"address\":\"A2\",\"value\":1},{\"address\":\"B2\",\"formula\":\"A2*2\"}]}]}"
    • addedInput schema / properties / spec / properties
      Added value: +{
      +  "sheets": {
      +    "description": "One or more sheets. Each sheet is { name: string, cells: array }.",
      +    "items": {
      +      "properties": {
      +        "cells": {
      +          "description": "List of cells to write. Order does not matter; addresses are absolute.",
      +          "items": {
      +            "description": "Cell entry. Provide EXACTLY ONE of `value` or `formula`.",
      +            "oneOf": [
      +              {
      +                "not": {
      +                  "required": [
      +                    "formula"
      +                  ]
      +                },
      +                "required": [
      +                  "value"
      +                ]
      +              },
      +              {
      +                "not": {
      +                  "required": [
      +                    "value"
      +                  ]
      +                },
      +                "required": [
      +                  "formula"
      +                ]
      +              }
      +            ],
      +            "properties": {
      +              "address": {
      +                "description": "A1-style cell address — e.g. \"A1\", \"B2\", \"AA10\".",
      +                "pattern": "^[A-Za-z]+\\d+$",
      +                "type": "string"
      +              },
      +              "formula": {
      +                "description": "Excel formula, WITHOUT leading \"=\". E.g. \"SUM(A1:A10)\" not \"=SUM(A1:A10)\". Mutually exclusive with `value`.",
      +                "pattern": "^(?!=).+",
      +                "type": "string"
      +              },
      +              "value": {
      +                "description": "Cell value: string, number, boolean, or null. Mutually exclusive with `formula`.",
      +                "type": [
      +                  "string",
      +                  "number",
      +                  "boolean",
      +                  "null"
      +                ]
      +              }
      +            },
      +            "required": [
      +              "address"
      +            ],
      +            "type": "object"
      +          },
      +          "type": "array"
      +        },
      +        "name": {
      +          "description": "Sheet name (non-empty).",
      +          "minLength": 1,
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "name",
      +        "cells"
      +      ],
      +      "type": "object"
      +    },
      +    "minItems": 1,
      +    "type": "array"
      +  }
      +}
    • addedInput schema / properties / spec / required
      Added value: +[
      +  "sheets"
      +]
    • addedInput schema / properties / spec_path
      Added value: +{
      +  "description": "Absolute path to a .json file carrying the spec (alternative to inline spec for large workbooks). Pass the path string AS-IS — do NOT base64-encode; the client reads it.",
      +  "type": "string"
      +}
    • removedInput schema / required
      Removed value: -[
      -  "spec"
      -]
  2. First observedv3.2.1

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=false, destructiveHint=false, idempotentHint=false, so the safety profile is supplied. The description adds real context beyond that: formatting is optional, the spec is server-validated before any write occurs, and cached-formula cells are reported back via _meta.cached_formula_cells. It does not explain overwrite semantics when the target file already exists, which is the main behavioral gap for a non-idempotent write.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The usage trigger is front-loaded and the validation and cached-formula notes are useful. But the description re-states the entire nested spec shape and even an example workbook, all of which the input schema already documents at full coverage, so a meaningful share of the text is redundant.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a nested-spec mutation tool with no output schema, the description covers input shape, validation, and one reply field, which is substantial. It leaves open what is returned when out_path is omitted, whether an existing file is overwritten, and why the operation is non-idempotent — gaps an agent needs before a write.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, and the description does add value by explaining that base_file_b64 is a deliberate narrow exception to the path-based convention used elsewhere and that spec_path is an alternative for large workbooks. However, the claim that 'a value sent beside a formula is stored as that formula's cached result' conflicts with the spec's oneOf constraint requiring exactly one of value or formula, which could mislead an agent on cell construction.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific trigger and verb-resource pair ('create or update a spreadsheet from a structured spec') and immediately characterizes the input shape at a high level. An agent can tell this is the write path that takes a structured spec, as opposed to reading/analyzing tools. Sibling names are not cited, but the operation itself is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The 'Use this when you need to create or update a spreadsheet from a structured spec' clause is a clear selection trigger, and the base_file_b64 note implicitly distinguishes fresh creation from edit-in-place. It stops short of explicit when-not guidance or naming the non-spec alternative tools (e.g. conversion of other formats), so it is clear context rather than a full routing rule.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.