Skip to main content
Glama
spreadsheet-mcp-server

spreadsheet-mcp-server

by slevin48
README.md
# Spreadsheet MCP🛠️

Tools:
- `list_worksheets`
- `show_sheet`
- `read_cell`
- `find_cell`
- `filter_rows_by_columns`

## Call from Claude

![show_sheet](img/show_sheet.png)

![filter](img/filter.png)

Setup:
`C:\Users\<username>\AppData\Roaming\Claude\claude_desktop_config.json`

```json
{
  "mcpServers": {
    "spreadsheet-mcp-server": {
      "command": "uvx",
      "args": [
        "--with-requirements=\\path\\to\\requirements.txt",
        "python",
        "\\path\\to\\main.py"
      ]
    }
  }
}
```


## Call from VSCode



https://github.com/user-attachments/assets/b640f1de-a97f-4d50-bd0e-3c3ad2baaa46



Command:
`uvx --with-requirements=requirements.txt python main.py`

This will generate the following file in `.vscode/` is you setup the MCP server for your workspace:
`mcp.json`:

```json
{
	"servers": {
		"spreadsheet-mcp-server": {
			"type": "stdio",
			"command": "uvx",
            "cwd": "C:\\path\\to\\spreadsheet-MCP", // C:\\Users\\ydebray\\Downloads\\magic-spread
			"args": [
				"--with-requirements=requirements.txt",
				"python",
				"main.py"
			]
		}
	},
	"inputs": []
}
```

## Connect to Google Sheets with gspread

This small helper shows how to connect to a private spreadsheet using gspread and a service account (or user OAuth).

Service account:
![Create service account](img/Create-service-account.png)
![Share "magic-spread"](img/Share-magic-spread.png)

Files added:

- `connect_gspread.py` — script to authorize and print a small preview of the spreadsheet.
- `requirements.txt` — minimal Python dependencies.
- `.gitignore` — ignores credential files.

Quick steps (Windows cmd.exe):

1. Activate the virtualenv in this repo (if you use the provided `env`):

```cmd
call env\Scripts\activate.bat
```

2. Install dependencies:

```cmd
pip install -r requirements.txt
```

3. Provide credentials (one of the service-account options below):

- Recommended: create a service account in Google Cloud, grant it at least Viewer access to the spreadsheet, then download the JSON key file and set:

```cmd
set GOOGLE_APPLICATION_CREDENTIALS=C:\path\to\service-account.json
```

- Alternative: set the JSON contents into an environment variable (not recommended for large JSONs):

```cmd
set GSPREAD_SERVICE_ACCOUNT_JSON={...JSON contents...}
```

4. Run the script (the default sheet id is already set in the script):

```cmd
python connect_gspread.py --sheet-id <your-spreadsheet-id>
```

Notes:

- If you prefer OAuth with a user account, ensure `gspread.oauth()` is configured (the script falls back to it but you need local OAuth config).
- Keep credential JSON files out of source control. `.gitignore` was added to help with that.

If you want, I can run a quick local test in your environment — but I cannot access your credentials. If you paste a sanitized path to a service-account JSON that is already in the workspace (or set the env var), I can run the script here.

## Debug the MCP Server

https://modelcontextprotocol.io/docs/tools/inspector

```
npx @modelcontextprotocol/inspector python main.py
```


![inspector](img/inspector.png)