Skip to main content
Glama
Google Sheets Write MCP Server

Google Sheets Write MCP Server

by tg-tool

sheets-write-mcp-server

Google Sheets への書き込み専用 MCP サーバー。google-sheets-mcp-server(読み取り専用)の対になる存在で、読み取りツールは持たない。読むだけなら readonly を使う。

設計思想

コミュニティ製の Sheets MCP は「アカウント内の全シートに読み書き可」という過剰権限になりがち。本サーバーは書き込みという破壊的操作を扱うため、全ツールが以下の安全パイプラインを通る:

whitelist(fail-closed)→ サイズ制限 → dry_run → 書込前スナップショット → 実行 → 監査ログ
  • ホワイトリスト:~/.config/sheets-write-mcp/allowed_spreadsheets.yaml に登録された spreadsheet(さらに sheet 単位で絞り込み可)にしか書き込めない。ファイルが無い・壊れている場合は全拒否(fail-closed)。編集は即反映(再起動不要)

  • dry_run:削除系ツール(clear_range / delete_rows / delete_columns / delete_sheet)はデフォルトで dry_run=true。実行計画と現在値のプレビューを返すだけで、明示的に dry_run=false を渡すまで何も起きない

  • 書込前スナップショット:上書き・削除される値(数式は数式文字列のまま)を ~/.local/share/sheets-write-mcp/rollback/ に保存してから書き込む。スナップショット取得に失敗したら書き込みは実行されない。spreadsheet ごとに直近50世代

  • 監査ログ:全操作(拒否・dry_run・エラー含む)を ~/.local/share/sheets-write-mcp/audit.jsonl に1行1レコードで記録

  • サイズ制限:1回の操作で 5,000 セル超は force=true が必要

  • 外部送信は Google APIs のみ。第三者サーバー経由なし

ロールバックの範囲

スナップショットが守るのは値と構造(行・列・シートの中身)。セル書式(色・罫線・条件付き書式等)の復元は対象外——書式事故は Google Sheets 本体の版履歴(ファイル > 変更履歴)で救済できるため、スナップショットの複雑化に見合わないと判断。schema_version フィールドがあるので将来拡張は可能。

Related MCP server: google-sheets-mcp

ツール(18本・3層)

層

ツール

dry_run 既定

L1 値

update_range / batch_update_values / append_rows

false

L1 値

clear_range

true

L2 構造

insert_rows / insert_columns / add_sheet / duplicate_sheet / rename_sheet

false

L2 構造

delete_rows / delete_columns / delete_sheet

true

L3 装飾

set_number_format / set_cell_style / set_conditional_format / set_data_validation / set_basic_filter / protect_range

false

  • 数式は既定で数式として解釈される(USER_ENTERED)。raw=true で文字列として格納

  • シート指定は名前・gid どちらでも可

  • L3 は指定した項目だけを fields マスクで更新(触っていない書式は保持)

  • 対象外:ピボット・グラフ(将来)/スプレッドシート自体の作成・削除・共有(Drive API 管轄)/表示・ツール・拡張機能メニュー(API 非対応)

セットアップ

git clone <this repo> && cd sheets-write-mcp-server
python3 -m venv .venv && .venv/bin/pip install -e .

# 1. OAuth クライアント(readonly と同じものを使い回せる)
mkdir -p ~/.config/sheets-write-mcp
cp ~/.config/sheets-mcp/credentials.json ~/.config/sheets-write-mcp/

# 2. ホワイトリスト作成
cat > ~/.config/sheets-write-mcp/allowed_spreadsheets.yaml <<'EOF'
spreadsheets:
  - id: "<spreadsheet ID>"
    note: "(用途メモ)"
    writable_sheets: "*"        # または ["シート名", ...]
EOF

# 3. OAuth を一度通す(ブラウザが開く。token.json が書き込みスコープで生成される)
.venv/bin/python -c "from sheets_write_mcp.auth import _load_credentials; _load_credentials()"

トークンは readonly(spreadsheets.readonly)とは別ファイル・別スコープ(spreadsheets)。

Claude Code / Claude Desktop への登録

claude mcp add sheets-write -- /path/to/sheets-write-mcp-server/.venv/bin/sheets-write-mcp

Claude Desktop(claude_desktop_config.json)で readonly と並走:

{
  "mcpServers": {
    "sheets-readonly": { "command": "/path/to/sheets-mcp-server/.venv/bin/sheets-mcp" },
    "sheets-write":    { "command": "/path/to/sheets-write-mcp-server/.venv/bin/sheets-write-mcp" }
  }
}

環境変数

変数

デフォルト

SHEETS_WRITE_MCP_CREDENTIALS

~/.config/sheets-write-mcp/credentials.json

SHEETS_WRITE_MCP_TOKEN

~/.config/sheets-write-mcp/token.json

SHEETS_WRITE_MCP_WHITELIST

~/.config/sheets-write-mcp/allowed_spreadsheets.yaml

SHEETS_WRITE_MCP_DATA_DIR

~/.local/share/sheets-write-mcp/

開発

