A blazing-fast CLI for Google Sheets with local DuckDB caching and MCP server support
- Full Sheets API - Read, write, format cells and ranges with A1 notation
- 14 Chart Types - Line, bar, pie, scatter, bubble, candlestick, and more
- Pivot Tables - Create, update, and refresh pivot tables programmatically
- Apps Script - Manage script projects, versions, deployments, and execution
- Local Caching - DuckDB-powered offline access with bi-directional sync
- Dual Auth - OAuth 2.0 interactive flow or service account for automation
- MCP Server - Expose tools for Claude and other AI assistants
- Multiple Outputs - Table, JSON, or CSV output formats
- Profiles - Named spreadsheet profiles for quick switching
- Shell Completions - Bash, Zsh, Fish, and PowerShell support
curl -fsSL https://raw.githubusercontent.com/dipankar/gsheet-cli/main/install.sh | bashOr with options:
./install.sh --prefix ~/.local --completionsgit clone https://github.com/dipankar/gsheet-cli.git
cd gsheet-cli
cargo build --release
cp target/release/gsheet ~/.local/bin/# Interactive OAuth (opens browser)
gsheet auth login
# Or use a service account
gsheet auth login --service-account /path/to/key.jsongsheet config profile add mysheet --spreadsheet "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"# List sheets
gsheet -p mysheet sheet list
# Read a range
gsheet -p mysheet range get "Sheet1!A1:D10"
# Write values
gsheet -p mysheet cell set "A1" "Hello, World!"# Get cell value
gsheet -s SPREADSHEET_ID cell get "B2"
# Set range from JSON
gsheet -s SPREADSHEET_ID range set "A1:B2" --json '[["Name","Age"],["Alice",30]]'
# Append row to sheet
gsheet -s SPREADSHEET_ID cell append "Sheet1" "John" "Doe" "john@example.com"
# Find cells matching pattern
gsheet -s SPREADSHEET_ID range find "A1:Z100" --pattern "error|warning"# Create a new sheet
gsheet -s SPREADSHEET_ID sheet create "Q1 Report"
# Duplicate sheet
gsheet -s SPREADSHEET_ID sheet duplicate "Template" "January"
# Freeze header row
gsheet -s SPREADSHEET_ID sheet freeze --sheet "Data" --rows 1
# Set tab color
gsheet -s SPREADSHEET_ID sheet tab-color "Important" --color "#FF0000"# Bold headers
gsheet -s SPREADSHEET_ID format bold "A1:Z1"
# Set background color
gsheet -s SPREADSHEET_ID format color "A1:D1" --bg "#4285F4" --fg "#FFFFFF"
# Apply borders
gsheet -s SPREADSHEET_ID format border "A1:D10" --style solid --color "#000000"
# Merge cells
gsheet -s SPREADSHEET_ID format merge "A1:D1"
# Number format
gsheet -s SPREADSHEET_ID format number "B2:B100" --pattern "#,##0.00"# Create a column chart
gsheet -s SPREADSHEET_ID chart create --type column --data "A1:B10" --title "Sales"
# Create a pie chart
gsheet -s SPREADSHEET_ID chart create --type pie --data "A1:B5" --title "Distribution"
# Create a bubble chart
gsheet -s SPREADSHEET_ID chart bubble --x-data "A1:A10" --y-data "B1:B10" --sizes "C1:C10"# Create pivot table
gsheet -s SPREADSHEET_ID pivot create \
--source "Data!A1:E1000" \
--anchor "Pivot!A1" \
--rows "0" \
--values "2:SUM,3:AVERAGE"
# Refresh pivot table
gsheet -s SPREADSHEET_ID pivot refresh "Pivot!A1"# Run a function
gsheet script run SCRIPT_ID "myFunction" --args '["param1", 42]'
# Create and deploy
gsheet script create --title "My Script" --parent-id SPREADSHEET_ID
gsheet script version create SCRIPT_ID --description "Initial release"
gsheet script deploy create SCRIPT_ID --version 1Configuration is stored in ~/.config/gsheet-cli/config.toml:
[auth]
method = "oauth"
token_cache_path = "~/.config/gsheet-cli/tokens"
[cache]
enabled = true
ttl_seconds = 300
auto_sync = true
[output]
format = "table"
color = "auto"
[spreadsheets.mysheet]
id = "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
description = "My main spreadsheet"| Flag | Description |
|---|---|
-s, --spreadsheet <ID> |
Spreadsheet ID |
-p, --profile <NAME> |
Use named profile |
-o, --output <FORMAT> |
Output format: table, json, csv |
-c, --config <PATH> |
Custom config file |
--no-cache |
Bypass cache |
-q, --quiet |
Suppress output |
-v, -vv, -vvv |
Increase verbosity |
Start the MCP server for AI assistant integration:
# stdio transport (default)
gsheet mcp
# HTTP transport
gsheet mcp --transport http --port 8080| Tool | Description |
|---|---|
read_range |
Read values from a range |
write_range |
Write values to a range |
list_sheets |
List all sheets |
create_sheet |
Create a new sheet |
format_range |
Apply formatting |
run_macro |
Execute Apps Script function |
Add to ~/.config/claude/claude_desktop_config.json:
{
"mcpServers": {
"gsheet": {
"command": "gsheet",
"args": ["mcp"]
}
}
}| Command | Description |
|---|---|
auth |
Authentication management |
sheet |
Sheet/tab operations |
cell |
Single cell operations |
range |
Range operations |
format |
Cell formatting |
chart |
Chart operations |
pivot |
Pivot table operations |
script |
Apps Script management |
cache |
Cache management |
config |
Configuration management |
mcp |
Start MCP server |
completions |
Generate shell completions |
Run gsheet <command> --help for detailed usage.
# Bash
gsheet completions bash > ~/.local/share/bash-completion/completions/gsheet
# Zsh
gsheet completions zsh > ~/.zfunc/_gsheet
# Fish
gsheet completions fish > ~/.config/fish/completions/gsheet.fish
# PowerShell
gsheet completions powershell > $PROFILE.CurrentUserAllHosts- Rust 1.70+
- Google Cloud project with Sheets API enabled
- OAuth 2.0 credentials or service account key
cargo build
cargo test
cargo clippy# Unit tests
cargo test
# With logging
RUST_LOG=debug cargo testsrc/
├── api/ # Google Sheets API client
├── auth/ # OAuth and service account auth
├── cache/ # DuckDB caching layer
├── cli/ # Command-line interface
├── config/ # Configuration management
├── mcp/ # MCP server implementation
├── error.rs # Error types
├── lib.rs # Library entry point
└── main.rs # CLI entry point
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing) - Open a Pull Request
MIT License - see LICENSE for details.
Made with Rust by Dipankar