### MCP Google Sheets Server Setup Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Instructions on how to install and run the MCP Google Sheets server using uvx, including environment variable configuration for authentication and tool filtering. ```APIDOC ## MCP Google Sheets Server Setup This section details how to install and configure the MCP Google Sheets server. ### Installation with uvx 1. **Install uv:** ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` 2. **Set Environment Variables (Service Account Authentication):** ```bash export SERVICE_ACCOUNT_PATH="/path/to/your/service-account-key.json" export DRIVE_FOLDER_ID="YOUR_DRIVE_FOLDER_ID" ``` 3. **Run the Server:** ```bash uvx mcp-google-sheets@latest ``` ### Claude Desktop Configuration Configure your `settings.json` for Claude Desktop: ```json { "mcpServers": { "google-sheets": { "command": "uvx", "args": ["mcp-google-sheets@latest"], "env": { "SERVICE_ACCOUNT_PATH": "/full/path/to/your/service-account-key.json", "DRIVE_FOLDER_ID": "your_shared_folder_id_here" } } } } ``` ### Tool Filtering Configuration To reduce context window usage, enable specific tools using `--include-tools` or `ENABLED_TOOLS`: ```json { "mcpServers": { "google-sheets": { "command": "uvx", "args": [ "mcp-google-sheets@latest", "--include-tools", "get_sheet_data,update_cells,list_spreadsheets,list_sheets" ], "env": { "SERVICE_ACCOUNT_PATH": "/path/to/credentials.json" } } } } ``` ``` -------------------------------- ### Install uv package manager Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Commands to install the uv package manager on different operating systems to facilitate running the MCP server. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` ```powershell powershell -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Install and Run MCP Google Sheets with uvx Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Instructions for installing the uv package manager and running the MCP Google Sheets server using uvx. It includes setting up necessary environment variables for Service Account authentication and specifying a Google Drive folder ID. ```bash # Install uv if not already installed curl -LsSf https://astral.sh/uv/install.sh | sh # Set environment variables for Service Account authentication export SERVICE_ACCOUNT_PATH="/path/to/your/service-account-key.json" export DRIVE_FOLDER_ID="YOUR_DRIVE_FOLDER_ID" # Run the server uvx mcp-google-sheets@latest ``` -------------------------------- ### MCP Google Sheets Tool Filtering Configuration Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Example JSON configuration for Claude Desktop to enable specific MCP Google Sheets tools, reducing context window usage. This demonstrates how to use the `--include-tools` argument with a comma-separated list of desired tools. ```json { "mcpServers": { "google-sheets": { "command": "uvx", "args": [ "mcp-google-sheets@latest", "--include-tools", "get_sheet_data,update_cells,list_spreadsheets,list_sheets" ], "env": { "SERVICE_ACCOUNT_PATH": "/path/to/credentials.json" } } } } ``` -------------------------------- ### Add Rows Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Inserts a specified number of empty rows into a Google Sheet at a given starting row index. ```APIDOC ## POST add_rows ### Description Adds (inserts) a specified number of empty rows into a sheet/tab at a given row index. If `start_row` is omitted, rows are inserted at the beginning of the sheet. ### Method POST ### Endpoint /xing5/mcp-google-sheets/add_rows ### Parameters #### Request Body - **spreadsheet_id** (string) - Required - The spreadsheet ID (from its URL). - **sheet** (string) - Required - Name of the sheet/tab (e.g., "Sheet1"). - **count** (integer) - Required - Number of empty rows to insert. - **start_row** (integer) - Optional - 0-based row index to start inserting rows. If omitted, defaults to `0` (inserts at the beginning). ### Request Example { "spreadsheet_id": "your_spreadsheet_id", "sheet": "Sheet1", "count": 5, "start_row": 10 } ### Response #### Success Response (200) - An object containing the result of the batch update operation. ### Response Example { "spreadsheetId": "your_spreadsheet_id", "replies": [ { "addRows": { "rowsAddedCount": 5 } } ] } ``` -------------------------------- ### GET /get_sheet_formulas Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Retrieves formulas from a specified sheet or range within a spreadsheet. ```APIDOC ## GET /get_sheet_formulas ### Description Retrieves the formulas present in a specific sheet or a defined range. ### Method GET ### Endpoint /get_sheet_formulas ### Parameters #### Query Parameters - **spreadsheet_id** (string) - Required - The ID of the spreadsheet. - **sheet** (string) - Required - The name of the sheet. - **range** (string) - Optional - The specific cell range to fetch. ### Request Example { "spreadsheet_id": "1aBcDeFgHiJkLmNoPqRsTuVwXyZ", "sheet": "Calculations" } ### Response #### Success Response (200) - **formulas** (array) - A 2D array containing the formulas found in the specified range. #### Response Example [ ["=A1+B1", "=SUM(A1:A10)"], ["=AVERAGE(B:B)", "=IF(A2>100,\"High\",\"Low\")"] ] ``` -------------------------------- ### Get Sheet Formulas Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Reads formulas from a specified range within a sheet or tab of a Google Spreadsheet. ```APIDOC ## POST get_sheet_formulas ### Description Reads formulas from a specified range in a sheet/tab of a Google Spreadsheet. If no range is specified, it reads all formulas in the given sheet. ### Method POST ### Endpoint /xing5/mcp-google-sheets/get_sheet_formulas ### Parameters #### Request Body - **spreadsheet_id** (string) - Required - The spreadsheet ID (from its URL). - **sheet** (string) - Required - Name of the sheet/tab (e.g., "Sheet1"). - **range** (string) - Optional - A1 notation (e.g., 'A1:C10', 'Sheet1!B2:D'). If omitted, reads all formulas in the sheet/tab specified by `sheet`. ### Request Example { "spreadsheet_id": "your_spreadsheet_id", "sheet": "Sheet1", "range": "A1:C5" } ### Response #### Success Response (200) - A 2D array of cell formulas (array of arrays). ### Response Example { "values": [ ["=SUM(A1:A5)", "=AVERAGE(B1:B5)", ""], ["", "=TODAY()", "=IF(C1>0, TRUE, FALSE)"] ] } ``` -------------------------------- ### Get Multiple Sheet Data Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Fetches data from multiple specified ranges across potentially different spreadsheets in a single API call. This is useful for consolidating data from various sources efficiently. ```APIDOC ## POST get_multiple_sheet_data ### Description Fetches data from multiple ranges across potentially different spreadsheets in one call. This allows for efficient retrieval of data from various sources. ### Method POST ### Endpoint /xing5/mcp-google-sheets/get_multiple_sheet_data ### Parameters #### Request Body - **requests** (array) - Required - An array of request objects, where each object specifies a spreadsheet, sheet, and range to retrieve data from. Example: `[{"spreadsheet_id": "sheet1_id", "sheet": "Sheet1", "range": "A1:B5"}, {"spreadsheet_id": "sheet2_id", "sheet": "Data", "range": "C1:D10"}]`. ### Request Example { "requests": [ { "spreadsheet_id": "spreadsheet_id_1", "sheet": "Sheet1", "range": "A1:C5" }, { "spreadsheet_id": "spreadsheet_id_2", "sheet": "Summary", "range": "B2:E10" } ] } ### Response #### Success Response (200) - An object containing the results for each requested range, typically structured by spreadsheet and range. ### Response Example { "results": { "spreadsheet_id_1": { "Sheet1": { "A1:C5": { "values": [ ["Data A1", "Data B1", "Data C1"], ["Data A2", "Data B2", "Data C2"] ] } } }, "spreadsheet_id_2": { "Summary": { "B2:E10": { "values": [ ["Summary B2", "Summary C2", "Summary D2", "Summary E2"], ["Summary B3", "Summary C3", "Summary D3", "Summary E3"] ] } } } } } ``` -------------------------------- ### Get Sheet Formulas API Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Reads formulas (not computed values) from a specific sheet. Useful for understanding spreadsheet logic or auditing calculations. ```APIDOC ## get_sheet_formulas Reads formulas (not computed values) from a specific sheet. Useful for understanding spreadsheet logic or auditing calculations. ### Method GET ### Endpoint /get_sheet_formulas ### Parameters #### Query Parameters - **spreadsheet_id** (string) - Required - The ID of the Google Spreadsheet. - **sheet** (string) - Required - The name of the sheet (tab) to read formulas from. - **range** (string) - Optional - The A1 notation of the range to retrieve formulas from (e.g., "A1:C10"). If not specified, all formulas in the sheet are returned. ### Response #### Success Response (200) - **spreadsheetId** (string) - The ID of the spreadsheet. - **valueRanges** (array) - A list containing information about the retrieved value range(s). - **range** (string) - The A1 notation of the range that was retrieved. - **values** (array) - A 2D array of formulas from the sheet. Each inner array represents a row. - **majorDimension** (string) - The major dimension of the returned values. ### Response Example ```json { "spreadsheetId": "1aBcDeFgHiJkLmNoPqRsTuVwXyZ", "valueRanges": [ { "range": "A1:B5", "values": [ ["=SUM(C1:C10)", "=AVERAGE(D1:D10)"], ["", "=IF(E1>100, \"High\", \"Low\")"] ], "majorDimension": "ROWS" } ] } ``` ``` -------------------------------- ### Get Sheet Data Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Reads data from a specified range within a sheet or tab of a Google Spreadsheet. Supports fetching values only or full grid data with formatting. ```APIDOC ## POST get_sheet_data ### Description Reads data from a specified range in a sheet/tab of a Google Spreadsheet. You can choose to retrieve only the values or the full grid data including formatting. ### Method POST ### Endpoint /xing5/mcp-google-sheets/get_sheet_data ### Parameters #### Request Body - **spreadsheet_id** (string) - Required - The spreadsheet ID (from its URL). - **sheet** (string) - Required - Name of the sheet/tab (e.g., "Sheet1"). - **range** (string) - Optional - A1 notation (e.g., 'A1:C10', 'Sheet1!B2:D'). If omitted, reads the whole sheet/tab specified by `sheet`. - **include_grid_data** (boolean) - Optional - If `True`, returns full grid data including formatting and metadata (much larger). If `False` (default), returns values only (more efficient). ### Request Example { "spreadsheet_id": "your_spreadsheet_id", "sheet": "Sheet1", "range": "A1:B5", "include_grid_data": false } ### Response #### Success Response (200) - The response structure depends on the `include_grid_data` parameter. If `false`, it's a values result object (similar to `values.get` response). If `true`, it's a full grid data object (similar to `get` response). ### Response Example (include_grid_data=false) { "values": [ ["Value 1", "Value 2"], ["Value 3", "Value 4"] ] } ### Response Example (include_grid_data=true) { "spreadsheetId": "your_spreadsheet_id", "valueRanges": [ { "range": "Sheet1!A1:B2", "majorDimension": "ROWS", "values": [ ["Value 1", "Value 2"], ["Value 3", "Value 4"] ], "grids": [ { "startRowIndex": 0, "endRowIndex": 2, "startColumnIndex": 0, "endColumnIndex": 2, "rows": [ { "values": [ { "userEnteredValue": {"stringValue": "Value 1"}, "formattedValue": "Value 1" }, { "userEnteredValue": {"stringValue": "Value 2"}, "formattedValue": "Value 2" } ] }, { "values": [ { "userEnteredValue": {"stringValue": "Value 3"}, "formattedValue": "Value 3" }, { "userEnteredValue": {"stringValue": "Value 4"}, "formattedValue": "Value 4" } ] } ] } ] } ] } ``` -------------------------------- ### Get Sheet Formulas (Python) Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Python function to retrieve the formulas from a specific sheet in a Google Spreadsheet, rather than the computed values. This is useful for auditing spreadsheet logic and calculations. ```python # Example usage for get_sheet_formulas would go here ``` -------------------------------- ### Get Sheet Data API Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Reads data from a specific sheet in a Google Spreadsheet. Supports optional cell range filtering and can include grid data with formatting metadata. ```APIDOC ## get_sheet_data Reads data from a specific sheet in a Google Spreadsheet. Supports optional cell range filtering and can include grid data with formatting metadata. ### Method GET ### Endpoint /get_sheet_data ### Parameters #### Query Parameters - **spreadsheet_id** (string) - Required - The ID of the Google Spreadsheet. - **sheet** (string) - Required - The name of the sheet (tab) to read data from. - **range** (string) - Optional - The A1 notation of the range to retrieve values from (e.g., "A1:C10"). If not specified, the entire sheet is returned. - **include_grid_data** (boolean) - Optional - If true, returns grid data with formatting metadata. Defaults to false. ### Response #### Success Response (200) - **spreadsheetId** (string) - The ID of the spreadsheet. - **valueRanges** (array) - A list containing information about the retrieved value range(s). - **range** (string) - The A1 notation of the range that was retrieved. - **values** (array) - A 2D array of values from the sheet. Each inner array represents a row. - **majorDimension** (string) - The major dimension of the returned values. - **gridData** (object) - Optional. Contains formatting metadata if `include_grid_data` is true. ### Response Example (Basic) ```json { "spreadsheetId": "1aBcDeFgHiJkLmNoPqRsTuVwXyZ", "valueRanges": [ { "range": "Sheet1", "values": [ ["Name", "Sales", "Region"], ["Alice", "1500", "North"] ], "majorDimension": "ROWS" } ] } ``` ### Response Example (With Grid Data) ```json { "spreadsheetId": "1aBcDeFgHiJkLmNoPqRsTuVwXyZ", "valueRanges": [ { "range": "A1:B5", "values": [ ["Header 1", "Header 2"], ["Data 1A", "Data 1B"] ], "majorDimension": "ROWS", "gridData": { "rows": [ { "values": [ { "userEnteredFormat": { "backgroundColor": {"red": 1, "green": 0, "blue": 0} } }, {} ] }, { "values": [ {}, {} ] } ] } } ] } ``` ``` -------------------------------- ### Get Sheet Data (Python) Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Python function to read data from a specific sheet in a Google Spreadsheet. It supports specifying a cell range and optionally including grid data with formatting. The output includes the spreadsheet ID and value ranges. ```python # Get all data from a sheet result = get_sheet_data( spreadsheet_id="1aBcDeFgHiJkLmNoPqRsTuVwXyZ", sheet="Sheet1" ) # Returns: { # 'spreadsheetId': '1aBcDeFgHiJkLmNoPqRsTuVwXyZ', # 'valueRanges': [{ # 'range': 'Sheet1', # 'values': [['Name', 'Sales', 'Region'], ['Alice', '1500', 'North'], ...] # }] # } # Get specific range result = get_sheet_data( spreadsheet_id="1aBcDeFgHiJkLmNoPqRsTuVwXyZ", sheet="Sales Data", range="A1:C10" ) # Include cell formatting metadata (larger response) result = get_sheet_data( spreadsheet_id="1aBcDeFgHiJkLmNoPqRsTuVwXyZ", sheet="Sheet1", range="A1:B5", include_grid_data=True ) ``` -------------------------------- ### Configure Local Development Environment Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Configures the MCP server to run directly from a local repository clone using the uv tool. ```json { "mcpServers": { "mcp-google-sheets-local": { "command": "uv", "args": [ "run", "--directory", "/path/to/your/mcp-google-sheets", "mcp-google-sheets" ], "env": { "SERVICE_ACCOUNT_PATH": "/path/to/your/mcp-google-sheets/service_account.json", "DRIVE_FOLDER_ID": "your_drive_folder_id_here" } } } } ``` -------------------------------- ### Configure authentication environment variables Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Sets the required environment variables for service account authentication and Google Drive folder targeting. ```bash export SERVICE_ACCOUNT_PATH="/path/to/your/service-account-key.json" export DRIVE_FOLDER_ID="YOUR_DRIVE_FOLDER_ID" ``` ```cmd set SERVICE_ACCOUNT_PATH="C:\path\to\your\service-account-key.json" set DRIVE_FOLDER_ID="YOUR_DRIVE_FOLDER_ID" ``` ```powershell $env:SERVICE_ACCOUNT_PATH = "C:\path\to\your\service-account-key.json" $env:DRIVE_FOLDER_ID = "YOUR_DRIVE_FOLDER_ID" ``` -------------------------------- ### Set Base64 Credentials via Environment Variable Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Demonstrates how to export the generated Base64 string as an environment variable for the application to consume. ```bash export CREDENTIALS_CONFIG="ewogICJ0eXBlIjogInNlcnZpY2VfYWNjb..." ``` -------------------------------- ### Run mcp-google-sheets server Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Executes the MCP server using uvx to ensure the latest version is downloaded and run. ```bash uvx mcp-google-sheets@latest ``` -------------------------------- ### Tool Filtering Configuration Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Explains how to restrict the number of exposed tools to optimize context window usage via command-line arguments or environment variables. ```APIDOC ## Configuration: Tool Filtering ### Description Reduces the number of tools exposed to the MCP client to save tokens and improve performance. By default, all 19 tools are enabled. ### Method N/A (Configuration via MCP Server settings) ### Parameters #### Environment Variables - **ENABLED_TOOLS** (string) - Optional - Comma-separated list of tool names to enable. #### Command-line Arguments - **--include-tools** (string) - Optional - Comma-separated list of tool names to enable. ### Configuration Example { "mcpServers": { "google-sheets": { "command": "uvx", "args": ["mcp-google-sheets@latest", "--include-tools", "get_sheet_data,update_cells"], "env": { "SERVICE_ACCOUNT_PATH": "/path/to/credentials.json" } } } } ``` -------------------------------- ### POST /add_chart Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Creates a visualization chart in a specified Google Spreadsheet. ```APIDOC ## POST /add_chart ### Description Generates a chart within a Google Spreadsheet based on provided data range and chart type. ### Method POST ### Endpoint /add_chart ### Parameters #### Request Body - **spreadsheet_id** (string) - Required - The spreadsheet ID. - **sheet** (string) - Required - Name of the sheet. - **chart_type** (string) - Required - Type of chart (e.g., COLUMN, BAR, LINE, PIE). - **data_range** (string) - Required - A1 notation range. ### Request Example { "spreadsheet_id": "abc", "sheet": "Sheet1", "chart_type": "COLUMN", "data_range": "A1:C10" } ### Response #### Success Response (200) - **status** (string) - Operation status. - **chart_id** (string) - The ID of the created chart. ``` -------------------------------- ### Configure Application Default Credentials (ADC) Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Configures the MCP server to use Google Application Default Credentials, either via an environment variable or local gcloud authentication. ```json { "mcpServers": { "google-sheets": { "command": "uvx", "args": ["mcp-google-sheets@latest"], "env": { "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json" } } } } ``` ```json { "mcpServers": { "google-sheets": { "command": "uvx", "args": ["mcp-google-sheets@latest"], "env": {} } } } ``` -------------------------------- ### Create Spreadsheet API Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Creates a new Google Spreadsheet in the specified folder or the configured default folder. Returns the new spreadsheet's ID, title, and parent folder. ```APIDOC ## create_spreadsheet Creates a new Google Spreadsheet in the specified folder or the configured default folder. Returns the new spreadsheet's ID, title, and parent folder. ### Method POST ### Endpoint /create_spreadsheet ### Parameters #### Request Body - **title** (string) - Required - The title for the new spreadsheet. - **folder_id** (string) - Optional - The ID of the Google Drive folder where the spreadsheet should be created. If not provided, the default configured folder is used. ### Request Example ```json { "title": "Quarterly Sales Report Q3 2024", "folder_id": "1xyzSpecificFolderID" } ``` ### Response #### Success Response (200) - **spreadsheetId** (string) - The unique identifier for the newly created spreadsheet. - **title** (string) - The title of the newly created spreadsheet. - **folder** (string) - The ID of the folder where the spreadsheet was created. ### Response Example ```json { "spreadsheetId": "1aBcDeFgHiJkLmNoPqRsTuVwXyZ", "title": "Quarterly Sales Report Q3 2024", "folder": "1xyzSpecificFolderID" } ``` ``` -------------------------------- ### Create Spreadsheet Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Creates a new Google Sheet with a specified title and optionally places it in a designated Google Drive folder. ```APIDOC ## POST create_spreadsheet ### Description Creates a new spreadsheet with a specified title. Optionally, you can specify a Google Drive folder ID to place the new spreadsheet in. ### Method POST ### Endpoint /xing5/mcp-google-sheets/create_spreadsheet ### Parameters #### Request Body - **title** (string) - Required - The desired title for the spreadsheet. Example: "Quarterly Report Q4". - **folder_id** (string) - Optional - Google Drive folder ID where the spreadsheet should be created. Get from its URL. If omitted, uses configured default or root. ### Request Example { "title": "My New Report", "folder_id": "your_folder_id" } ### Response #### Success Response (200) - **spreadsheetId** (string) - The ID of the newly created spreadsheet. - **title** (string) - The title of the spreadsheet. - **folder** (object) - Information about the folder where the spreadsheet was created. ### Response Example { "spreadsheetId": "new_spreadsheet_id", "title": "My New Report", "folder": { "id": "your_folder_id", "name": "Reports" } } ``` -------------------------------- ### POST /get_multiple_spreadsheet_summary Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Retrieves titles, sheet names, headers, and preview rows for multiple spreadsheets. ```APIDOC ## POST /get_multiple_spreadsheet_summary ### Description Fetches a summary of multiple Google Spreadsheets, including metadata and a preview of the data. ### Method POST ### Endpoint /get_multiple_spreadsheet_summary ### Parameters #### Request Body - **spreadsheet_ids** (array of strings) - Required - List of spreadsheet IDs. - **rows_to_fetch** (integer) - Optional - Number of rows to preview (default: 5). ### Request Example { "spreadsheet_ids": ["id1", "id2"], "rows_to_fetch": 5 } ### Response #### Success Response (200) - **summaries** (array) - List of summary objects for each spreadsheet. ``` -------------------------------- ### Claude Desktop Configuration for MCP Google Sheets Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Configuration snippet for Claude Desktop to connect to the MCP Google Sheets server. This JSON defines the command to run the server and necessary environment variables for authentication and drive folder access. ```json { "mcpServers": { "google-sheets": { "command": "uvx", "args": ["mcp-google-sheets@latest"], "env": { "SERVICE_ACCOUNT_PATH": "/full/path/to/your/service-account-key.json", "DRIVE_FOLDER_ID": "your_shared_folder_id_here" } } } } ``` -------------------------------- ### Configure OAuth 2.0 Authentication Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Configures the MCP server using OAuth 2.0 credentials. Ensures the token path is writable as the server will generate a token file upon first login. ```json { "mcpServers": { "google-sheets": { "command": "uvx", "args": ["mcp-google-sheets@latest"], "env": { "CREDENTIALS_PATH": "/full/path/to/your/credentials.json", "TOKEN_PATH": "/full/path/to/your/token.json" } } } } ``` -------------------------------- ### Enable Tool Filtering via Environment Variable Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Illustrates how to filter Google Sheets tools using the `ENABLED_TOOLS` environment variable. This method achieves the same goal as the command-line argument, allowing for selective tool loading to conserve context window space. ```json { "mcpServers": { "google-sheets": { "command": "uvx", "args": ["mcp-google-sheets@latest"], "env": { "SERVICE_ACCOUNT_PATH": "/path/to/credentials.json", "ENABLED_TOOLS": "get_sheet_data,update_cells,list_spreadsheets,list_sheets" } } } } ``` -------------------------------- ### Fetch Multiple Data Sources Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Retrieves data from multiple ranges or provides a summary of multiple spreadsheets, including headers and initial rows. ```python result = get_multiple_sheet_data( queries=[ {"spreadsheet_id": "1abc...", "sheet": "Sheet1", "range": "A1:B5"}, {"spreadsheet_id": "2xyz...", "sheet": "Data", "range": "A1:Z100"} ] ) result = get_multiple_spreadsheet_summary( spreadsheet_ids=["1abc...", "2xyz..."], rows_to_fetch=5 ) ``` -------------------------------- ### Configure Base64 Encoded Credentials Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Configures the MCP server using a Base64-encoded string for credentials, useful for environment-based deployments. ```json { "mcpServers": { "google-sheets": { "command": "uvx", "args": ["mcp-google-sheets@latest"], "env": { "CREDENTIALS_CONFIG": "ewogICJ0eXBlIjogInNlcnZpY2VfYWNjb3VudCIsCiAgInByb2plY3RfaWQiOiAi...", "DRIVE_FOLDER_ID": "your_shared_folder_id_here" } } } } ``` -------------------------------- ### Generate Base64 Credential String for Environment Variables Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Converts a local JSON credentials file into a Base64 encoded string. This is useful for injecting credentials directly into environment variables in containerized environments like Docker or Kubernetes. ```bash base64 -w 0 your_credentials.json ``` ```powershell $filePath = "C:\path\to\your_credentials.json"; $bytes = [System.IO.File]::ReadAllBytes($filePath); $base64 = [System.Convert]::ToBase64String($bytes); $base64 ``` -------------------------------- ### List Google Drive Folders Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Retrieves a list of folders from the root of My Drive or a specific parent folder. This is useful for organizing and navigating spreadsheet locations. ```python result = list_folders() result = list_folders(parent_folder_id="1abc...") ``` -------------------------------- ### MCP Resource: Spreadsheet Info Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Access basic spreadsheet metadata as an MCP resource using the URI pattern `spreadsheet://{spreadsheet_id}/info`. ```APIDOC ## GET spreadsheet://{spreadsheet_id}/info ### Description Retrieves basic metadata for a given Google Sheet. ### Method GET ### Endpoint `spreadsheet://{spreadsheet_id}/info` ### Parameters #### Path Parameters - **spreadsheet_id** (string) - Required - The ID of the Google Sheet. ### Response #### Success Response (200) - **title** (string) - The title of the spreadsheet. - **sheets** (array) - An array of sheet objects, each containing: - **title** (string) - The title of the sheet. - **sheetId** (integer) - The unique ID of the sheet. - **gridProperties** (object) - Properties of the sheet's grid: - **rowCount** (integer) - The number of rows in the sheet. - **columnCount** (integer) - The number of columns in the sheet. #### Response Example ```json { "title": "Quarterly Report", "sheets": [ { "title": "Sheet1", "sheetId": 0, "gridProperties": { "rowCount": 1000, "columnCount": 26 } }, { "title": "Summary", "sheetId": 123456789, "gridProperties": { "rowCount": 100, "columnCount": 10 } } ] } ``` ``` -------------------------------- ### List Spreadsheets Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Lists spreadsheets available in a specified Google Drive folder or accessible by the user. If no folder is specified, it uses the configured default or searches 'My Drive'. ```APIDOC ## POST list_spreadsheets ### Description Lists spreadsheets in the configured Drive folder (Service Account) or accessible by the user (OAuth). ### Method POST ### Endpoint /xing5/mcp-google-sheets/list_spreadsheets ### Parameters #### Query Parameters - **folder_id** (string) - Optional - Google Drive folder ID to search in. Get from its URL. If omitted, uses the configured default folder or searches 'My Drive'. ### Response #### Success Response (200) - **id** (string) - The ID of the spreadsheet. - **title** (string) - The title of the spreadsheet. ### Response Example { "spreadsheets": [ { "id": "spreadsheet_id_1", "title": "Spreadsheet One" }, { "id": "spreadsheet_id_2", "title": "Spreadsheet Two" } ] } ``` -------------------------------- ### Create Google Sheets Charts Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Demonstrates how to programmatically generate charts within a Google Sheet. It uses the add_chart function, requiring a spreadsheet ID, sheet name, chart type, data range, and optional axis labels. ```python # Create a pie chart for market share result = add_chart( spreadsheet_id="1aBcDeFgHiJkLmNoPqRsTuVwXyZ", sheet="Market", chart_type="PIE", data_range="A1:B5", title="Market Share by Product" ) # Create a line chart for trend analysis result = add_chart( spreadsheet_id="1aBcDeFgHiJkLmNoPqRsTuVwXyZ", sheet="Trends", chart_type="LINE", data_range="A1:D52", title="Weekly Performance Trends", x_axis_label="Week", y_axis_label="Performance Score" ) ``` -------------------------------- ### Search Spreadsheets by Query Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Searches for spreadsheets across Google Drive using a keyword query. Returns metadata including owner information and direct web links. ```python result = search_spreadsheets(query="budget 2024", max_results=20) ``` -------------------------------- ### Create Google Spreadsheet (Python) Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Python function to create a new Google Spreadsheet. It can create the spreadsheet in the default configured folder or a specific folder ID. The function returns the new spreadsheet's ID, title, and parent folder. ```python # Create spreadsheet in default folder result = create_spreadsheet(title="Quarterly Sales Report Q3 2024") # Returns: { # 'spreadsheetId': '1aBcDeFgHiJkLmNoPqRsTuVwXyZ', # 'title': 'Quarterly Sales Report Q3 2024', # 'folder': 'your_folder_id' # } # Create spreadsheet in a specific folder result = create_spreadsheet( title="Project Budget", folder_id="1xyzSpecificFolderID" ) ``` -------------------------------- ### Create Sheet Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Adds a new sheet (tab) with a specified title to an existing Google Spreadsheet. ```APIDOC ## POST create_sheet ### Description Adds a new sheet/tab to a specified Google Spreadsheet with a given title. ### Method POST ### Endpoint /xing5/mcp-google-sheets/create_sheet ### Parameters #### Request Body - **spreadsheet_id** (string) - Required - The spreadsheet ID (from its URL). - **title** (string) - Required - The name for the new sheet/tab. ### Request Example { "spreadsheet_id": "your_spreadsheet_id", "title": "New Tab Name" } ### Response #### Success Response (200) - An object containing the properties of the newly created sheet. ### Response Example { "properties": { "sheetId": 123456789, "title": "New Tab Name", "index": 2, "gridProperties": { "rowCount": 1000, "columnCount": 26 } } } ``` -------------------------------- ### Create Sheet API Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Creates a new sheet/tab within an existing Google Spreadsheet. Returns the new sheet's ID, title, and index. ```APIDOC ## create_sheet Creates a new sheet/tab within an existing Google Spreadsheet. Returns the new sheet's ID, title, and index. ### Method POST ### Endpoint /create_sheet ### Parameters #### Request Body - **spreadsheet_id** (string) - Required - The ID of the Google Spreadsheet to add the sheet to. - **title** (string) - Required - The title for the new sheet. ### Request Example ```json { "spreadsheet_id": "1aBcDeFgHiJkLmNoPqRsTuVwXyZ", "title": "Q4 Analysis" } ``` ### Response #### Success Response (200) - **sheetId** (integer) - The unique identifier for the newly created sheet. - **title** (string) - The title of the newly created sheet. - **index** (integer) - The index (position) of the new sheet within the spreadsheet. - **spreadsheetId** (string) - The ID of the spreadsheet the sheet was added to. ### Response Example ```json { "sheetId": 123456789, "title": "Q4 Analysis", "index": 3, "spreadsheetId": "1aBcDeFgHiJkLmNoPqRsTuVwXyZ" } ``` ``` -------------------------------- ### List Spreadsheets API Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Lists all spreadsheets in a specified Google Drive folder or the configured default folder. Returns spreadsheet IDs and titles, sorted by modification time. ```APIDOC ## list_spreadsheets Lists all spreadsheets in the specified Google Drive folder or the configured default folder. Returns spreadsheet IDs and titles sorted by modification time. ### Method GET ### Endpoint /list_spreadsheets ### Parameters #### Query Parameters - **folder_id** (string) - Optional - The ID of the Google Drive folder to list spreadsheets from. If not provided, the default configured folder is used. ### Response #### Success Response (200) - **spreadsheets** (array) - A list of spreadsheet objects. - **id** (string) - The unique identifier for the spreadsheet. - **title** (string) - The title of the spreadsheet. ### Response Example ```json { "spreadsheets": [ {"id": "1aBcDeFgHiJkLmNoPqRsTuVwXyZ", "title": "Sales Report Q4"}, {"id": "1xyzABC123folderID", "title": "Budget 2024"} ] } ``` ``` -------------------------------- ### POST /share_spreadsheet Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Shares a spreadsheet with specific users and assigns them roles. ```APIDOC ## POST /share_spreadsheet ### Description Shares a Google Spreadsheet with a list of recipients and assigns specific access roles. ### Method POST ### Endpoint /share_spreadsheet ### Parameters #### Request Body - **spreadsheet_id** (string) - Required - The spreadsheet ID. - **recipients** (array of objects) - Required - List of objects with email_address and role (reader, commenter, writer). - **send_notification** (boolean) - Optional - Whether to send email notifications (default: True). ### Request Example { "spreadsheet_id": "abc", "recipients": [{"email_address": "user@example.com", "role": "writer"}] } ### Response #### Success Response (200) - **successes** (array) - List of successful operations. - **failures** (array) - List of failed operations. ``` -------------------------------- ### Common Google Sheets Tools Source: https://github.com/xing5/mcp-google-sheets/blob/main/README.md Overview of the most frequently used tools for reading and writing spreadsheet data. ```APIDOC ## Tool Reference: Common Operations ### Description Core tools for interacting with spreadsheet data, including reading cell values and updating content. ### Available Tools - **get_sheet_data**: Retrieves data from a specified sheet. - **update_cells**: Writes data to specified cells in a sheet. - **list_spreadsheets**: Lists available spreadsheets in the connected account. - **list_sheets**: Lists tabs within a specific spreadsheet. ### Usage Note These tools require appropriate Google Drive/Sheets API permissions and authentication via Service Account or OAuth 2.0. ``` -------------------------------- ### Share Spreadsheet with Users Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Shares a Google Spreadsheet with a list of recipients, assigning specific roles such as reader, commenter, or writer. It supports optional email notifications for the shared users. ```python result = share_spreadsheet( spreadsheet_id="1aBcDeFgHiJkLmNoPqRsTuVwXyZ", recipients=[ {"email_address": "manager@example.com", "role": "writer"}, {"email_address": "team@example.com", "role": "reader"}, {"email_address": "reviewer@example.com", "role": "commenter"} ], send_notification=True ) result = share_spreadsheet( spreadsheet_id="1aBcDeFgHiJkLmNoPqRsTuVwXyZ", recipients=[{"email_address": "silent@example.com", "role": "reader"}], send_notification=False ) ``` -------------------------------- ### Retrieve Spreadsheet Metadata via MCP Resource Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Shows how to access spreadsheet metadata using the MCP resource URI pattern. The request returns a JSON object containing the spreadsheet title and a list of sheets with their respective grid properties. ```json { "title": "Quarterly Report", "sheets": [ { "title": "Sheet1", "sheetId": 0, "gridProperties": { "rowCount": 1000, "columnCount": 26 } }, { "title": "Summary", "sheetId": 123456789, "gridProperties": { "rowCount": 100, "columnCount": 10 } } ] } ``` -------------------------------- ### List Spreadsheets in Google Drive (Python) Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Python code to list spreadsheets within a specified Google Drive folder or the default configured folder. The function returns a list of dictionaries, each containing the spreadsheet ID and title, sorted by modification time. ```python # List spreadsheets in configured default folder result = list_spreadsheets() # Returns: [{'id': '1aBcDeFgHiJkLmNoPqRsTuVwXyZ', 'title': 'Sales Report Q4'}, ...] # List spreadsheets in a specific folder result = list_spreadsheets(folder_id="1xyzABC123folderID") # Returns: [{'id': '1abc...', 'title': 'Budget 2024'}, {'id': '2def...', 'title': 'Inventory'}] ``` -------------------------------- ### Add Chart to Spreadsheet Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Creates and positions a chart within a spreadsheet based on a specified data range. Supports various chart types like column, bar, and line. ```python result = add_chart( spreadsheet_id="1aBcDeFgHiJkLmNoPqRsTuVwXyZ", sheet="Sales", chart_type="COLUMN", data_range="A1:B13", title="Monthly Sales 2024", x_axis_label="Month", y_axis_label="Revenue ($)", position_x=400, position_y=50, width=600, height=400 ) ``` -------------------------------- ### Manage Sheets and Tabs Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Operations for copying sheets between spreadsheets or renaming existing tabs within a spreadsheet. ```python result = copy_sheet( src_spreadsheet="1SourceSpreadsheetID", src_sheet="Template", dst_spreadsheet="1DestinationSpreadsheetID", dst_sheet="Q4 Report" ) result = rename_sheet( spreadsheet="1aBcDeFgHiJkLmNoPqRsTuVwXyZ", sheet="Sheet1", new_name="Sales Data 2024" ) ``` -------------------------------- ### Retrieve Sheet Formulas Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Fetches cell formulas from a specified spreadsheet and range. Returns a 2D array representing the formula structure within the requested area. ```python formulas = get_sheet_formulas( spreadsheet_id="1aBcDeFgHiJkLmNoPqRsTuVwXyZ", sheet="Calculations" ) formulas = get_sheet_formulas( spreadsheet_id="1aBcDeFgHiJkLmNoPqRsTuVwXyZ", sheet="Budget", range="D1:D20" ) ``` -------------------------------- ### POST /update_cells Source: https://context7.com/xing5/mcp-google-sheets/llms.txt Writes data to a specific range in a Google Spreadsheet, overwriting existing content. ```APIDOC ## POST /update_cells ### Description Updates a specific range with a 2D array of values. ### Method POST ### Endpoint /update_cells ### Parameters #### Request Body - **spreadsheet_id** (string) - Required - The ID of the spreadsheet. - **sheet** (string) - Required - The name of the sheet. - **range** (string) - Required - The target range (e.g., A1:C3). - **data** (array) - Required - A 2D array of values to write. ### Request Example { "spreadsheet_id": "1aBcDeFgHiJkLmNoPqRsTuVwXyZ", "sheet": "Sheet1", "range": "A1:C3", "data": [["Name", "Sales"], ["Alice", 1500]] } ### Response #### Success Response (200) - **updatedRange** (string) - The range that was updated. - **updatedCells** (integer) - The total number of cells updated. ```