Google Drive MCP Server Policy

Sandbox the Google Drive MCP server. It needs access to multiple Google APIs.

What it needs

ResourceAccessDetails
FilesystemRead + WriteOAuth credentials file + cache
Network3 Google API hostswww.googleapis.com, oauth2.googleapis.com, drive.google.com
EnvGoogle credentialsGOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET

Complete Policy

command: ["node", "@modelcontextprotocol/server-gdrive"]

filesystem:
  read:
    - "./config/credentials.json"     # OAuth client credentials
  write:
    - "./cache"                       # API response cache

network:
  allow:
    - "www.googleapis.com"            # Google APIs
    - "oauth2.googleapis.com"         # OAuth flow
    - "drive.google.com"              # Drive web UI

env:
  allow:
    - "GOOGLE_CLIENT_ID"
    - "GOOGLE_CLIENT_SECRET"
    - "HOME"

limits:
  memory_mb: 256
  timeout_s: 300

How to run

# Step 1: Install the server
npm install -g @modelcontextprotocol/server-gdrive

# Step 2: Set credentials
export GOOGLE_CLIENT_ID="your-client-id"
export GOOGLE_CLIENT_SECRET="your-client-secret"

# Step 3: Run sandboxed
warden run --policy policy-gdrive.yaml

Tips

  • Give the exact path to credentials.json
  • 3 Google API hosts are needed, add all of them to network.allow
  • The OAuth flow happens on oauth2.googleapis.com
  • The cache directory is needed for API responses

Security

  • Grant credentials.json read-only access (only read)
  • Never put GOOGLE_CLIENT_SECRET in the policy
  • The cache directory may store sensitive data

Troubleshooting

ErrorFix
OAuth errorIs oauth2.googleapis.com in network.allow?
credentials not foundCheck the path to credentials.json
API errorIs www.googleapis.com in network.allow?

Resources