.venv/bin/pip install -e ".[dev]"
.venv/bin/python -m pytest -q       # 110+ tests
.venv/bin/python -m ruff check src/ tests/

grid.py(A1⇔GridRange 変換)が範囲計算の単一障害点。1-indexed(ユーザー向け)と 0-indexed(GridRange)の変換ミスは「隣の行を消す」事故に直結するため、境界値テストを最も厚くしている。

既知の制約

  • スナップショットは valueRenderOption=FORMULA で取得するため、数式セルの計算結果値は保存されない(数式は保存され、復元時に再計算される)

  • rename_sheet 後はホワイトリストのシート名指定が旧名のままになる——リネーム後に yaml を更新すること

Available Tools

18 tools
add_sheetA

Add a new empty sheet (tab).

Whitelist note: allowed only when writable_sheets is "*" or the new title is explicitly listed.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. title: Name of the new sheet. rows: Grid row count. columns: Grid column count. index: Optional 0-based tab position. dry_run: If true, return the execution plan without changing anything.

Inputs: title (required), spreadsheet_id_or_url (required), rows, index, +2 more.

append_rowsA

Append rows after the last data row of a sheet. Never overwrites.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. rows: 2D list of row values to append. raw: If true, store inputs literally (formulas become plain text). dry_run: If true, return the execution plan without writing. force: Allow writes touching more than the cell limit.

Inputs: rows (required), sheet (required), spreadsheet_id_or_url (required), raw, +2 more.

batch_update_valuesA

Write multiple ranges in one call (one API request, atomic-ish).

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. updates: List of {"sheet": str, "range": str, "values": list[list]}. 'sheet' is a name or gid; 'range' is bare A1 without prefix. raw: If true, store inputs literally (formulas become plain text). dry_run: If true, return the execution plan without writing. force: Allow writes touching more than the cell limit.

Inputs: updates (required), spreadsheet_id_or_url (required), raw, force, +1 more.

clear_rangeA

Clear all values in a range (destructive — dry_run defaults to TRUE).

Values are snapshotted before clearing so they can be restored. Formatting is not affected by this operation.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. range: Bare A1 range without sheet prefix, e.g. 'B2:D10'. dry_run: Defaults to TRUE. Pass false to actually clear. force: Allow clears touching more than the cell limit.

Inputs: range (required), sheet (required), spreadsheet_id_or_url (required), force, +1 more.

delete_columnsA

Delete columns (destructive — dry_run defaults to TRUE).

The full contents of the columns are snapshotted before deletion.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. start_column: Column letter ('B') or 1-indexed number of the first column to delete. count: Number of columns to delete. dry_run: Defaults to TRUE. Pass false to actually delete. force: Allow deletions touching more than the cell limit.

Inputs: sheet (required), start_column (required), spreadsheet_id_or_url (required), count, +2 more.

delete_rowsA

Delete rows (destructive — dry_run defaults to TRUE).

The full contents of the rows are snapshotted (formulas preserved) before deletion.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. start_row: 1-indexed first row to delete. count: Number of rows to delete. dry_run: Defaults to TRUE. Pass false to actually delete. force: Allow deletions touching more than the cell limit.

Inputs: sheet (required), start_row (required), spreadsheet_id_or_url (required), count, +2 more.

delete_sheetA

Delete an entire sheet (destructive — dry_run defaults to TRUE).

The whole sheet's values (formulas preserved) and its properties are snapshotted so the sheet can be recreated. Formatting is not restored.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. dry_run: Defaults to TRUE. Pass false to actually delete. force: Allow deletion of sheets larger than the cell limit.

Inputs: sheet (required), spreadsheet_id_or_url (required), force, dry_run.

duplicate_sheetA

Duplicate a sheet within the same spreadsheet.

Whitelist note: allowed only when writable_sheets is "*" or the new title is explicitly listed.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Source sheet name OR gid string. new_title: Name for the copy. insert_index: Optional 0-based tab position for the copy. dry_run: If true, return the execution plan without changing anything.

Inputs: sheet (required), new_title (required), spreadsheet_id_or_url (required), dry_run, +1 more.

insert_columnsA

Insert blank columns before the given column.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. start_column: Column letter ('B') or 1-indexed number the new columns are inserted BEFORE. count: Number of columns to insert. inherit_before: Inherit formatting from the column to the left. dry_run: If true, return the execution plan without changing anything.

Inputs: sheet (required), start_column (required), spreadsheet_id_or_url (required), count, +2 more.

insert_rowsA

Insert blank rows before the given row number.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. start_row: 1-indexed row number the new rows are inserted BEFORE (start_row=3 inserts new rows as row 3..). count: Number of rows to insert. inherit_before: Inherit formatting from the row above. dry_run: If true, return the execution plan without changing anything.

Inputs: sheet (required), start_row (required), spreadsheet_id_or_url (required), count, +2 more.

protect_rangeA

Protect a range (or the whole sheet) from editing.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. range: Bare A1 range to protect. None = whole sheet. description: Label shown in the Sheets UI. warning_only: Show a warning instead of blocking edits. editors: Email addresses still allowed to edit (ignored when warning_only). dry_run: If true, return the execution plan without changing anything.

