### Clone and Install Google Drive MCP Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Clone the repository and install dependencies using npm. This is the initial setup step for local installation. ```bash git clone https://github.com/piotr-agier/google-drive-mcp.git cd google-drive-mcp npm install ``` -------------------------------- ### Set Up OAuth Credentials Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Copy the example credentials file and edit it with your OAuth client ID. This file is required for authentication. ```bash # Copy the example file cp gcp-oauth.keys.example.json gcp-oauth.keys.json # Edit gcp-oauth.keys.json with your OAuth client ID ``` -------------------------------- ### Install Google Drive MCP Server via npx Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Install and run the Google Drive MCP Server directly using npx, or run the authentication process separately. ```bash npx @piotr-agier/google-drive-mcp ``` ```bash npx @piotr-agier/google-drive-mcp auth ``` -------------------------------- ### Claude Desktop MCP Server Configuration (Local Install) Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Configure Claude Desktop to use a locally installed Google Drive MCP server. Provide the absolute path to the installed JavaScript file and your GCP OAuth credentials. ```json { "mcpServers": { "google-drive": { "command": "node", "args": ["/absolute/path/to/google-drive-mcp/dist/index.js"], "env": { "GOOGLE_DRIVE_OAUTH_CREDENTIALS": "/path/to/your/gcp-oauth.keys.json" } } } } ``` -------------------------------- ### Start Google Drive MCP Server in HTTP Transport Mode Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Start the Google Drive MCP server using HTTP transport, specifying the port and host, or by setting environment variables. ```bash # Start server in HTTP mode google-drive-mcp start --transport http --port 3100 --host 127.0.0.1 # Or with environment variables MCP_TRANSPORT=http MCP_HTTP_PORT=3100 google-drive-mcp start ``` -------------------------------- ### Claude Desktop Integration Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Instructions for integrating the Google Drive MCP server with Claude Desktop using either npx or a local installation. ```APIDOC ## Usage with Claude Desktop Add the server to your Claude Desktop configuration: **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json` **Windows**: `%APPDATA%\Claude\claude_desktop_config.json` ### Using npx (Recommended): ```json { "mcpServers": { "google-drive": { "command": "npx", "args": ["@piotr-agier/google-drive-mcp"], "env": { "GOOGLE_DRIVE_OAUTH_CREDENTIALS": "/path/to/your/gcp-oauth.keys.json" } } } } ``` ### Using Local Installation: ```json { "mcpServers": { "google-drive": { "command": "node", "args": ["/absolute/path/to/google-drive-mcp/dist/index.js"], "env": { "GOOGLE_DRIVE_OAUTH_CREDENTIALS": "/path/to/your/gcp-oauth.keys.json" } } } } ``` **Note**: Replace `/path/to/your/gcp-oauth.keys.json` with the actual path to your OAuth credentials file. ``` -------------------------------- ### Start Google Drive MCP in HTTP Mode Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Start the Google Drive MCP server using the HTTP transport. You can specify the port and host using CLI flags or environment variables. CLI flags take precedence. ```bash google-drive-mcp start --transport http --port 3100 --host 127.0.0.1 ``` ```bash MCP_TRANSPORT=http MCP_HTTP_PORT=3100 MCP_HTTP_HOST=127.0.0.1 google-drive-mcp start ``` -------------------------------- ### Build Google Drive MCP Project Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Install dependencies and build the project before building the Docker image. This ensures all necessary files are generated for the Docker build process. ```bash npm install npm run build ``` -------------------------------- ### NPM Scripts for MCP Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Commonly used npm scripts for managing the Google Drive MCP project, including starting the server, authentication, building, and testing. ```bash - npm start - Start the compiled server - npm run auth - Run authentication flow - npm run build - Build the project (runs typecheck + custom build script) - npm run watch - Build and watch for changes - npm run typecheck - Run TypeScript type checking only - npm run lint - Run TypeScript type checking (alias for typecheck) - npm run prepare - Auto-runs build before npm publish - npm test - Run unit tests ``` -------------------------------- ### Docker Configuration for Fresh Container Each Time Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Configure MCP clients to use a fresh Docker container for each client restart. This setup creates and removes a new container every time, ensuring a clean environment. ```json { "mcpServers": { "google-drive": { "command": "docker", "args": [ "run", "-i", "--rm", "-v", "/path/to/gcp-oauth.keys.json:/config/gcp-oauth.keys.json:ro", "-v", "/Users/yourname/.config/google-drive-mcp/tokens.json:/config/tokens.json", "google-drive-mcp" ] } } } ``` -------------------------------- ### Docker Configuration for Reusable Container Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Configure MCP clients to use a reusable Docker container. This setup uses a wrapper script that manages a single named container for faster startup and reduced churn. ```json { "mcpServers": { "google-drive": { "command": "/path/to/google-drive-mcp/scripts/docker-mcp.sh", "env": { "GOOGLE_DRIVE_OAUTH_CREDENTIALS": "$HOME/gcp-oauth.keys.json", "GOOGLE_DRIVE_MCP_TOKEN_PATH": "$HOME/.config/google-drive-mcp/tokens.json" } } } } ``` -------------------------------- ### Set Auth Server Port Configuration Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Configure the starting port for the local HTTP server used during OAuth authentication by setting the GOOGLE_DRIVE_MCP_AUTH_PORT environment variable. This is useful if default ports conflict with other services. ```bash export GOOGLE_DRIVE_MCP_AUTH_PORT=3100 ``` -------------------------------- ### Run Google Drive MCP Docker Container Help Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Verify the Docker image by running the container with the --help flag. This command checks if the image was built correctly and the entry point is functional. ```bash docker run --rm google-drive-mcp --help ``` -------------------------------- ### Create Folder and Template Documents Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Use this command to create a new folder and populate it with standard template documents. ```natural language Create a Templates folder and add standard documents like a Meeting Notes template, Project Proposal template, and Budget Spreadsheet template. ``` -------------------------------- ### Run Google Drive MCP Server Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Execute the Google Drive MCP Server using npx. Authentication is handled automatically on the first run. ```bash npx @piotr-agier/google-drive-mcp ``` -------------------------------- ### Get Google Sheet Content Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Read data from a specific range within a Google Sheet. ```APIDOC ## POST /getGoogleSheetContent ### Description Read data from a specific range within a Google Sheet. ### Method POST ### Endpoint /getGoogleSheetContent ### Parameters #### Request Body - **spreadsheetId** (string) - Required - The ID of the spreadsheet to read from. - **range** (string) - Required - The A1 notation of the range to retrieve (e.g., "Sheet1!A1:E5"). ### Request Example ```json { "spreadsheetId": "sheet123abc", "range": "Sheet1!A1:E5" } ``` ### Response #### Success Response (200) - **content** (string) - The retrieved data from the specified range, formatted row by row. #### Response Example ```json { "content": "Content for range Sheet1!A1:E5:\nRow 1: Product, Q1, Q2, Q3, Q4\nRow 2: Widget A, 1000, 1200, 1100, 1300\nRow 3: Widget B, 800, 900, 950, 1000" } ``` ``` -------------------------------- ### List all calendars Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Lists all accessible calendars for the authenticated user. Use this to get a list of calendars before performing operations on them. ```javascript await mcp.callTool("listCalendars", { showHidden: false }); ``` -------------------------------- ### Delete Content Range in Google Doc Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Delete a range of content from a Google Doc specified by start and end character indices. ```javascript await mcp.callTool("deleteRange", { documentId: "doc123abc", startIndex: 50, endIndex: 100 }); ``` -------------------------------- ### Create Google Doc Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Use this command to create a new Google Doc with a specified title and content outline in a given folder. ```natural language Create a new Google Doc called "Project Plan" in the folder /Work/Projects with an outline for our Q1 initiatives including milestones and deliverables. ``` -------------------------------- ### Get Google Doc Content with Formatting Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Retrieve document content along with formatting information, including text indices for precise operations. ```javascript await mcp.callTool("getGoogleDocContent", { documentId: "doc123abc", includeFormatting: true }); ``` -------------------------------- ### Authenticate Google Drive MCP Locally Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Run the authentication command to generate tokens. This step is optional as authentication occurs automatically on the first run if skipped. ```bash npm run auth ``` -------------------------------- ### Get content of a Google Slides presentation Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Retrieves the content of a specific slide from a Google Slides presentation, including element IDs for further formatting. Requires presentation ID and slide index. ```javascript await mcp.callTool("getGoogleSlidesContent", { presentationId: "slides123abc", slideIndex: 0 }); ``` -------------------------------- ### Build and Watch Project Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Compile TypeScript code for the project. Use 'watch' for continuous compilation during development. ```bash npm run build # Compile TypeScript npm run watch # Compile and watch for changes npm run typecheck # Type checking without compilation ``` -------------------------------- ### Create Google Presentation Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md This command creates a new Google Slides presentation with slides outlining project details. ```natural language Create a presentation called "Product Roadmap" with slides outlining our Q1 milestones, key features, and timeline. ``` -------------------------------- ### Get calendar events with filtering Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Retrieves events from a specified calendar with options for time range, result count, and ordering. Ensure `calendarId` is valid and `timeMin`/`timeMax` are in ISO 8601 format. ```javascript await mcp.callTool("getCalendarEvents", { calendarId: "primary", timeMin: "2024-01-01T00:00:00Z", timeMax: "2024-01-31T23:59:59Z", maxResults: 50, singleEvents: true, orderBy: "startTime" }); ``` -------------------------------- ### Claude Desktop Configuration for Google Drive MCP Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Configure Claude Desktop to use the Google Drive MCP server by specifying the command, arguments, and environment variables for authentication. ```json { "mcpServers": { "google-drive": { "command": "npx", "args": ["@piotr-agier/google-drive-mcp"], "env": { "GOOGLE_DRIVE_OAUTH_CREDENTIALS": "/path/to/your/gcp-oauth.keys.json" } } } } ``` -------------------------------- ### Create Google Sheet Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Use this command to create a new Google Sheet with specified columns for tracking data. ```natural language Create a Google Sheet called "Sales Analysis 2024" with columns for Date, Product, Quantity, and Revenue to track your sales data. ``` -------------------------------- ### Build Docker Image After Local Build Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Build the project locally first to ensure the dist/ directory exists, then build the Docker image. This resolves 'npm ci failed' errors during Docker build. ```bash npm install npm run build docker build -t google-drive-mcp . ``` -------------------------------- ### Initiate Manual Re-authentication Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Run this command to re-authenticate, switch accounts, or refresh expired tokens. It can be executed via npx or a local npm script. ```bash # Using npx npx @piotr-agier/google-drive-mcp auth ``` ```bash # Using local installation npm run auth ``` -------------------------------- ### Set Environment Variables for Credentials Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Configure production environments by exporting environment variables for OAuth credentials and token paths. ```bash export GOOGLE_DRIVE_OAUTH_CREDENTIALS="/secure/path/credentials.json" export GOOGLE_DRIVE_MCP_TOKEN_PATH="/secure/path/tokens.json" ``` -------------------------------- ### Search and Organize Files Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md This command searches for files containing a specific keyword and organizes them by moving them to appropriate folders. ```natural language Search for files containing "budget" and organize them by moving each one to the appropriate folder in your Drive hierarchy. ``` -------------------------------- ### Create New Google Doc Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Create a new Google Document with a specified name, initial content, and parent folder. ```javascript await mcp.callTool("createGoogleDoc", { name: "Meeting Notes", content: "# Team Meeting\n\n## Agenda\n1. Project updates\n2. Timeline review\n3. Next steps", parentFolderId: "/Work/Meetings" }); ``` -------------------------------- ### Enable Missing Google Cloud APIs Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md If you encounter 'API not enabled' errors, enable the required API through the Google Cloud Console. Allow a few minutes for the changes to propagate. ```bash Error: Google Sheets API has not been used in project... ``` -------------------------------- ### Build Docker Image for Google Drive MCP Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Build the Docker image tagged as 'google-drive-mcp' from the current directory. This command creates the Docker image used for running the MCP in a container. ```bash docker build -t google-drive-mcp . ``` -------------------------------- ### Create Google Sheet Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Create a new Google Sheet with specified initial data and parent folder. ```APIDOC ## POST /createGoogleSheet ### Description Create a new Google Sheet with specified initial data and parent folder. ### Method POST ### Endpoint /createGoogleSheet ### Parameters #### Request Body - **name** (string) - Required - The name of the new spreadsheet. - **data** (array of arrays) - Optional - Initial data to populate the spreadsheet. Each inner array represents a row. - **parentFolderId** (string) - Optional - The ID or path of the folder where the spreadsheet should be created. ### Request Example ```json { "name": "Sales Report 2024", "data": [ ["Product", "Q1", "Q2", "Q3", "Q4"], ["Widget A", "1000", "1200", "1100", "1300"], ["Widget B", "800", "900", "950", "1000"], ["Widget C", "500", "600", "700", "800"] ], "parentFolderId": "/Reports" } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the spreadsheet was created, including its name and ID. #### Response Example ```json { "message": "Created Google Sheet: Sales Report 2024\nID: sheet123abc" } ``` ``` -------------------------------- ### Set OAuth Credentials via Environment Variable Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Configure OAuth credentials by setting the GOOGLE_DRIVE_OAUTH_CREDENTIALS environment variable. This method has the highest priority for providing credentials. ```bash export GOOGLE_DRIVE_OAUTH_CREDENTIALS="/path/to/your/gcp-oauth.keys.json" ``` -------------------------------- ### Mount Token File with Write Permissions in Docker Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Ensure the token file is mounted with write permissions to allow token refresh within the Docker container. Use the correct volume mount syntax. ```bash # Correct: tokens can be updated -v "$HOME/.config/google-drive-mcp/tokens.json":/config/tokens.json # Wrong: read-only mount prevents token refresh -v "$HOME/.config/google-drive-mcp/tokens.json":/config/tokens.json:ro ``` -------------------------------- ### Search Documents and Summarize Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md This command searches for documents within a specified folder and creates a summary document listing the found files. ```natural language Search for documents in the /Reports folder and create a summary document listing the files you found. ``` -------------------------------- ### Create Google Sheet Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Use `createGoogleSheet` to create a new spreadsheet with initial data and specify a parent folder. The `data` parameter accepts a 2D array. ```javascript await mcp.callTool("createGoogleSheet", { name: "Sales Report 2024", data: [ ["Product", "Q1", "Q2", "Q3", "Q4"], ["Widget A", "1000", "1200", "1100", "1300"], ["Widget B", "800", "900", "950", "1000"], ["Widget C", "500", "600", "700", "800"] ], parentFolderId: "/Reports" }); ``` -------------------------------- ### Verify Token Location Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Check if the authentication token file exists in the expected configuration directory. This confirms that the authentication process has successfully created the token file. ```bash ls -la ~/.config/google-drive-mcp/tokens.json ``` -------------------------------- ### Manually Authenticate Google Drive MCP Server Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Run this command to manually trigger the authentication process for the Google Drive MCP Server if needed. ```bash npx @piotr-agier/google-drive-mcp auth ``` -------------------------------- ### Available Tools - Search and Navigation Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Tools for searching files and listing contents of folders and shared drives. ```APIDOC ## Available Tools ### Search and Navigation - **search** - Search for files across Google Drive - `query`: Search terms (or raw Drive API query when `rawQuery=true`) - `pageSize`: Number of results per page (optional, default 50, max 100) - `pageToken`: Pagination token for next page (optional) - `rawQuery`: Pass `query` directly to the Drive API — enables operators like `modifiedTime`, `createdTime`, `mimeType`, `name contains`, etc. (optional) - **listFolder** - List contents of a folder - `folderId`: Folder ID (optional, defaults to root) - `pageSize`: Number of results (optional, max 100) - `pageToken`: Pagination token (optional) - **listSharedDrives** - List available Google Shared Drives - `pageSize`: Number of drives to return (optional, default 50, max 100) - `pageToken`: Pagination token (optional) ``` -------------------------------- ### Check for Port Conflicts Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Use this command to identify processes listening on the default authentication ports (3000-3004). ```bash # Check if ports are in use lsof -i :3000-3004 ``` -------------------------------- ### Available Tools - File Management Source: https://github.com/piotr-agier/google-drive-mcp/blob/master/README.md Tools for creating, updating, deleting, renaming, moving, and copying files and folders. ```APIDOC ### File Management - **createTextFile** - Create a text or markdown file - `name`: File name (must end with .txt or .md) - `content`: File content - `parentFolderId`: Parent folder ID (optional) - **updateTextFile** - Update existing text file - `fileId`: File ID to update - `content`: New content - `name`: New name (optional) - **deleteItem** - Move a file or folder to trash (not a permanent deletion - items can be restored from Google Drive trash) - `itemId`: Item ID to move to trash - **renameItem** - Rename a file or folder - `itemId`: Item ID to rename - `newName`: New name - **moveItem** - Move a file or folder - `itemId`: Item ID to move - `destinationFolderId`: Destination folder ID - **copyFile** - Create a copy of a Google Drive file or document - `fileId`: ID of the file to copy - `newName`: Name for the copied file (optional, defaults to "Copy of [original name]") - `parentFolderId`: Destination folder ID (optional, defaults to same location) ``` -------------------------------- ### Share File with User Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Share files with specific users, assigning them a role and optionally sending a notification email. ```javascript await mcp.callTool("shareFile", { fileId: "doc123", emailAddress: "colleague@example.com", role: "writer", sendNotificationEmail: true, emailMessage: "Here's the document we discussed" }); ``` -------------------------------- ### Create a Google Slides presentation Source: https://context7.com/piotr-agier/google-drive-mcp/llms.txt Creates a new Google Slides presentation with specified slides and content. Allows setting a name, defining slides with titles and content, and specifying a parent folder. ```javascript await mcp.callTool("createGoogleSlides", { name: "Q1 Product Roadmap", slides: [ { title: "Product Roadmap 2024", content: "Strategic initiatives and milestones" }, { title: "Q1 Goals", content: "Launch new features\nImprove performance\nExpand market reach" }, { title: "Timeline", content: "January: Planning\nFebruary: Development\nMarch: Launch" } ], parentFolderId: "/Presentations" }); ```