mcp-server-spreadsheet 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(uv run python -c \"\nfrom odf.table import Table\nprint\\(type\\(Table\\)\\)\nprint\\(repr\\(Table\\)\\)\n# check if it's a class or something else\nimport inspect\nprint\\('is class:', inspect.isclass\\(Table\\)\\)\n\" 2>&1)",
5
+ "Bash(uv run python -c \"\nfrom odf.table import Table, TableRow, TableCell\n# Create instances to get their qname\nt = Table\\(\\)\ntr = TableRow\\(\\)\ntc = TableCell\\(\\)\nprint\\('Table qname:', t.qname\\)\nprint\\('TableRow qname:', tr.qname\\)\nprint\\('TableCell qname:', tc.qname\\)\nprint\\('type of element:', type\\(t\\)\\)\nprint\\('type name:', type\\(t\\).__name__\\)\n\" 2>&1)",
6
+ "Bash(uv run python -c \"\nfrom backends import load_workbook\n\n# --- XLSX ---\nwb = load_workbook\\('examples/example.xlsx'\\)\nprint\\('=== XLSX ==='\\)\nprint\\('Sheets:', wb.sheetnames\\)\nfor ws in wb.worksheets:\n print\\(f' {ws.title}: {ws.max_row} rows x {ws.max_column} cols'\\)\n rows = list\\(ws.iter_rows\\(max_row=3\\)\\)\n for r in rows:\n print\\(f' {r}'\\)\n\" 2>&1)",
7
+ "Bash(uv run python -c \"\nfrom backends import load_workbook\n\n# --- CSV free-form ---\nwb = load_workbook\\('examples/example-free-form.csv'\\)\nprint\\('=== CSV free-form ==='\\)\nprint\\('Sheets:', wb.sheetnames\\)\nws = wb.worksheets[0]\nprint\\(f' {ws.title}: {ws.max_row} rows x {ws.max_column} cols'\\)\nrows = list\\(ws.iter_rows\\(max_row=5\\)\\)\nfor r in rows:\n print\\(f' {r}'\\)\n\nprint\\(\\)\n\n# --- CSV table ---\nwb = load_workbook\\('examples/example-table.csv'\\)\nprint\\('=== CSV table ==='\\)\nws = wb.worksheets[0]\nprint\\(f' {ws.title}: {ws.max_row} rows x {ws.max_column} cols'\\)\nrows = list\\(ws.iter_rows\\(max_row=5\\)\\)\nfor r in rows:\n print\\(f' {r}'\\)\n\" 2>&1)",
8
+ "Bash(uv run python -c \"\nfrom backends import load_workbook\n\n# --- ODS ---\nwb = load_workbook\\('examples/example.ods'\\)\nprint\\('=== ODS ==='\\)\nprint\\('Sheets:', wb.sheetnames\\)\nfor ws in wb.worksheets:\n print\\(f' {ws.title}: {ws.max_row} rows x {ws.max_column} cols'\\)\n rows = list\\(ws.iter_rows\\(max_row=3\\)\\)\n for r in rows:\n print\\(f' {r}'\\)\n\" 2>&1)",
9
+ "Bash(uv run python -c \"\nimport shutil, os, tempfile\n\n# Work on copies to avoid modifying originals\ntmpdir = tempfile.mkdtemp\\(\\)\nfor f in os.listdir\\('examples'\\):\n shutil.copy2\\(f'examples/{f}', f'{tmpdir}/{f}'\\)\n\n# Import tools\nfrom main import \\(\n list_workbooks, read_sheet, read_cell, read_range,\n get_sheet_dimensions, search_sheet, list_sheets,\n write_cell, append_rows, describe_table, sql_query,\n\\)\n\n# --- list_workbooks ---\nfiles = list_workbooks\\(tmpdir\\)\nprint\\('list_workbooks:', files\\)\nassert len\\(files\\) == 4 # 2 csv + 1 xlsx + 1 ods\n\n# --- XLSX tests ---\nxlsx = f'{tmpdir}/example.xlsx'\nprint\\(\\)\nprint\\('=== XLSX tool tests ==='\\)\nprint\\('list_sheets:', list_sheets\\(xlsx\\)\\)\nprint\\('dimensions \\(Free-form\\):', get_sheet_dimensions\\(xlsx, sheet='Free-form'\\)\\)\nprint\\('read_cell B2:', read_cell\\(xlsx, 'B2', sheet='Free-form'\\)\\)\nprint\\('read_range A1:B3:', read_range\\(xlsx, 'A1:B3', sheet='Free-form'\\)\\)\nprint\\('search:', search_sheet\\(xlsx, 'sql_query', sheet='Table'\\)\\)\n\n# --- CSV tests ---\ncsv_f = f'{tmpdir}/example-table.csv'\nprint\\(\\)\nprint\\('=== CSV tool tests ==='\\)\nprint\\('list_sheets:', list_sheets\\(csv_f\\)\\)\nprint\\('dimensions:', get_sheet_dimensions\\(csv_f\\)\\)\nprint\\('read_cell A1:', read_cell\\(csv_f, 'A1'\\)\\)\nprint\\('read_range A1:C3:', read_range\\(csv_f, 'A1:C3'\\)\\)\nprint\\('search:', search_sheet\\(csv_f, 'sql_query'\\)\\)\n\n# --- ODS tests ---\nods = f'{tmpdir}/example.ods'\nprint\\(\\)\nprint\\('=== ODS tool tests ==='\\)\nprint\\('list_sheets:', list_sheets\\(ods\\)\\)\nprint\\('dimensions \\(Table\\):', get_sheet_dimensions\\(ods, sheet='Table'\\)\\)\nprint\\('read_cell A1 \\(Table\\):', read_cell\\(ods, 'A1', sheet='Table'\\)\\)\nprint\\('read_range A1:C3 \\(Table\\):', read_range\\(ods, 'A1:C3', sheet='Table'\\)\\)\nprint\\('search:', search_sheet\\(ods, 'sql_query', sheet='Table'\\)\\)\n\nshutil.rmtree\\(tmpdir\\)\nprint\\(\\)\nprint\\('All tool tests passed!'\\)\n\" 2>&1)",
10
+ "Bash(uv run python -c \"\nfrom main import add_sheet, delete_sheet, copy_sheet\n\n# CSV should reject multi-sheet operations\nimport tempfile, os\nfrom backends import create_workbook\n\ntmpdir = tempfile.mkdtemp\\(\\)\npath = f'{tmpdir}/test.csv'\nwb = create_workbook\\(path\\)\nwb.save\\(path\\)\n\nerrors = []\nfor op_name, op in [\\('add_sheet', lambda: add_sheet\\(path, 'new'\\)\\),\n \\('delete_sheet', lambda: delete_sheet\\(path, 'default'\\)\\),\n \\('copy_sheet', lambda: copy_sheet\\(path, 'default'\\)\\)]:\n try:\n op\\(\\)\n errors.append\\(f'{op_name} should have raised'\\)\n except ValueError as e:\n print\\(f'{op_name} correctly raised: {e}'\\)\n\nimport shutil\nshutil.rmtree\\(tmpdir\\)\n\nif errors:\n print\\('FAILURES:', errors\\)\nelse:\n print\\('CSV sheet constraints OK'\\)\n\" 2>&1)",
11
+ "Bash(gh repo view --json nameWithOwner,name 2>&1)"
12
+ ]
13
+ }
14
+ }
@@ -0,0 +1,10 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Marek Rost
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,226 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-server-spreadsheet
3
+ Version: 0.2.0
4
+ Summary: MCP server for reading and writing spreadsheet files (.xlsx, .csv, .ods)
5
+ Project-URL: Repository, https://github.com/marekrost/mcp-server-spreadsheet
6
+ Author: Marek Rost
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Keywords: csv,duckdb,mcp,ods,spreadsheet,sql,xlsx
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Requires-Python: >=3.13
14
+ Requires-Dist: duckdb>=0.10.0
15
+ Requires-Dist: mcp>=1.0.0
16
+ Requires-Dist: odfpy>=1.4.0
17
+ Requires-Dist: openpyxl>=3.1.0
18
+ Description-Content-Type: text/markdown
19
+
20
+ # mcp-server-spreadsheet
21
+
22
+ Data-first MCP server for reading and writing spreadsheet files (`.xlsx`, `.csv`, `.ods`).
23
+
24
+ ## Key features
25
+
26
+ - **Multi-format** — works with Excel (`.xlsx`), CSV (`.csv`), and OpenDocument (`.ods`) files through a unified tool interface.
27
+ - **Dual mode** — cell-level workbook operations and a DuckDB-powered SQL query engine, interleaved freely on the same file.
28
+ - **Workbook essentials** — worksheets, rows, columns, cells, search.
29
+ - **Data-only** — preserves existing formatting but only reads and writes values.
30
+ - **Stateless** — every call specifies `file` and `sheet` explicitly; no handles or sessions.
31
+ - **Atomic saves** — writes go to a temp file, then `os.replace()` into the target path.
32
+ - **Type coercion on write** — numeric strings become numbers, everything else is text.
33
+ - **SQL across sheets** — JOINs, GROUP BY, aggregates, subqueries via in-memory DuckDB; mutations write back to the file.
34
+ - **CSV as single-sheet workbook** — CSV files are treated as a workbook with one sheet named `default`.
35
+
36
+ ## Requirements
37
+
38
+ - Python 3.13+
39
+
40
+ ## Installation
41
+
42
+ ### From PyPI (recommended)
43
+
44
+ No local checkout needed — just configure your MCP client (see below).
45
+
46
+ ### From source (for development)
47
+
48
+ ```bash
49
+ git clone https://github.com/marekrost/mcp-server-spreadsheet.git
50
+ cd mcp-server-spreadsheet
51
+ uv sync
52
+ ```
53
+
54
+ ## Usage
55
+
56
+ ### Claude Desktop
57
+
58
+ Add to your `claude_desktop_config.json`:
59
+
60
+ **Using PyPI (recommended):**
61
+
62
+ ```json
63
+ {
64
+ "mcpServers": {
65
+ "mcp-server-spreadsheet": {
66
+ "command": "uvx",
67
+ "args": ["mcp-server-spreadsheet"]
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ **Using local source:**
74
+
75
+ ```json
76
+ {
77
+ "mcpServers": {
78
+ "mcp-server-spreadsheet": {
79
+ "command": "uv",
80
+ "args": ["run", "--directory", "/path/to/mcp-server-spreadsheet", "main.py"]
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ ### Claude Code
87
+
88
+ Add to your `.mcp.json`:
89
+
90
+ **Using PyPI (recommended):**
91
+
92
+ ```json
93
+ {
94
+ "mcpServers": {
95
+ "mcp-server-spreadsheet": {
96
+ "command": "uvx",
97
+ "args": ["mcp-server-spreadsheet"]
98
+ }
99
+ }
100
+ }
101
+ ```
102
+
103
+ **Using local source:**
104
+
105
+ ```json
106
+ {
107
+ "mcpServers": {
108
+ "mcp-server-spreadsheet": {
109
+ "command": "uv",
110
+ "args": ["run", "--directory", "/path/to/mcp-server-spreadsheet", "main.py"]
111
+ }
112
+ }
113
+ }
114
+ ```
115
+
116
+ ### Standalone (stdio transport)
117
+
118
+ ```bash
119
+ # PyPI
120
+ uvx mcp-server-spreadsheet
121
+
122
+ # Local source
123
+ uv run main.py
124
+ ```
125
+
126
+ ## Format notes
127
+
128
+ | Format | Sheets | Formulas | Types |
129
+ |---|---|---|---|
130
+ | `.xlsx` | Multiple | Preserved as strings | Native (int, float, date, bool) |
131
+ | `.ods` | Multiple | Not preserved | Native (int, float, date, bool) |
132
+ | `.csv` | Single (`default`) | N/A | Inferred on load (int, float, text) |
133
+
134
+ Sheet management tools (`add_sheet`, `delete_sheet`, `copy_sheet`) raise an error for CSV files.
135
+
136
+ ## Tools
137
+
138
+ ### Workbook Operations
139
+
140
+ | Tool | Description |
141
+ |---|---|
142
+ | `list_workbooks` | List all spreadsheet files in a directory (non-recursive) |
143
+ | `create_workbook_file` | Create a new empty spreadsheet file (format by extension) |
144
+ | `copy_workbook` | Copy an existing file to a new path |
145
+
146
+ ### Sheet Operations
147
+
148
+ | Tool | Description |
149
+ |---|---|
150
+ | `list_sheets` | List all sheet names in a workbook |
151
+ | `add_sheet` | Add a new sheet (optional name and position) |
152
+ | `rename_sheet` | Rename an existing sheet |
153
+ | `delete_sheet` | Delete a sheet by name |
154
+ | `copy_sheet` | Duplicate a sheet within a workbook (optional new name and position) |
155
+
156
+ ### Reading Data
157
+
158
+ | Tool | Description |
159
+ |---|---|
160
+ | `read_sheet` | Read entire sheet as rows (optional row/column bounds) |
161
+ | `read_cell` | Read a single cell value, e.g. `B3` |
162
+ | `read_range` | Read a rectangular range, e.g. `A1:D10` |
163
+ | `get_sheet_dimensions` | Get row and column count of the used range |
164
+
165
+ ### Writing Data
166
+
167
+ | Tool | Description |
168
+ |---|---|
169
+ | `write_cell` | Write a value to a single cell |
170
+ | `write_range` | Write a 2D array starting at a given cell |
171
+ | `append_rows` | Append rows after the last used row |
172
+ | `insert_rows` | Insert blank or pre-filled rows at a position (shifts rows down) |
173
+ | `delete_rows` | Delete rows by index (shifts rows up) |
174
+ | `clear_range` | Clear values in a range without removing rows/columns |
175
+ | `copy_range` | Copy a block of cells to another location (optionally to a different sheet) |
176
+
177
+ ### Column Operations
178
+
179
+ | Tool | Description |
180
+ |---|---|
181
+ | `insert_columns` | Insert blank columns at a position |
182
+ | `delete_columns` | Delete columns by index |
183
+
184
+ ### Search
185
+
186
+ | Tool | Description |
187
+ |---|---|
188
+ | `search_sheet` | Search for a value or regex pattern, returns matching cell references |
189
+
190
+ ### Table Mode (SQL)
191
+
192
+ | Tool | Description |
193
+ |---|---|
194
+ | `describe_table` | Inspect column names, inferred types, row count, and sample values |
195
+ | `sql_query` | Execute a read-only SQL `SELECT` (supports JOINs across sheets, GROUP BY, aggregates, subqueries) |
196
+ | `sql_execute` | Execute `INSERT INTO`, `UPDATE`, or `DELETE FROM` — writes changes back to the file |
197
+
198
+ SQL examples:
199
+
200
+ ```sql
201
+ -- Filter and sort
202
+ SELECT name, revenue FROM Sales WHERE status = 'Active' ORDER BY revenue DESC LIMIT 20
203
+
204
+ -- Cross-sheet JOIN
205
+ SELECT o.order_id, c.name FROM Orders o JOIN Customers c ON o.customer_id = c.id
206
+
207
+ -- Aggregate
208
+ SELECT department, COUNT(*) AS n, AVG(salary) AS avg FROM Employees GROUP BY department
209
+
210
+ -- Mutate
211
+ UPDATE Sales SET status = 'Closed' WHERE quarter = 'Q1' AND revenue < 1000
212
+ DELETE FROM Logs WHERE date < '2024-01-01'
213
+ ```
214
+
215
+ Sheet names with spaces must be quoted: `SELECT * FROM "Q1 Sales"`.
216
+
217
+ ## Common Parameters
218
+
219
+ Every sheet-level tool accepts:
220
+
221
+ | Parameter | Required | Description |
222
+ |---|---|---|
223
+ | `file` | yes | Path to the spreadsheet file (.xlsx, .csv, or .ods) |
224
+ | `sheet` | no | Sheet name. Defaults to the first sheet in the workbook |
225
+
226
+ All row/column indices are **1-based**. Cell references use A1 notation (`A1`, `$B$2`).
@@ -0,0 +1,207 @@
1
+ # mcp-server-spreadsheet
2
+
3
+ Data-first MCP server for reading and writing spreadsheet files (`.xlsx`, `.csv`, `.ods`).
4
+
5
+ ## Key features
6
+
7
+ - **Multi-format** — works with Excel (`.xlsx`), CSV (`.csv`), and OpenDocument (`.ods`) files through a unified tool interface.
8
+ - **Dual mode** — cell-level workbook operations and a DuckDB-powered SQL query engine, interleaved freely on the same file.
9
+ - **Workbook essentials** — worksheets, rows, columns, cells, search.
10
+ - **Data-only** — preserves existing formatting but only reads and writes values.
11
+ - **Stateless** — every call specifies `file` and `sheet` explicitly; no handles or sessions.
12
+ - **Atomic saves** — writes go to a temp file, then `os.replace()` into the target path.
13
+ - **Type coercion on write** — numeric strings become numbers, everything else is text.
14
+ - **SQL across sheets** — JOINs, GROUP BY, aggregates, subqueries via in-memory DuckDB; mutations write back to the file.
15
+ - **CSV as single-sheet workbook** — CSV files are treated as a workbook with one sheet named `default`.
16
+
17
+ ## Requirements
18
+
19
+ - Python 3.13+
20
+
21
+ ## Installation
22
+
23
+ ### From PyPI (recommended)
24
+
25
+ No local checkout needed — just configure your MCP client (see below).
26
+
27
+ ### From source (for development)
28
+
29
+ ```bash
30
+ git clone https://github.com/marekrost/mcp-server-spreadsheet.git
31
+ cd mcp-server-spreadsheet
32
+ uv sync
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ### Claude Desktop
38
+
39
+ Add to your `claude_desktop_config.json`:
40
+
41
+ **Using PyPI (recommended):**
42
+
43
+ ```json
44
+ {
45
+ "mcpServers": {
46
+ "mcp-server-spreadsheet": {
47
+ "command": "uvx",
48
+ "args": ["mcp-server-spreadsheet"]
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ **Using local source:**
55
+
56
+ ```json
57
+ {
58
+ "mcpServers": {
59
+ "mcp-server-spreadsheet": {
60
+ "command": "uv",
61
+ "args": ["run", "--directory", "/path/to/mcp-server-spreadsheet", "main.py"]
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ ### Claude Code
68
+
69
+ Add to your `.mcp.json`:
70
+
71
+ **Using PyPI (recommended):**
72
+
73
+ ```json
74
+ {
75
+ "mcpServers": {
76
+ "mcp-server-spreadsheet": {
77
+ "command": "uvx",
78
+ "args": ["mcp-server-spreadsheet"]
79
+ }
80
+ }
81
+ }
82
+ ```
83
+
84
+ **Using local source:**
85
+
86
+ ```json
87
+ {
88
+ "mcpServers": {
89
+ "mcp-server-spreadsheet": {
90
+ "command": "uv",
91
+ "args": ["run", "--directory", "/path/to/mcp-server-spreadsheet", "main.py"]
92
+ }
93
+ }
94
+ }
95
+ ```
96
+
97
+ ### Standalone (stdio transport)
98
+
99
+ ```bash
100
+ # PyPI
101
+ uvx mcp-server-spreadsheet
102
+
103
+ # Local source
104
+ uv run main.py
105
+ ```
106
+
107
+ ## Format notes
108
+
109
+ | Format | Sheets | Formulas | Types |
110
+ |---|---|---|---|
111
+ | `.xlsx` | Multiple | Preserved as strings | Native (int, float, date, bool) |
112
+ | `.ods` | Multiple | Not preserved | Native (int, float, date, bool) |
113
+ | `.csv` | Single (`default`) | N/A | Inferred on load (int, float, text) |
114
+
115
+ Sheet management tools (`add_sheet`, `delete_sheet`, `copy_sheet`) raise an error for CSV files.
116
+
117
+ ## Tools
118
+
119
+ ### Workbook Operations
120
+
121
+ | Tool | Description |
122
+ |---|---|
123
+ | `list_workbooks` | List all spreadsheet files in a directory (non-recursive) |
124
+ | `create_workbook_file` | Create a new empty spreadsheet file (format by extension) |
125
+ | `copy_workbook` | Copy an existing file to a new path |
126
+
127
+ ### Sheet Operations
128
+
129
+ | Tool | Description |
130
+ |---|---|
131
+ | `list_sheets` | List all sheet names in a workbook |
132
+ | `add_sheet` | Add a new sheet (optional name and position) |
133
+ | `rename_sheet` | Rename an existing sheet |
134
+ | `delete_sheet` | Delete a sheet by name |
135
+ | `copy_sheet` | Duplicate a sheet within a workbook (optional new name and position) |
136
+
137
+ ### Reading Data
138
+
139
+ | Tool | Description |
140
+ |---|---|
141
+ | `read_sheet` | Read entire sheet as rows (optional row/column bounds) |
142
+ | `read_cell` | Read a single cell value, e.g. `B3` |
143
+ | `read_range` | Read a rectangular range, e.g. `A1:D10` |
144
+ | `get_sheet_dimensions` | Get row and column count of the used range |
145
+
146
+ ### Writing Data
147
+
148
+ | Tool | Description |
149
+ |---|---|
150
+ | `write_cell` | Write a value to a single cell |
151
+ | `write_range` | Write a 2D array starting at a given cell |
152
+ | `append_rows` | Append rows after the last used row |
153
+ | `insert_rows` | Insert blank or pre-filled rows at a position (shifts rows down) |
154
+ | `delete_rows` | Delete rows by index (shifts rows up) |
155
+ | `clear_range` | Clear values in a range without removing rows/columns |
156
+ | `copy_range` | Copy a block of cells to another location (optionally to a different sheet) |
157
+
158
+ ### Column Operations
159
+
160
+ | Tool | Description |
161
+ |---|---|
162
+ | `insert_columns` | Insert blank columns at a position |
163
+ | `delete_columns` | Delete columns by index |
164
+
165
+ ### Search
166
+
167
+ | Tool | Description |
168
+ |---|---|
169
+ | `search_sheet` | Search for a value or regex pattern, returns matching cell references |
170
+
171
+ ### Table Mode (SQL)
172
+
173
+ | Tool | Description |
174
+ |---|---|
175
+ | `describe_table` | Inspect column names, inferred types, row count, and sample values |
176
+ | `sql_query` | Execute a read-only SQL `SELECT` (supports JOINs across sheets, GROUP BY, aggregates, subqueries) |
177
+ | `sql_execute` | Execute `INSERT INTO`, `UPDATE`, or `DELETE FROM` — writes changes back to the file |
178
+
179
+ SQL examples:
180
+
181
+ ```sql
182
+ -- Filter and sort
183
+ SELECT name, revenue FROM Sales WHERE status = 'Active' ORDER BY revenue DESC LIMIT 20
184
+
185
+ -- Cross-sheet JOIN
186
+ SELECT o.order_id, c.name FROM Orders o JOIN Customers c ON o.customer_id = c.id
187
+
188
+ -- Aggregate
189
+ SELECT department, COUNT(*) AS n, AVG(salary) AS avg FROM Employees GROUP BY department
190
+
191
+ -- Mutate
192
+ UPDATE Sales SET status = 'Closed' WHERE quarter = 'Q1' AND revenue < 1000
193
+ DELETE FROM Logs WHERE date < '2024-01-01'
194
+ ```
195
+
196
+ Sheet names with spaces must be quoted: `SELECT * FROM "Q1 Sales"`.
197
+
198
+ ## Common Parameters
199
+
200
+ Every sheet-level tool accepts:
201
+
202
+ | Parameter | Required | Description |
203
+ |---|---|---|
204
+ | `file` | yes | Path to the spreadsheet file (.xlsx, .csv, or .ods) |
205
+ | `sheet` | no | Sheet name. Defaults to the first sheet in the workbook |
206
+
207
+ All row/column indices are **1-based**. Cell references use A1 notation (`A1`, `$B$2`).
@@ -0,0 +1,45 @@
1
+ "Workbook operations",
2
+ "Tool","Description"
3
+ "list_workbooks","List all spreadsheet files in a directory (non-recursive)"
4
+ "create_workbook_file","Create a new empty spreadsheet file (format by extension)"
5
+ "copy_workbook","Copy an existing file to a new path"
6
+ ,
7
+ "Sheet operations",
8
+ "Tool","Description"
9
+ "list_sheets","List all sheet names in a workbook"
10
+ "add_sheet","Add a new sheet (optional name and position)"
11
+ "rename_sheet","Rename an existing sheet"
12
+ "delete_sheet","Delete a sheet by name"
13
+ "copy_sheet","Duplicate a sheet within a workbook (optional new name and position)"
14
+ ,
15
+ "Worksheet reading",
16
+ "Tool","Description"
17
+ "read_sheet","Read entire sheet as rows (optional row/column bounds)"
18
+ "read_cell","Read a single cell value, e.g. `B3`"
19
+ "read_range","Read a rectangular range, e.g. `A1:D10`"
20
+ "get_sheet_dimensions","Get row and column count of the used range"
21
+ ,
22
+ "Worksheet writing",
23
+ "Tool","Description"
24
+ "write_cell","Write a value to a single cell"
25
+ "write_range","Write a 2D array starting at a given cell"
26
+ "append_rows","Append rows after the last used row"
27
+ "insert_rows","Insert blank or pre-filled rows at a position (shifts rows down)"
28
+ "delete_rows","Delete rows by index (shifts rows up)"
29
+ "clear_range","Clear values in a range without removing rows/columns"
30
+ "copy_range","Copy a block of cells to another location (optionally to a different sheet)"
31
+ ,
32
+ "Column operations",
33
+ "Tool","Description"
34
+ "insert_columns","Insert blank columns at a position"
35
+ "delete_columns","Delete columns by index"
36
+ ,
37
+ "Search",
38
+ "Tool","Description"
39
+ "search_sheet","Search for a value or regex pattern, returns matching cell references"
40
+ ,
41
+ "SQL table mode",
42
+ "Tool","Description"
43
+ "describe_table","Inspect column names, inferred types, row count, and sample values"
44
+ "sql_query","Execute a read-only SQL `SELECT` (supports JOINs across sheets, GROUP BY, aggregates, subqueries)"
45
+ "sql_execute","Execute `INSERT INTO`, `UPDATE`, or `DELETE FROM` — writes changes back to the file"
@@ -0,0 +1,26 @@
1
+ "Tool category","Tool","Description"
2
+ "Workbook operations","list_workbooks","List all spreadsheet files in a directory (non-recursive)"
3
+ "Workbook operations","create_workbook_file","Create a new empty spreadsheet file (format by extension)"
4
+ "Workbook operations","copy_workbook","Copy an existing file to a new path"
5
+ "Sheet operations","list_sheets","List all sheet names in a workbook"
6
+ "Sheet operations","add_sheet","Add a new sheet (optional name and position)"
7
+ "Sheet operations","rename_sheet","Rename an existing sheet"
8
+ "Sheet operations","delete_sheet","Delete a sheet by name"
9
+ "Sheet operations","copy_sheet","Duplicate a sheet within a workbook (optional new name and position)"
10
+ "Worksheet reading","read_sheet","Read entire sheet as rows (optional row/column bounds)"
11
+ "Worksheet reading","read_cell","Read a single cell value, e.g. `B3`"
12
+ "Worksheet reading","read_range","Read a rectangular range, e.g. `A1:D10`"
13
+ "Worksheet reading","get_sheet_dimensions","Get row and column count of the used range"
14
+ "Worksheet writing","write_cell","Write a value to a single cell"
15
+ "Worksheet writing","write_range","Write a 2D array starting at a given cell"
16
+ "Worksheet writing","append_rows","Append rows after the last used row"
17
+ "Worksheet writing","insert_rows","Insert blank or pre-filled rows at a position (shifts rows down)"
18
+ "Worksheet writing","delete_rows","Delete rows by index (shifts rows up)"
19
+ "Worksheet writing","clear_range","Clear values in a range without removing rows/columns"
20
+ "Worksheet writing","copy_range","Copy a block of cells to another location (optionally to a different sheet)"
21
+ "Column operations","insert_columns","Insert blank columns at a position"
22
+ "Column operations","delete_columns","Delete columns by index"
23
+ "Search","search_sheet","Search for a value or regex pattern, returns matching cell references"
24
+ "SQL table mode","describe_table","Inspect column names, inferred types, row count, and sample values"
25
+ "SQL table mode","sql_query","Execute a read-only SQL `SELECT` (supports JOINs across sheets, GROUP BY, aggregates, subqueries)"
26
+ "SQL table mode","sql_execute","Execute `INSERT INTO`, `UPDATE`, or `DELETE FROM` — writes changes back to the file"
@@ -0,0 +1,6 @@
1
+ """Local dev entry point — delegates to the installed package."""
2
+
3
+ from mcp_server_spreadsheet.server import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "mcp-server-spreadsheet"
7
+ version = "0.2.0"
8
+ description = "MCP server for reading and writing spreadsheet files (.xlsx, .csv, .ods)"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.13"
12
+ authors = [{ name = "Marek Rost" }]
13
+ keywords = ["mcp", "spreadsheet", "xlsx", "csv", "ods", "duckdb", "sql"]
14
+ classifiers = [
15
+ "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.13",
18
+ ]
19
+ dependencies = [
20
+ "mcp>=1.0.0",
21
+ "openpyxl>=3.1.0",
22
+ "duckdb>=0.10.0",
23
+ "odfpy>=1.4.0",
24
+ ]
25
+
26
+ [project.scripts]
27
+ mcp-server-spreadsheet = "mcp_server_spreadsheet.server:main"
28
+
29
+ [project.urls]
30
+ Repository = "https://github.com/marekrost/mcp-server-spreadsheet"
31
+
32
+ [dependency-groups]
33
+ dev = ["hatchling"]
@@ -0,0 +1,3 @@
1
+ """MCP server for reading and writing spreadsheet files."""
2
+
3
+ __version__ = "0.2.0"
@@ -0,0 +1,46 @@
1
+ """Spreadsheet backend factory — dispatches by file extension."""
2
+
3
+ from pathlib import Path
4
+
5
+ from .base import SpreadsheetWorkbook
6
+
7
+ SUPPORTED_EXTENSIONS = {".xlsx", ".csv", ".ods"}
8
+
9
+
10
+ def load_workbook(path: str) -> SpreadsheetWorkbook:
11
+ """Load a spreadsheet file, choosing the backend by extension."""
12
+ p = Path(path)
13
+ if not p.exists():
14
+ raise ValueError(f"File not found: {path}")
15
+ ext = p.suffix.lower()
16
+ if ext == ".xlsx":
17
+ from .xlsx import XlsxWorkbook
18
+ return XlsxWorkbook.load(path)
19
+ if ext == ".csv":
20
+ from .csv import CsvWorkbook
21
+ return CsvWorkbook.load(path)
22
+ if ext == ".ods":
23
+ from .ods import OdsWorkbook
24
+ return OdsWorkbook.load(path)
25
+ raise ValueError(
26
+ f"Unsupported file format: {ext!r}. "
27
+ f"Supported: {', '.join(sorted(SUPPORTED_EXTENSIONS))}"
28
+ )
29
+
30
+
31
+ def create_workbook(path: str, sheet_name: str | None = None) -> SpreadsheetWorkbook:
32
+ """Create a new empty workbook in memory, choosing the backend by extension."""
33
+ ext = Path(path).suffix.lower()
34
+ if ext == ".xlsx":
35
+ from .xlsx import XlsxWorkbook
36
+ return XlsxWorkbook.create(sheet_name)
37
+ if ext == ".csv":
38
+ from .csv import CsvWorkbook
39
+ return CsvWorkbook.create(sheet_name)
40
+ if ext == ".ods":
41
+ from .ods import OdsWorkbook
42
+ return OdsWorkbook.create(sheet_name)
43
+ raise ValueError(
44
+ f"Unsupported file format: {ext!r}. "
45
+ f"Supported: {', '.join(sorted(SUPPORTED_EXTENSIONS))}"
46
+ )