Skip to main content
Glama

Google Drive MCP Server

by ducla5
SETUP.md6.17 kB
# Google Drive MCP Server Setup Guide This guide will walk you through setting up the Google Drive MCP Server from installation to first use. ## Prerequisites Before you begin, ensure you have: - **Node.js 18.0.0 or higher** - [Download Node.js](https://nodejs.org/) - **npm or yarn** - Comes with Node.js - **Google Account** - For Google Drive API access - **Google Cloud Project** - For API credentials ## Installation ### 1. Clone and Install ```bash # Clone the repository git clone <repository-url> cd google-drive-mcp-server # Install dependencies npm install # Build the project npm run build ``` ### 2. Verify Installation ```bash # Check if the CLI is working npx google-drive-mcp --help # Verify TypeScript compilation npm run type-check ``` ## Google Drive API Setup ### 1. Create Google Cloud Project 1. Go to the [Google Cloud Console](https://console.cloud.google.com/) 2. Click "Select a project" → "New Project" 3. Enter project name (e.g., "Google Drive MCP Server") 4. Click "Create" ### 2. Enable Google Drive API 1. In your project, go to "APIs & Services" → "Library" 2. Search for "Google Drive API" 3. Click on it and press "Enable" 4. Also enable "Google Docs API" for document processing ### 3. Create OAuth 2.0 Credentials 1. Go to "APIs & Services" → "Credentials" 2. Click "Create Credentials" → "OAuth client ID" 3. If prompted, configure the OAuth consent screen: - Choose "External" for user type - Fill in required fields (App name, User support email, Developer contact) - Add your email to test users 4. For Application type, choose "Desktop application" 5. Name it "Google Drive MCP Server" 6. Click "Create" 7. Download the JSON file and save it as `credentials.json` in your project root ### 4. Configure Redirect URI In your OAuth client settings, add these redirect URIs: - `http://localhost:8080/callback` - `urn:ietf:wg:oauth:2.0:oob` (for CLI authentication) ## Configuration ### Method 1: Configuration File (Recommended) Create a `config.json` file in your project root: ```json { "google": { "clientId": "your-client-id.googleusercontent.com", "clientSecret": "your-client-secret", "redirectUri": "http://localhost:8080/callback", "scopes": [ "https://www.googleapis.com/auth/drive.readonly", "https://www.googleapis.com/auth/documents.readonly" ], "applicationName": "Google Drive MCP Server" }, "cache": { "directory": "./cache", "maxSize": "1GB", "defaultTTL": 3600, "cleanupInterval": 300 }, "processing": { "maxFileSize": "100MB", "supportedMimeTypes": [ "application/vnd.google-apps.document", "application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "text/plain", "text/markdown" ], "chunkSize": 4000, "summaryLength": 500 }, "server": { "port": 3000, "logLevel": "info", "requestTimeout": 30000 } } ``` ### Method 2: Environment Variables Alternatively, set these environment variables: ```bash # Required export GOOGLE_CLIENT_ID="your-client-id.googleusercontent.com" export GOOGLE_CLIENT_SECRET="your-client-secret" export GOOGLE_REDIRECT_URI="http://localhost:8080/callback" # Optional (with defaults) export CACHE_DIR="./cache" export CACHE_MAX_SIZE="1GB" export CACHE_TTL="3600" export LOG_LEVEL="info" export MAX_FILE_SIZE="100MB" export SERVER_PORT="3000" ``` ## Authentication Setup ### Using the CLI Wizard (Recommended) The server includes an interactive authentication wizard: ```bash # Run the authentication wizard npx google-drive-mcp auth setup # Follow the prompts: # 1. It will open your browser for Google OAuth # 2. Sign in and grant permissions # 3. The wizard will save your tokens securely ``` ### Manual Authentication If the wizard doesn't work, you can authenticate manually: ```bash # Start the server in auth mode npx google-drive-mcp auth manual # Copy the provided URL to your browser # After authorization, copy the code back to the terminal ``` ## First Run ### 1. Start the Server ```bash # Start the MCP server npm start # Or in development mode with auto-reload npm run dev ``` ### 2. Test the Connection ```bash # Test authentication npx google-drive-mcp test auth # Test basic functionality npx google-drive-mcp test search "test" ``` ### 3. Verify MCP Tools The server should expose these MCP tools: - `drive_search_files` - `drive_get_file` - `drive_get_content_chunk` - `drive_get_file_metadata` - `drive_list_folder` - `drive_get_comments` ## Integration with MCP Clients ### Claude Desktop Add to your Claude Desktop configuration: ```json { "mcpServers": { "google-drive": { "command": "node", "args": ["/path/to/google-drive-mcp-server/dist/index.js"], "env": { "GOOGLE_CLIENT_ID": "your-client-id", "GOOGLE_CLIENT_SECRET": "your-client-secret" } } } } ``` ### Other MCP Clients For other MCP-compatible clients, use: - **Command**: `node /path/to/google-drive-mcp-server/dist/index.js` - **Protocol**: stdio - **Environment**: Set the required environment variables ## Verification ### Test Basic Functionality ```bash # Search for files npx google-drive-mcp search --query "presentation" # Get file metadata npx google-drive-mcp info --file-id "your-file-id" # Test content extraction npx google-drive-mcp content --file-id "your-file-id" --chunk-size 1000 ``` ### Check Server Health ```bash # Check server status curl http://localhost:3000/health # View server logs tail -f logs/server.log ``` ## Next Steps 1. **Explore the API**: Check out the [API documentation](./API.md) 2. **See Examples**: Review [usage examples](./EXAMPLES.md) 3. **Troubleshooting**: If you encounter issues, see [troubleshooting guide](./TROUBLESHOOTING.md) 4. **Configuration**: Learn about [advanced configuration options](./CONFIGURATION.md) ## Security Notes - Keep your `credentials.json` and token files secure - Never commit credentials to version control - Use environment variables in production - Regularly rotate your OAuth credentials - Monitor API usage in Google Cloud Console

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ducla5/gdriver-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server