@starfysh/gdrive-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ https://opensource.org/license/MIT
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the β€œSoftware”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,521 @@
1
+ # Ultimate Google Docs, Sheets & Drive MCP Server
2
+
3
+ ![Demo Animation](assets/google.docs.mcp.1.gif)
4
+
5
+ Connect Claude Desktop (or other MCP clients) to your Google Docs, Google Sheets, and Google Drive!
6
+
7
+ > πŸ”₯ **Check out [15 powerful tasks](SAMPLE_TASKS.md) you can accomplish with this enhanced server!**
8
+ > πŸ“ **NEW:** Complete Google Drive file management capabilities!
9
+ > πŸ“Š **NEW:** Full Google Sheets support for reading, writing, and managing spreadsheets!
10
+
11
+ This comprehensive server uses the Model Context Protocol (MCP) and the `fastmcp` library to provide tools for reading, writing, formatting, structuring Google Documents and Spreadsheets, and managing your entire Google Drive. It acts as a powerful bridge, allowing AI assistants like Claude to interact with your documents, spreadsheets, and files programmatically with advanced capabilities.
12
+
13
+ **Features:**
14
+
15
+ ### Document Access & Editing
16
+
17
+ - **Read Documents:** Read content with `readGoogleDoc` (plain text, JSON structure, or markdown)
18
+ - **Append to Documents:** Add text to documents with `appendToGoogleDoc`
19
+ - **Insert Text:** Place text at specific positions with `insertText`
20
+ - **Delete Content:** Remove content from a document with `deleteRange`
21
+ - **Tab Support:** Work with multi-tab documents using `listDocumentTabs` and optional `tabId` parameter in read/write operations
22
+
23
+ ### Formatting & Styling
24
+
25
+ - **Text Formatting:** Apply rich styling with `applyTextStyle` (bold, italic, colors, etc.)
26
+ - **Paragraph Formatting:** Control paragraph layout with `applyParagraphStyle` (alignment, spacing, etc.)
27
+ - **Find & Format:** Format by text content using `formatMatchingText` (legacy support)
28
+
29
+ ### Document Structure
30
+
31
+ - **Tables:** Create tables with `insertTable`
32
+ - **Page Breaks:** Insert page breaks with `insertPageBreak`
33
+ - **Images:** Insert images from URLs with `insertImageFromUrl`, or upload local images with `insertLocalImage`
34
+ - **Experimental Features:** Tools like `fixListFormatting` for automatic list detection
35
+
36
+ ### πŸ†• Comment Management
37
+
38
+ - **List Comments:** View all comments in a document with `listComments` (shows author, date, and quoted text)
39
+ - **Get Comment Details:** Get specific comment with replies using `getComment`
40
+ - **Add Comments:** Create new comments anchored to text with `addComment`
41
+ - **Reply to Comments:** Add replies to existing comments with `replyToComment`
42
+ - **Resolve Comments:** Mark comments as resolved with `resolveComment`
43
+ - **Delete Comments:** Remove comments from documents with `deleteComment`
44
+
45
+ ### πŸ†• Google Sheets Support
46
+
47
+ - **Read Spreadsheets:** Read data from ranges with `readSpreadsheet` (supports A1 notation like "A1:B10" or "Sheet1!A1:B10")
48
+ - **Write Data:** Write data to ranges with `writeSpreadsheet` (overwrites existing data)
49
+ - **Append Rows:** Add new rows to sheets with `appendSpreadsheetRows`
50
+ - **Clear Ranges:** Clear cell values with `clearSpreadsheetRange`
51
+ - **Spreadsheet Info:** Get detailed metadata and sheet list with `getSpreadsheetInfo`
52
+ - **Create Spreadsheets:** Create new spreadsheets with `createSpreadsheet` (optionally with initial data)
53
+ - **Add Sheets:** Add new sheets/tabs to spreadsheets with `addSpreadsheetSheet`
54
+ - **List Spreadsheets:** Find and list spreadsheets with `listGoogleSheets`
55
+
56
+ ### πŸ†• Google Drive File Management
57
+
58
+ - **Document Discovery:** Find and list documents with `listGoogleDocs`, `searchGoogleDocs`, `getRecentGoogleDocs`
59
+ - **Document Information:** Get detailed metadata with `getDocumentInfo`
60
+ - **Folder Management:** Create folders (`createFolder`), list contents (`listFolderContents`), get info (`getFolderInfo`)
61
+ - **File Operations:** Move (`moveFile`), copy (`copyFile`), rename (`renameFile`), delete (`deleteFile`)
62
+ - **Document Creation:** Create new docs (`createDocument`) or from templates (`createFromTemplate`)
63
+
64
+ ### πŸ†• Shared Drive Support
65
+
66
+ - **List Shared Drives:** Discover accessible shared drives with `listSharedDrives`
67
+ - **Search Across Drives:** All document and spreadsheet discovery tools now include results from shared drives
68
+ - **Folder Navigation:** Browse shared drive folders using `listFolderContents` with the folder ID
69
+
70
+ ### πŸ†• Enterprise Features
71
+
72
+ - **List Permissions:** Audit file access with `listFilePermissions` - see all users, groups, and domains with access
73
+ - **Share Files:** Share files programmatically with `shareFile` - supports users, groups, domains, and public access
74
+ - **Remove Access:** Revoke permissions with `removePermission` - remove specific users or groups from files
75
+ - **Version History:** View file revisions with `listRevisions` - track changes for compliance and auditing
76
+
77
+ ### Integration
78
+
79
+ - **Google Authentication:** Secure OAuth 2.0 authentication with full Drive, Docs, and Sheets access
80
+ - **MCP Compliant:** Designed for use with Claude and other MCP clients
81
+ - **VS Code Integration:** [Setup guide](vscode.md) for VS Code MCP extension
82
+
83
+ ---
84
+
85
+ ## Prerequisites
86
+
87
+ Before you start, make sure you have:
88
+
89
+ 1. **Node.js and npm:** A recent version of Node.js (which includes npm) installed on your computer. You can download it from [nodejs.org](https://nodejs.org/). (Version 18 or higher recommended).
90
+ 2. **Git:** Required for cloning this repository. ([Download Git](https://git-scm.com/downloads)).
91
+ 3. **A Google Account:** The account that owns or has access to the Google Docs you want to interact with.
92
+ 4. **Command Line Familiarity:** Basic comfort using a terminal or command prompt (like Terminal on macOS/Linux, or Command Prompt/PowerShell on Windows).
93
+ 5. **Claude Desktop (Optional):** If your goal is to connect this server to Claude, you'll need the Claude Desktop application installed.
94
+
95
+ ---
96
+
97
+ ## Setup Instructions
98
+
99
+ Follow these steps carefully to get your own instance of the server running.
100
+
101
+ ### Step 1: Google Cloud Project & Credentials (The Important Bit!)
102
+
103
+ This server needs permission to talk to Google APIs on your behalf. You'll create special "keys" (credentials) that only your server will use.
104
+
105
+ 1. **Go to Google Cloud Console:** Open your web browser and go to the [Google Cloud Console](https://console.cloud.google.com/). You might need to log in with your Google Account.
106
+ 2. **Create or Select a Project:**
107
+ - If you don't have a project, click the project dropdown near the top and select "NEW PROJECT". Give it a name (e.g., "My MCP Docs Server") and click "CREATE".
108
+ - If you have existing projects, you can select one or create a new one.
109
+ 3. **Enable APIs:** You need to turn on the specific Google services this server uses.
110
+ - In the search bar at the top, type "APIs & Services" and select "Library".
111
+ - Search for "**Google Docs API**" and click on it. Then click the "**ENABLE**" button.
112
+ - Search for "**Google Sheets API**" and click on it. Then click the "**ENABLE**" button.
113
+ - Search for "**Google Drive API**" and click on it. Then click the "**ENABLE**" button (this is often needed for finding files or permissions).
114
+ 4. **Configure OAuth Consent Screen:** This screen tells users (usually just you) what your app wants permission for.
115
+ - On the left menu, click "APIs & Services" -> "**OAuth consent screen**".
116
+ - Choose User Type: Select "**External**" and click "CREATE".
117
+ - Fill in App Information:
118
+ - **App name:** Give it a name users will see (e.g., "Claude Docs MCP Access").
119
+ - **User support email:** Select your email address.
120
+ - **Developer contact information:** Enter your email address.
121
+ - Click "**SAVE AND CONTINUE**".
122
+ - **Scopes:** Click "**ADD OR REMOVE SCOPES**". Search for and add the following scopes:
123
+ - `https://www.googleapis.com/auth/documents` (Allows reading/writing docs)
124
+ - `https://www.googleapis.com/auth/spreadsheets` (Allows reading/writing spreadsheets)
125
+ - `https://www.googleapis.com/auth/drive.file` (Allows access to specific files opened/created by the app)
126
+ - Click "**UPDATE**".
127
+ - Click "**SAVE AND CONTINUE**".
128
+ - **Test Users:** Click "**ADD USERS**". Enter the same Google email address you are logged in with. Click "**ADD**". This allows _you_ to use the app while it's in "testing" mode.
129
+ - Click "**SAVE AND CONTINUE**". Review the summary and click "**BACK TO DASHBOARD**".
130
+ 5. **Create Credentials (The Keys!):**
131
+ - On the left menu, click "APIs & Services" -> "**Credentials**".
132
+ - Click "**+ CREATE CREDENTIALS**" at the top and choose "**OAuth client ID**".
133
+ - **Application type:** Select "**Desktop app**" from the dropdown.
134
+ - **Name:** Give it a name (e.g., "MCP Docs Desktop Client").
135
+ - Click "**CREATE**".
136
+ 6. **⬇️ DOWNLOAD THE CREDENTIALS FILE:** A box will pop up showing your Client ID. Click the "**DOWNLOAD JSON**" button.
137
+ - Save this file. It will likely be named something like `client_secret_....json`.
138
+ - **IMPORTANT:** Rename the downloaded file to exactly `credentials.json`.
139
+ 7. ⚠️ **SECURITY WARNING:** Treat this `credentials.json` file like a password! Do not share it publicly, and **never commit it to GitHub.** Anyone with this file could potentially pretend to be _your application_ (though they'd still need user consent to access data).
140
+
141
+ ### Step 2: Get the Server Code
142
+
143
+ 1. **Clone the Repository:** Open your terminal/command prompt and run:
144
+ ```bash
145
+ git clone https://github.com/starfysh-tech/gdrive-mcp.git gdrive-mcp
146
+ ```
147
+ 2. **Navigate into Directory:**
148
+ ```bash
149
+ cd gdrive-mcp
150
+ ```
151
+ 3. **Place Credentials:** Move or copy the `credentials.json` file you downloaded and renamed (from Step 1.6) directly into this `gdrive-mcp` folder.
152
+
153
+ ### Step 3: Install Dependencies
154
+
155
+ Your server needs some helper libraries specified in the `package.json` file.
156
+
157
+ 1. In your terminal (make sure you are inside the `gdrive-mcp` directory), run:
158
+ ```bash
159
+ npm install
160
+ ```
161
+ This will download and install all the necessary packages into a `node_modules` folder.
162
+
163
+ ### Step 4: Build the Server Code
164
+
165
+ The server is written in TypeScript (`.ts`), but we need to compile it into JavaScript (`.js`) that Node.js can run directly.
166
+
167
+ 1. In your terminal, run:
168
+ ```bash
169
+ npm run build
170
+ ```
171
+ This uses the TypeScript compiler (`tsc`) to create a `dist` folder containing the compiled JavaScript files.
172
+
173
+ ### Step 5: First Run & Google Authorization (One Time Only)
174
+
175
+ Now you need to run the server once manually to grant it permission to access your Google account data. This will create a `token.json` file that saves your permission grant.
176
+
177
+ 1. In your terminal, run the _compiled_ server using `node`:
178
+ ```bash
179
+ node ./dist/server.js
180
+ ```
181
+ 2. **Watch the Terminal:** The script will print:
182
+ - Status messages (like "Attempting to authorize...").
183
+ - An "Authorize this app by visiting this url:" message followed by a long `https://accounts.google.com/...` URL.
184
+ 3. **Authorize in Browser:**
185
+ - Copy the entire long URL from the terminal.
186
+ - Paste the URL into your web browser and press Enter.
187
+ - Log in with the **same Google account** you added as a Test User in Step 1.4.
188
+ - Google will show a screen asking for permission for your app ("Claude Docs MCP Access" or similar) to access Google Docs, Sheets, and Drive. Review and click "**Allow**" or "**Grant**".
189
+ 4. **Get the Authorization Code:**
190
+ - After clicking Allow, your browser will likely try to redirect to `http://localhost` and show a **"This site can't be reached" error**. **THIS IS NORMAL!**
191
+ - Look **carefully** at the URL in your browser's address bar. It will look like `http://localhost/?code=4/0Axxxxxxxxxxxxxx&scope=...`
192
+ - Copy the long string of characters **between `code=` and the `&scope` part**. This is your single-use authorization code.
193
+ 5. **Paste Code into Terminal:** Go back to your terminal where the script is waiting ("Enter the code from that page here:"). Paste the code you just copied.
194
+ 6. **Press Enter.**
195
+ 7. **Success!** The script should print:
196
+ - "Authentication successful!"
197
+ - "Token stored to .../token.json"
198
+ - It will then finish starting and likely print "Awaiting MCP client connection via stdio..." or similar, and then exit (or you can press `Ctrl+C` to stop it).
199
+ 8. βœ… **Check:** You should now see a new file named `token.json` in your `gdrive-mcp` folder.
200
+ 9. ⚠️ **SECURITY WARNING:** This `token.json` file contains the key that allows the server to access your Google account _without_ asking again. Protect it like a password. **Do not commit it to GitHub.** The included `.gitignore` file should prevent this automatically.
201
+
202
+ ### Alternative: Service Account with Domain-Wide Delegation (Enterprise)
203
+
204
+ For Google Workspace organizations that need to access documents across the domain without individual user OAuth flows, you can use a service account with domain-wide delegation.
205
+
206
+ **Prerequisites:**
207
+ - Google Workspace admin access to configure domain-wide delegation
208
+ - A service account with domain-wide delegation enabled
209
+
210
+ **Setup:**
211
+
212
+ 1. **Create a Service Account** in Google Cloud Console:
213
+ - Go to "APIs & Services" β†’ "Credentials" β†’ "Create Credentials" β†’ "Service Account"
214
+ - Download the JSON key file
215
+
216
+ 2. **Enable Domain-Wide Delegation** in Google Workspace Admin Console:
217
+ - Go to Security β†’ API Controls β†’ Domain-wide delegation
218
+ - Add the service account's client ID with the required scopes:
219
+ - `https://www.googleapis.com/auth/documents`
220
+ - `https://www.googleapis.com/auth/drive`
221
+ - `https://www.googleapis.com/auth/spreadsheets`
222
+
223
+ 3. **Configure Environment Variables:**
224
+ ```bash
225
+ # Path to your service account key file
226
+ export SERVICE_ACCOUNT_PATH="/path/to/service-account-key.json"
227
+
228
+ # Email of the user to impersonate (required for domain-wide delegation)
229
+ export GOOGLE_IMPERSONATE_USER="user@yourdomain.com"
230
+ ```
231
+
232
+ 4. **Update Claude Desktop Config** (add environment variables):
233
+ ```json
234
+ {
235
+ "mcpServers": {
236
+ "gdrive-mcp": {
237
+ "command": "node",
238
+ "args": ["/PATH/TO/gdrive-mcp/dist/server.js"],
239
+ "env": {
240
+ "SERVICE_ACCOUNT_PATH": "/path/to/service-account-key.json",
241
+ "GOOGLE_IMPERSONATE_USER": "user@yourdomain.com"
242
+ }
243
+ }
244
+ }
245
+ }
246
+ ```
247
+
248
+ When `GOOGLE_IMPERSONATE_USER` is set, the server will impersonate that user when accessing Google APIs, allowing access to that user's documents and Drive.
249
+
250
+ ### Step 6: Configure Claude Desktop (Optional)
251
+
252
+ If you want to use this server with Claude Desktop, you need to tell Claude how to run it.
253
+
254
+ 1. **Find Your Absolute Path:** You need the full path to the server code.
255
+ - In your terminal, make sure you are still inside the `gdrive-mcp` directory.
256
+ - Run the `pwd` command (on macOS/Linux) or `cd` (on Windows, just displays the path).
257
+ - Copy the full path (e.g., `/Users/yourname/projects/gdrive-mcp` or `C:\Users\yourname\projects\gdrive-mcp`).
258
+ 2. **Locate `mcp_config.json`:** Find Claude's configuration file:
259
+ - **macOS:** `~/Library/Application Support/Claude/mcp_config.json` (You might need to use Finder's "Go" -> "Go to Folder..." menu and paste `~/Library/Application Support/Claude/`)
260
+ - **Windows:** `%APPDATA%\Claude\mcp_config.json` (Paste `%APPDATA%\Claude` into File Explorer's address bar)
261
+ - **Linux:** `~/.config/Claude/mcp_config.json`
262
+ - _If the `Claude` folder or `mcp_config.json` file doesn't exist, create them._
263
+ 3. **Edit `mcp_config.json`:** Open the file in a text editor. Add or modify the `mcpServers` section like this, **replacing `/PATH/TO/YOUR/CLONED/REPO` with the actual absolute path you copied in Step 6.1**:
264
+
265
+ ```json
266
+ {
267
+ "mcpServers": {
268
+ "gdrive-mcp": {
269
+ "command": "node",
270
+ "args": [
271
+ "/PATH/TO/YOUR/CLONED/REPO/gdrive-mcp/dist/server.js"
272
+ ],
273
+ "env": {}
274
+ }
275
+ // Add commas here if you have other servers defined
276
+ }
277
+ // Other Claude settings might be here
278
+ }
279
+ ```
280
+
281
+ - **Make sure the path in `"args"` is correct and absolute!**
282
+ - If the file already existed, carefully merge this entry into the existing `mcpServers` object. Ensure the JSON is valid (check commas!).
283
+
284
+ 4. **Save `mcp_config.json`.**
285
+ 5. **Restart Claude Desktop:** Close Claude completely and reopen it.
286
+
287
+ ---
288
+
289
+ ## Usage with Claude Desktop
290
+
291
+ Once configured, you should be able to use the tools in your chats with Claude:
292
+
293
+ - "Use the `gdrive-mcp` server to read the document with ID `YOUR_GOOGLE_DOC_ID`."
294
+ - "Can you get the content of Google Doc `YOUR_GOOGLE_DOC_ID`?"
295
+ - "Append 'This was added by Claude!' to document `YOUR_GOOGLE_DOC_ID` using the `gdrive-mcp` tool."
296
+
297
+ ### Working with Tabs
298
+
299
+ Google Docs now supports multi-tab documents. This MCP server provides full support for working with tabs:
300
+
301
+ **Listing Tabs:**
302
+
303
+ - "List all tabs in document `YOUR_GOOGLE_DOC_ID` using the `listDocumentTabs` tool."
304
+ - "Show me the tab structure with content summary for document `YOUR_GOOGLE_DOC_ID`."
305
+
306
+ **Reading from Specific Tabs:**
307
+
308
+ - "Read the content from tab `TAB_ID` in document `YOUR_GOOGLE_DOC_ID` using the `readGoogleDoc` tool."
309
+ - "Get the markdown content from tab `TAB_ID` in document `YOUR_GOOGLE_DOC_ID`."
310
+
311
+ **Writing to Specific Tabs:**
312
+
313
+ - "Append 'New content' to tab `TAB_ID` in document `YOUR_GOOGLE_DOC_ID`."
314
+ - "Insert text at index 100 in tab `TAB_ID` of document `YOUR_GOOGLE_DOC_ID`."
315
+ - "Delete content from range 50-100 in tab `TAB_ID` of document `YOUR_GOOGLE_DOC_ID`."
316
+
317
+ **Note:** The following tools support the optional `tabId` parameter:
318
+
319
+ - `readGoogleDoc` - Read from a specific tab
320
+ - `appendToGoogleDoc` - Append to a specific tab
321
+ - `insertText` - Insert text into a specific tab
322
+ - `deleteRange` - Delete content from a specific tab
323
+
324
+ When `tabId` is not specified, operations target the first tab (or the legacy document body for older documents without tabs).
325
+
326
+ ### Advanced Usage Examples:
327
+
328
+ **Google Docs:**
329
+ - **Text Styling**: "Use `applyTextStyle` to make the text 'Important Section' bold and red (#FF0000) in document `YOUR_GOOGLE_DOC_ID`."
330
+ - **Paragraph Styling**: "Use `applyParagraphStyle` to center-align the paragraph containing 'Title Here' in document `YOUR_GOOGLE_DOC_ID`."
331
+ - **Table Creation**: "Insert a 3x4 table at index 500 in document `YOUR_GOOGLE_DOC_ID` using the `insertTable` tool."
332
+ - **Image Insertion**: "Use `insertImageFromUrl` to insert an image from 'https://example.com/image.png' at index 100 in document `YOUR_GOOGLE_DOC_ID`."
333
+ - **Local Image Upload**: "Use `insertLocalImage` to upload '/path/to/image.jpg' and insert it at index 200 in document `YOUR_GOOGLE_DOC_ID`."
334
+ - **Legacy Formatting**: "Use `formatMatchingText` to find the second instance of 'Project Alpha' and make it blue (#0000FF) in doc `YOUR_GOOGLE_DOC_ID`."
335
+
336
+ **Google Sheets:**
337
+ - **Read Data**: "Read range A1:B10 from spreadsheet `YOUR_SPREADSHEET_ID` using `readSpreadsheet`."
338
+ - **Write Data**: "Write data [[1, 2], [3, 4]] to range A1:B2 in spreadsheet `YOUR_SPREADSHEET_ID`."
339
+ - **Append Rows**: "Append rows [[5, 6], [7, 8]] to spreadsheet `YOUR_SPREADSHEET_ID` starting at A1."
340
+ - **Create Spreadsheet**: "Create a new spreadsheet titled 'Sales Data' with initial data [[Name, Amount], [Product A, 100]]."
341
+ - **Get Info**: "Get information about spreadsheet `YOUR_SPREADSHEET_ID` including all sheets."
342
+ - **Add Sheet**: "Add a new sheet named 'Summary' to spreadsheet `YOUR_SPREADSHEET_ID`."
343
+ - **Clear Range**: "Clear the range A1:B10 in spreadsheet `YOUR_SPREADSHEET_ID`."
344
+ - **List Spreadsheets**: "List all my Google Spreadsheets modified in the last 30 days."
345
+
346
+ Remember to replace:
347
+ - `YOUR_GOOGLE_DOC_ID` with the actual ID from a Google Doc's URL (the long string between `/d/` and `/edit`)
348
+ - `YOUR_SPREADSHEET_ID` with the actual ID from a Google Sheet's URL (the long string between `/d/` and `/edit`)
349
+
350
+ Claude will automatically launch your server in the background when needed using the command you provided. You do **not** need to run `node ./dist/server.js` manually anymore.
351
+
352
+ ---
353
+
354
+ ## Image Insertion
355
+
356
+ This server provides two ways to insert images into Google Documents:
357
+
358
+ ### 1. Insert from Public URL (`insertImageFromUrl`)
359
+
360
+ Inserts an image directly from a publicly accessible URL. The image URL must be accessible without authentication.
361
+
362
+ **Parameters:**
363
+
364
+ - `documentId`: The Google Document ID
365
+ - `imageUrl`: Publicly accessible URL (http:// or https://)
366
+ - `index`: Position in the document (1-based indexing)
367
+ - `width` (optional): Image width in points
368
+ - `height` (optional): Image height in points
369
+
370
+ **Example:**
371
+
372
+ ```
373
+ "Insert an image from https://example.com/logo.png at index 100 in document YOUR_DOC_ID"
374
+ ```
375
+
376
+ ### 2. Upload Local Image (`insertLocalImage`)
377
+
378
+ Uploads a local image file to Google Drive and inserts it into the document. This is a two-step process that:
379
+
380
+ 1. Uploads the image to Google Drive (by default to the same folder as the document)
381
+ 2. Makes the image publicly readable
382
+ 3. Inserts the image into the document using its Drive URL
383
+
384
+ **Parameters:**
385
+
386
+ - `documentId`: The Google Document ID
387
+ - `localImagePath`: Absolute path to the local image file
388
+ - `index`: Position in the document (1-based indexing)
389
+ - `width` (optional): Image width in points
390
+ - `height` (optional): Image height in points
391
+ - `uploadToSameFolder` (optional, default: true): If true, uploads to the document's folder; if false, uploads to Drive root
392
+
393
+ **Supported formats:** .jpg, .jpeg, .png, .gif, .bmp, .webp, .svg
394
+
395
+ **Example:**
396
+
397
+ ```
398
+ "Upload and insert the image at /Users/myname/Pictures/chart.png at index 200 in document YOUR_DOC_ID with width 400 and height 300"
399
+ ```
400
+
401
+ **Note:** The uploaded image will be made publicly readable so it can be displayed in the document. The image file will remain in your Google Drive and can be managed separately.
402
+
403
+ ---
404
+
405
+ ## Security & Token Storage
406
+
407
+ - **`.gitignore`:** This repository includes a `.gitignore` file which should prevent you from accidentally committing your sensitive `credentials.json` and `token.json` files. **Do not remove these lines from `.gitignore`**.
408
+ - **Token Storage:** This server stores the Google authorization token (`token.json`) directly in the project folder for simplicity during setup. In production or more security-sensitive environments, consider storing this token more securely, such as using system keychains, encrypted files, or dedicated secret management services.
409
+
410
+ ---
411
+
412
+ ## Testing
413
+
414
+ The multi-tab support features have been thoroughly tested and verified:
415
+
416
+ βœ… **Tested Features:**
417
+
418
+ - `listDocumentTabs` - Lists all tabs with IDs, titles, positions, and content summaries
419
+ - `readGoogleDoc` with `tabId` - Reads specific tabs; backward compatible without `tabId`
420
+ - `appendToGoogleDoc` with `tabId` - Appends to specific tabs without affecting others
421
+ - `insertText` with `tabId` - Inserts text at specific positions in specific tabs
422
+ - `deleteRange` with `tabId` - Deletes content from specific tabs in isolation
423
+ - Multi-tab operations - Sequential operations on different tabs work independently
424
+ - Error handling - Invalid tab IDs return clear, helpful error messages
425
+ - Backward compatibility - Operations without `tabId` default to first tab (legacy documents supported)
426
+
427
+ All tab-related features have been validated with real Google Docs containing multiple tabs, confirming:
428
+
429
+ - Tab isolation (operations on one tab don't affect others)
430
+ - Proper tab ID validation and error messages
431
+ - Correct content retrieval and manipulation per tab
432
+ - Full backward compatibility with single-tab and legacy documents
433
+
434
+ ## Google Sheets Usage
435
+
436
+ ### A1 Notation
437
+
438
+ Google Sheets uses A1 notation to specify ranges. Examples:
439
+ - `A1` - Single cell
440
+ - `A1:B10` - Range from A1 to B10
441
+ - `Sheet1!A1:B10` - Range on a specific sheet named "Sheet1"
442
+ - `A:A` - Entire column A
443
+ - `1:1` - Entire row 1
444
+
445
+ ### Value Input Options
446
+
447
+ When writing data to spreadsheets, you can choose how values are interpreted:
448
+ - **USER_ENTERED** (default): Values are parsed as if typed by a user (formulas work, dates are recognized, etc.)
449
+ - **RAW**: Values are stored exactly as provided (no parsing)
450
+
451
+ ### Example Workflow
452
+
453
+ ```bash
454
+ # 1. Create a new spreadsheet
455
+ "Create a spreadsheet titled 'Monthly Report'"
456
+
457
+ # 2. Write headers
458
+ "Write [[Date, Sales, Expenses]] to range A1:C1 in spreadsheet YOUR_SPREADSHEET_ID"
459
+
460
+ # 3. Append data rows
461
+ "Append rows [[2024-01-01, 1000, 500], [2024-01-02, 1200, 600]] to spreadsheet YOUR_SPREADSHEET_ID starting at A2"
462
+
463
+ # 4. Read the data back
464
+ "Read range A1:C3 from spreadsheet YOUR_SPREADSHEET_ID"
465
+
466
+ # 5. Add a new sheet for analysis
467
+ "Add a new sheet named 'Analysis' to spreadsheet YOUR_SPREADSHEET_ID"
468
+ ```
469
+
470
+ ## Known Limitations
471
+
472
+ While this MCP server provides comprehensive Google Docs, Sheets, and Drive functionality, there are some limitations imposed by the Google APIs themselves:
473
+
474
+ ### Comment Anchoring
475
+
476
+ **Programmatically Created Comments Are Not Anchored**: Comments created via the `addComment` tool appear in the "All Comments" list but are not visibly anchored to specific text in the Google Docs UI. They will show "original content deleted" instead of highlighting the intended text range. This is a limitation of the Google Drive API v3 when working with Google Docs files.
477
+
478
+ - **Workaround**: Comments created manually in the Google Docs UI are properly anchored
479
+ - **Other Operations**: Reply, delete, and list operations work correctly on all comments regardless of how they were created
480
+
481
+ ### Comment Resolution
482
+
483
+ **Resolved Status May Not Persist**: The `resolveComment` tool attempts to mark comments as resolved, but the Drive API v3 does not fully support this operation for Google Docs files. The resolved status may not persist or be visible in the Google Docs UI.
484
+
485
+ - **Workaround**: Resolve comments manually in the Google Docs web interface
486
+
487
+ ### Converted Documents
488
+
489
+ **Limited Support for Converted Documents**: Some Google Docs that were converted from other formats (especially Microsoft Word documents) may not support all Docs API operations. You may encounter errors like "This operation is not supported for this document" when trying to read or modify these files.
490
+
491
+ ## Troubleshooting
492
+
493
+ - **Claude shows "Failed" or "Could not attach":**
494
+ - Double-check the absolute path in `mcp_config.json`.
495
+ - Ensure you ran `npm run build` successfully and the `dist` folder exists.
496
+ - Try running the command from `mcp_config.json` manually in your terminal: `node /PATH/TO/YOUR/CLONED/REPO/gdrive-mcp/dist/server.js`. Look for any errors printed.
497
+ - Check the Claude Desktop logs (see the official MCP debugging guide).
498
+ - Make sure all `console.log` status messages in the server code were changed to `console.error`.
499
+ - **Google Authorization Errors:**
500
+ - Ensure you enabled the correct APIs (Docs, Sheets, Drive).
501
+ - Make sure you added your email as a Test User on the OAuth Consent Screen.
502
+ - Verify the `credentials.json` file is correctly placed in the project root.
503
+ - **If you're upgrading from an older version:** You may need to delete your existing `token.json` file and re-authenticate to grant the new Sheets API scope.
504
+ - **Tab-related Errors:**
505
+ - If you get "Tab with ID not found", use `listDocumentTabs` to see all available tab IDs
506
+ - Ensure you're using the correct tab ID format (typically a short alphanumeric string)
507
+ - Single-tab documents don't require `tabId` - operations work on the document body automatically
508
+
509
+ ---
510
+
511
+ ## About
512
+
513
+ This project is maintained by [Starfysh](https://starfysh.net), providing fractional product and technology leadership for technical founders.
514
+
515
+ Originally forked from [a-bonus/google-docs-mcp](https://github.com/a-bonus/google-docs-mcp).
516
+
517
+ ---
518
+
519
+ ## License
520
+
521
+ This project is licensed under the MIT License - see the `LICENSE` file for details.