MCP Libraries
mcp-gsheets

Configuration

Configuration options for mcp-gsheets

Configuration

Environment Variables

VariableRequiredDescription
GOOGLE_PROJECT_IDYes*Your Google Cloud project ID
GOOGLE_APPLICATION_CREDENTIALSOption 1Path to service account JSON key file
GOOGLE_SERVICE_ACCOUNT_KEYOption 2Full service account JSON as string
GOOGLE_PRIVATE_KEYOption 3Private key from service account
GOOGLE_CLIENT_EMAILOption 3Service account email

*Optional if included in JSON credentials

Authentication Methods

Option 1: File-based (Traditional)

{
  "env": {
    "GOOGLE_PROJECT_ID": "your-project-id",
    "GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/service-account-key.json"
  }
}

Option 2: JSON String (CI/CD, Containers)

Provide the entire service account JSON as an escaped string:

{
  "env": {
    "GOOGLE_PROJECT_ID": "your-project-id",
    "GOOGLE_SERVICE_ACCOUNT_KEY": "{\"type\":\"service_account\",\"project_id\":\"...\",\"private_key\":\"-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----\\n\",\"client_email\":\"...@....iam.gserviceaccount.com\"}"
  }
}

Notes:

  • 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

Option 3: Private Key + Email (Simplified)

The simplest method - only two fields needed:

{
  "env": {
    "GOOGLE_PRIVATE_KEY": "-----BEGIN PRIVATE KEY-----\\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAo...\\n-----END PRIVATE KEY-----\\n",
    "GOOGLE_CLIENT_EMAIL": "spreadsheet@your-project.iam.gserviceaccount.com"
  }
}

Finding IDs

Spreadsheet ID

From the URL:

https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit
                                        ↑ This is the spreadsheet ID

Sheet ID

Use sheets_get_metadata to list all sheets with their IDs.

Troubleshooting

Authentication Failed

  • Verify JSON key path is absolute and correct
  • Ensure JSON is properly escaped (for string auth)
  • Check that the private key includes BEGIN/END markers
  • Verify client email is a valid service account email

Permission Denied

  • Share spreadsheet with service account email
  • Service account needs "Editor" role
  • Check the client_email field in your JSON file

Spreadsheet Not Found

  • Verify spreadsheet ID from URL
  • Ensure the spreadsheet is shared with the service account

On this page