
Mcp Gsheets
io.github.freema由 GitHub 帳號 freema 發布v1.11.1更新於 Nov 7, 2026
MCP server for Google Sheets API — read, write, format, batch operations.
概覽
本機 MCP 伺服器,讓助理透過 Google 服務帳戶讀取、寫入、格式化及管理 Google Sheets 試算表。
- 可以做什麼
- 讀取單一或多個範圍的儲存格值,以及試算表中繼資料與存取權限檢查
- 寫入、附加、清除及插入值、列、連結與日期
- 建立、複製、跨試算表複製、刪除及重新命名工作表和分頁
- 設定儲存格格式、框線、合併、條件格式規則與原生表格
- 建立、更新及刪除圖表
- 檢視結構、尺寸、格式、篩選器與資料驗證,並支援精簡快照
- 適用情境
- 當你希望助理直接處理 Google Sheets 檔案時使用:擷取資料、填寫或清理範圍、調整工作表結構,或套用格式與圖表。唯讀模式和工具集限制也適合以讀取為主的輕量工作階段。
- 執行需求
- 透過 npx 在本機執行,需要 Node.js v22 或以上版本。需要已啟用 Sheets API 的 Google Cloud 專案與服務帳戶金鑰,可用金鑰檔案路徑(GOOGLE_APPLICATION_CREDENTIALS)、JSON 字串(GOOGLE_SERVICE_ACCOUNT_KEY)或私鑰加電子郵件(GOOGLE_PRIVATE_KEY、GOOGLE_CLIENT_EMAIL)提供;部分方式需要 GOOGLE_PROJECT_ID。每個試算表都須共用給服務帳戶電子郵件。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Mcp Gsheets,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
MCP Google Sheets Server
[圖片][npm version] [CI] [Coverage] [License: MIT] [TypeScript] [Node] [code style: prettier]
A Model Context Protocol (MCP) server for Google Sheets API integration. Enables reading, writing, and managing Google Sheets documents directly from your MCP client (e.g., Claude Code, Claude Desktop, Cursor, etc.).
Key Features
- Complete Google Sheets Integration: Read, write, and manage spreadsheets
- Advanced Operations: Batch operations, formatting, charts, and conditional formatting
- Flexible Authentication: Support for both file-based and JSON string credentials
- Production Ready: Built with TypeScript, comprehensive error handling, and full test coverage
Requirements
- Node.js v22 or higher
- Google Cloud Project with Sheets API enabled
- Service Account with JSON key file
- npm
Getting Started
Quick Install (Recommended)
Add the following config to your MCP client:
[!NOTE] Using
mcp-gsheets@latestensures that your MCP client will always use the latest version of the MCP Google Sheets server.
MCP Client Configuration
Claude Code
Use the Claude Code CLI to add the MCP Google Sheets server (guide):After adding, edit your Claude Code config to add the required environment variables:
Claude Desktop
Add to your Claude Desktop config:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/claude/claude_desktop_config.json
Cursor
Go to Cursor Settings → MCP → New MCP Server. Use the config provided above.
Cline
Follow https://docs.cline.bot/mcp/configuring-mcp-servers and use the config provided above.
Other MCP Clients
For other MCP clients, use the standard configuration format shown above. Ensure the command is set to npx and include the environment variables for Google Cloud authentication.
Google Cloud Setup
- Go to Google Cloud Console
- Create a new project or select existing
- Enable Google Sheets API:
- Navigate to "APIs & Services" → "Library"
- Search for "Google Sheets API" and click "Enable"
- Create Service Account:
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "Service Account"
- In the service accounts list, click the three dots in the
Actionscolumn →Manage keys→Add key→Create new key→ select JSON format - Download the JSON key file
- Share your spreadsheets:
- Open your Google Sheet
- Click Share and add the service account email (from JSON file)
- Grant "Editor" permissions
Alternative Authentication Methods
Option 1: JSON String Authentication
Instead of using a file path for credentials, you can provide the service account credentials directly as a JSON string. This is useful for containerized environments, CI/CD pipelines, or when you want to avoid managing credential files.
Note: When using GOOGLE_SERVICE_ACCOUNT_KEY:
- The entire JSON must be on a single line
- All quotes must be escaped with backslashes
- Newlines in the private key must be represented as
\\n - If the JSON includes a
project_id, you can omitGOOGLE_PROJECT_ID
Option 2: Private Key Authentication (Simplified)
For the most user-friendly approach, you can provide just the private key and email directly. This is the simplest method and requires only two fields from your service account JSON:
Note: When using GOOGLE_PRIVATE_KEY:
- Newlines in the private key should be represented as
\\n - The private key must include the
-----BEGIN PRIVATE KEY-----and-----END PRIVATE KEY-----markers - The client email should be the service account email from your JSON file
GOOGLE_PROJECT_IDis optional when using this method
Local Development Setup
If you want to develop or contribute to this project, you can clone and build it locally:
Interactive Setup Script
Run the interactive setup script to configure your local MCP client:
This will:
- Guide you through the configuration
- Automatically detect your Node.js installation (including nvm)
- Find your Claude Desktop config
- Create the proper JSON configuration
- Optionally create a .env file for development
Manual Local Configuration
If you prefer manual configuration with a local build, add to your MCP client config:
📦 Build & Development
Development Commands
Task Runner (Alternative)
If you have Task installed:
Development Setup
- Create
.envfile for testing:
- Run in development mode:
🎚️ Reducing context cost with toolsets
All 44 tools together cost about 9,900 tokens of context in every session,
before the model does anything. Most workflows need a fraction of that.
GSHEETS_TOOLSETS limits which tools the server exposes:
Measured tools/list cost:
Notes:
- The default is unchanged — leave
GSHEETS_TOOLSETSunset and you get every tool, exactly as before. coreis always included.GSHEETS_TOOLSETS=chartsmeans "charts as well as core", not "charts only" — without core the server cannot read a cell.- A typo is a startup error, not a silently smaller tool list.
GSHEETS_READ_ONLY=truedrops every writing tool and can be combined withGSHEETS_TOOLSETS. It is enforced when a tool is called, not just when the list is built, so a client cannot write by naming a hidden tool.
All tools also carry MCP annotations (readOnlyHint, destructiveHint,
idempotentHint), so clients can skip confirmation prompts on reads and warn
before destructive operations.
📋 Available Tools
Reading Data
Writing Data
Sheet Management
Cell Formatting
Native Tables
Charts
Read / Snapshot Tools
🔧 Code Quality
Linting
Formatting
Type Checking
❗ Troubleshooting
Common Issues
"Authentication failed"
- If using file-based auth: Verify JSON key path is absolute and correct
- If using JSON string auth: Ensure JSON is properly escaped and valid
- If using private key auth: Check that the private key includes BEGIN/END markers and newlines are escaped as
\\n - Verify GOOGLE_CLIENT_EMAIL is a valid service account email
- Check GOOGLE_PROJECT_ID matches your project (or is included in JSON for full JSON auth)
- Ensure Sheets API is enabled
"Permission denied"
- Share spreadsheet with service account email
- Service account needs "Editor" role
- Check email in JSON file (client_email field)
"Spreadsheet not found"
- Verify spreadsheet ID from URL
- Format:
https://docs.google.com/spreadsheets/d/[SPREADSHEET_ID]/edit
MCP Connection Issues
- Ensure you're using the built version (
dist/index.js) - Check that Node.js path is correct in Claude Desktop config
- Look for errors in Claude Desktop logs
- Use
npm run inspectorto debug
🔍 Finding IDs
Spreadsheet ID
From the URL:
Sheet ID
Use sheets_get_metadata to list all sheets with their IDs.
📝 Tips
- Always test with a copy of your data
- Use batch operations for better performance
- Set appropriate permissions (read-only vs edit)
- Check rate limits for large operations
- Use
sheets_check_accessto verify permissions before operations
📘 Tool Details
sheets_get_sheet_structure
Returns lightweight structural/dimensional metadata for a sheet without any per-cell data. Much faster and cheaper than sheets_get_full_sheet_snapshot when you only need layout information.
Parameters:
spreadsheetId(required): The ID of the spreadsheetsheetName(required): Name of the sheet (tab)
Returns: sheetName, sheetId, sheetIndex, tabColor, tabColorStyle, dimensions (rowCount, columnCount), frozen (rowCount, columnCount), columnWidths (array of pixel sizes), rowHeights (array of pixel sizes), hiddenColumns (0-based indices), hiddenRows (0-based indices), mergeCount, merges (A1 notation array)
sheets_get_formatting_compact
Read cell formatting for a range and return it as compact A1Range → format pairs. Adjacent cells with identical formatting are collapsed into rectangular ranges (run-length encoded), reducing output by 90 %+ compared to per-cell data.
Parameters:
spreadsheetId(required): The ID of the spreadsheetsheetName(required): Name of the sheet (tab)range(required): Range without sheet prefix, e.g."A1:Z85"useEffectiveFormat(optional):false(default) = userEnteredFormat (only explicit overrides, smaller output);true= effectiveFormat (all inherited defaults)fields(optional): Array of format field names to include, e.g.["backgroundColor", "textFormat", "borders"]
Returns: { range, formatType, rangeCount, data: { "A1:C3": { backgroundColor: {...} }, ... } }
Supported fields: backgroundColor, backgroundColorStyle, textFormat, horizontalAlignment, verticalAlignment, wrapStrategy, textRotation, numberFormat, padding, borders
sheets_get_full_sheet_snapshot
Master one-shot tool that returns all structural and formatting metadata in a single API call.
Parameters:
spreadsheetId(required): The ID of the spreadsheetsheetName(required): Name of the sheet (tab)includeFormattingRange(optional): If provided (e.g."A1:Z100"), per-cell formatting is included in the responseuseEffectiveFormat(optional): Use effectiveFormat instead of userEnteredFormat when including cell formatting (default:false)fields(optional): Array of format field names to return, e.g.["backgroundColor", "textFormat"]— reduces API transfer size and response sizecompactMode(optional): Whentrue, identical adjacent cells are collapsed into rectangular ranges (RLE). Reduces a typical 85×28 sheet from ~60 000 lines to ~500 lines (default:false)
sheets_insert_rows
Insert new rows at a specific position in a spreadsheet with optional data.
Parameters:
spreadsheetId(required): The ID of the spreadsheetrange(required): A1 notation anchor point where rows will be inserted (e.g., "Sheet1!A5")rows(optional): Number of rows to insert (default: 1)position(optional): 'BEFORE' or 'AFTER' the anchor row (default: 'BEFORE')inheritFromBefore(optional): Whether to inherit formatting from the row before (default: false)values(optional): 2D array of values to fill the newly inserted rowsvalueInputOption(optional): 'RAW' or 'USER_ENTERED' (default: 'USER_ENTERED')
Examples:
sheets_delete_columns
Delete one or more columns from a sheet using a full-column A1 range.
Parameters:
spreadsheetId(required): The ID of the spreadsheetrange(required): Full-column A1 range to delete (e.g., "Sheet1!B:D" or "Sheet1!C:C")
Examples:
sheets_delete_rows
Delete one or more rows from a sheet using a full-row A1 range.
Parameters:
spreadsheetId(required): The ID of the spreadsheetrange(required): Full-row A1 range to delete (e.g., "Sheet1!2:4" or "Sheet1!3:3")
Examples:
📋 Changelog
See CHANGELOG.md for a list of changes in each version.
🤝 Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Run tests and linting (
npm run check) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
👤 Author
Tomáš Grásl - tomasgrasl.cz
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
來源:README.md,提交 48435ef
工具
0版本歷史
4- v1.11.1最新Nov 7, 2026
- v1.11.0Oct 25, 2026
- v1.10.3Sep 19, 2026
- v1.10.1Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分