Inputs: sheet (required), spreadsheet_id_or_url (required), range, dry_run, +3 more.

rename_sheetA

Rename a sheet (tab).

Note: if the whitelist lists sheets by name, update the whitelist entry after renaming — the old name will no longer match.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. new_title: New sheet name. dry_run: If true, return the execution plan without changing anything.

Inputs: sheet (required), new_title (required), spreadsheet_id_or_url (required), dry_run.

set_basic_filterA

Set (or clear) the basic filter of a sheet.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. range: Bare A1 range for the filter. None = whole sheet. clear: If true, remove the existing basic filter instead. dry_run: If true, return the execution plan without changing anything.

Inputs: sheet (required), spreadsheet_id_or_url (required), clear, range, +1 more.

set_cell_styleA

Style cells. Only the parameters you pass are changed; the rest is preserved.

Formatting changes are NOT rollback-capable (use Sheets version history).

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. range: Bare A1 range without sheet prefix. bold: Bold on/off. italic: Italic on/off. font_size: Font size in points. fg_color: Text color '#RRGGBB'. bg_color: Background color '#RRGGBB'. h_align: 'left' | 'center' | 'right'. borders: Optional {"sides": ["top","bottom","left","right","innerHorizontal","innerVertical"], "style": "SOLID|SOLID_MEDIUM|SOLID_THICK|DOTTED|DASHED|DOUBLE|NONE", "color": "#RRGGBB"}. dry_run: If true, return the execution plan without changing anything.

Inputs: range (required), sheet (required), spreadsheet_id_or_url (required), bold, +7 more.

set_conditional_formatA

Add a conditional-format rule to a range.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. range: Bare A1 range without sheet prefix. condition_type: e.g. NUMBER_GREATER, TEXT_CONTAINS, CUSTOM_FORMULA, BLANK. condition_values: Values/formula for the condition (e.g. ['100'] or ['=B2>C2']). bg_color: Highlight background '#RRGGBB'. fg_color: Highlight text color '#RRGGBB'. bold: Bold the matching cells. index: Rule priority position (0 = highest). dry_run: If true, return the execution plan without changing anything.

Inputs: range (required), sheet (required), condition_type (required), spreadsheet_id_or_url (required), +6 more.

set_data_validationA

Set (or clear) data validation on a range.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. range: Bare A1 range without sheet prefix. rule_type: e.g. ONE_OF_LIST, NUMBER_BETWEEN, CHECKBOX, CUSTOM_FORMULA. Pass null/None to CLEAR validation from the range. values: Rule values (e.g. ['A','B','C'] for ONE_OF_LIST). strict: Reject invalid input (false = warning only). show_dropdown: Show dropdown for list rules. dry_run: If true, return the execution plan without changing anything.

Inputs: range (required), sheet (required), spreadsheet_id_or_url (required), strict, +4 more.

set_number_formatA

Set the number format of a range (e.g. '#,##0', '0.0%', 'yyyy-mm-dd').

Only numberFormat is touched — other formatting is preserved. Formatting changes are NOT rollback-capable (use Sheets version history).

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. range: Bare A1 range without sheet prefix. pattern: Number format pattern string. type: One of TEXT/NUMBER/PERCENT/CURRENCY/DATE/TIME/DATE_TIME/SCIENTIFIC. dry_run: If true, return the execution plan without changing anything.

Inputs: range (required), sheet (required), pattern (required), spreadsheet_id_or_url (required), +2 more.

update_rangeA

Write values (or formulas) to an existing range. Overwrites current content.

Formulas like '=SUM(A:A)' are interpreted as formulas by default (USER_ENTERED). The previous values of the target range are snapshotted for rollback before writing.

Args: spreadsheet_id_or_url: Full Sheets URL or bare spreadsheet ID. sheet: Sheet name OR gid string. range: Bare A1 range without sheet prefix, e.g. 'B2:D10'. values: 2D list of cell values, rows x columns. raw: If true, store inputs literally (formulas become plain text). dry_run: If true, return the execution plan without writing. force: Allow writes touching more than the cell limit.

Inputs: range (required), sheet (required), values (required), spreadsheet_id_or_url (required), +3 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 18 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes. The only minor overlap is between update_range and batch_update_values, but their descriptions distinguish single vs. batch writes. Otherwise, each tool targets a unique aspect of sheet manipulation.

    Naming Consistency5/5

    All tool names follow a consistent snake_case verb_noun pattern (e.g., add_sheet, delete_columns, set_cell_style). No mixing of conventions, making it easy for agents to predict tool names.

    Tool Count5/5

    With 18 tools, the server covers a wide range of write operations suitable for Google Sheets. The count is appropriate—neither sparse nor overwhelming.

    Completeness4/5

    The server provides comprehensive CRUD-like coverage for sheets and data, plus formatting, validation, protection, and filtering. Minor gaps include no tool to restore from snapshots and no move sheet operation, but these are acceptable for a write-focused server.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers