AgentSkillsCN

googlesheets

掌握 Google Sheets MCP 集成的连接技巧。在搜索表格、列出数据表,或读取数据时,可灵活运用此方法。提供关于表格 ID 提取、工具链整合,以及避免常见“幻觉”模式的指导。

SKILL.md
--- frontmatter
name: googlesheets
description: Connection skill for Google Sheets MCP integration. Provides guidance on spreadsheet ID extraction, tool chaining, and avoiding common hallucination patterns. Use when searching sheets, listing tables, or reading data.
metadata:
  version: 1.0.0
  category: data
  tags:
    - google-sheets
    - spreadsheets
    - data
    - mcp
  author:
    name: NimbleBrain
    url: https://www.nimblebrain.ai

Google Sheets Integration

This skill provides behavioral guidance for interacting with Google Sheets via MCP tools.

ID Handling (CRITICAL)

Google Sheets uses 44-character alphanumeric IDs. These IDs are returned by search tools and must be extracted exactly.

ID Format Example:

  • Spreadsheet: 11t2duqAVMcA2rfVaGf94QWx_OBcz1vaN6i1fUXqC-q4

The Cardinal Rule

NEVER use memorized or training-data IDs. ALWAYS extract from the actual tool response.

The most common failure mode:

code
GOOGLESHEETS_SEARCH_SPREADSHEETS returns:
  {"id": "11t2duqAVMcA2rfVaGf94QWx_OBcz1vaN6i1fUXqC-q4", "name": "hubspot-crm-exports"}

You use: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms  <- WRONG (Google's example spreadsheet)

The ID 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms is Google's famous "Example Spreadsheet" from tutorials. It exists in training data but is NOT the user's spreadsheet.

Required Workflow: Search Then Use

code
Step 1: GOOGLESHEETS_SEARCH_SPREADSHEETS(query="hubspot")
Response: {
  "spreadsheets": [
    {"id": "11t2duqAVMcA2rfVaGf94QWx_OBcz1vaN6i1fUXqC-q4", "name": "hubspot-crm-exports-2025-12-01"},
    {"id": "1H578KWaJSHyf4DpZr3YulBKTlNTXNffffkTSmNSqjG0", "name": "hubspot-crm-exports-2025-06-01"}
  ]
}

Step 2: Parse JSON, locate the "id" field for the desired sheet

Step 3: GOOGLESHEETS_LIST_TABLES(spreadsheet_id="11t2duqAVMcA2rfVaGf94QWx_OBcz1vaN6i1fUXqC-q4")

The ID in step 3 MUST match the ID from step 1 exactly.

Tool Chaining Patterns

Pattern: Find Sheet by Name, Then Access

code
User: "What's in the hubspot export sheet?"

1. GOOGLESHEETS_SEARCH_SPREADSHEETS(query="hubspot export")
2. Extract spreadsheet_id from response
3. GOOGLESHEETS_LIST_TABLES(spreadsheet_id=<extracted_id>)
4. GOOGLESHEETS_GET_TABLE_DATA(spreadsheet_id=<extracted_id>, range=<table_range>)

Pattern: User Provides URL

If user provides a Google Sheets URL, extract the ID from between /d/ and /edit:

code
URL: https://docs.google.com/spreadsheets/d/11t2duqAVMcA2rfVaGf94QWx_OBcz1vaN6i1fUXqC-q4/edit
ID:  11t2duqAVMcA2rfVaGf94QWx_OBcz1vaN6i1fUXqC-q4

Pattern: Disambiguation

When search returns multiple matches, confirm with user:

code
GOOGLESHEETS_SEARCH_SPREADSHEETS("report") returns 3 sheets:
- "Q4 Sales Report" (modified Dec 15)
- "Annual Report 2025" (modified Jan 10)
- "Bug Report Tracker" (modified Jan 18)

Ask: "I found 3 sheets matching 'report'. Which one?"

Never assume. Different sheets may have similar names.

Tool Reference

Search & Discovery

ToolPurposeKey Parameter
GOOGLESHEETS_SEARCH_SPREADSHEETSFind sheets by namequery
GOOGLESHEETS_LIST_TABLESGet sheets/ranges in a spreadsheetspreadsheet_id

Data Operations

ToolPurposeKey Parameters
GOOGLESHEETS_GET_TABLE_DATARead cell dataspreadsheet_id, range
GOOGLESHEETS_BATCH_UPDATEWrite/update cellsspreadsheet_id, data
GOOGLESHEETS_CREATE_SPREADSHEETCreate new sheettitle

Range Format

Ranges use A1 notation:

  • Single cell: Sheet1!A1
  • Range: Sheet1!A1:D10
  • Full column: Sheet1!A:A
  • Full row: Sheet1!1:1

Sheet names with spaces require quotes: 'My Sheet'!A1:B10

Error Recovery

ErrorCauseFix
"Spreadsheet not found"Wrong ID usedSearch again, extract exact ID from response
"Invalid spreadsheet_id"Hallucinated/memorized IDNever guess IDs, always extract from search
"Range not found"Sheet name mismatchUse LIST_TABLES first to see actual sheet names
"Permission denied"User doesn't have accessVerify the sheet is shared with user's account

Anti-Patterns

WrongRight
Use a memorized spreadsheet IDExtract ID from search response
Guess the ID formatParse the actual JSON response
Assume sheet namesCall LIST_TABLES to discover sheets
Skip search when user says sheet nameAlways search first, names can be partial matches
Use "Example Spreadsheet" IDThat's Google's demo, not user data

ID Extraction Checklist

Before calling any tool that requires spreadsheet_id:

  1. Did I just call SEARCH_SPREADSHEETS?
  2. Did I parse the JSON response?
  3. Did I extract the exact id field value?
  4. Am I using that exact string (not a similar-looking one)?
  5. Is this ID from THIS conversation (not memorized)?

If any answer is "no", search first.