@brainwavesio/google-docs-mcp 1.0.0 → 1.1.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/README.md +18 -27
- package/dist/auth.js +313 -0
- package/dist/googleDocsApiHelpers.js +617 -0
- package/dist/googleSheetsApiHelpers.js +356 -0
- package/dist/server.js +2215 -0
- package/dist/types.js +107 -0
- package/package.json +2 -1
- package/.repomix/bundles.json +0 -3
- package/SAMPLE_TASKS.md +0 -230
- package/assets/google.docs.mcp.1.gif +0 -0
- package/claude.md +0 -46
- package/docs/index.html +0 -228
- package/google docs mcp.mp4 +0 -0
- package/pages/pages.md +0 -0
- package/repomix-output.txt.xml +0 -4447
- package/src/auth.ts +0 -228
- package/src/backup/auth.ts.bak +0 -101
- package/src/backup/server.ts.bak +0 -481
- package/src/googleDocsApiHelpers.ts +0 -710
- package/src/googleSheetsApiHelpers.ts +0 -427
- package/src/server.ts +0 -2494
- package/src/types.ts +0 -136
- package/tests/helpers.test.js +0 -164
- package/tests/types.test.js +0 -69
- package/tsconfig.json +0 -17
- package/vscode.md +0 -168
package/dist/types.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// src/types.ts
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
// --- Helper function for hex color validation ---
|
|
4
|
+
export const hexColorRegex = /^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;
|
|
5
|
+
export const validateHexColor = (color) => hexColorRegex.test(color);
|
|
6
|
+
// --- Helper function for Hex to RGB conversion ---
|
|
7
|
+
export function hexToRgbColor(hex) {
|
|
8
|
+
if (!hex)
|
|
9
|
+
return null;
|
|
10
|
+
let hexClean = hex.startsWith('#') ? hex.slice(1) : hex;
|
|
11
|
+
if (hexClean.length === 3) {
|
|
12
|
+
hexClean = hexClean[0] + hexClean[0] + hexClean[1] + hexClean[1] + hexClean[2] + hexClean[2];
|
|
13
|
+
}
|
|
14
|
+
if (hexClean.length !== 6)
|
|
15
|
+
return null;
|
|
16
|
+
const bigint = parseInt(hexClean, 16);
|
|
17
|
+
if (isNaN(bigint))
|
|
18
|
+
return null;
|
|
19
|
+
const r = ((bigint >> 16) & 255) / 255;
|
|
20
|
+
const g = ((bigint >> 8) & 255) / 255;
|
|
21
|
+
const b = (bigint & 255) / 255;
|
|
22
|
+
return { red: r, green: g, blue: b };
|
|
23
|
+
}
|
|
24
|
+
// --- Zod Schema Fragments for Reusability ---
|
|
25
|
+
export const DocumentIdParameter = z.object({
|
|
26
|
+
documentId: z.string().describe('The ID of the Google Document (from the URL).'),
|
|
27
|
+
});
|
|
28
|
+
export const RangeParameters = z.object({
|
|
29
|
+
startIndex: z.number().int().min(1).describe('The starting index of the text range (inclusive, starts from 1).'),
|
|
30
|
+
endIndex: z.number().int().min(1).describe('The ending index of the text range (exclusive).'),
|
|
31
|
+
}).refine(data => data.endIndex > data.startIndex, {
|
|
32
|
+
message: "endIndex must be greater than startIndex",
|
|
33
|
+
path: ["endIndex"],
|
|
34
|
+
});
|
|
35
|
+
export const OptionalRangeParameters = z.object({
|
|
36
|
+
startIndex: z.number().int().min(1).optional().describe('Optional: The starting index of the text range (inclusive, starts from 1). If omitted, might apply to a found element or whole paragraph.'),
|
|
37
|
+
endIndex: z.number().int().min(1).optional().describe('Optional: The ending index of the text range (exclusive). If omitted, might apply to a found element or whole paragraph.'),
|
|
38
|
+
}).refine(data => !data.startIndex || !data.endIndex || data.endIndex > data.startIndex, {
|
|
39
|
+
message: "If both startIndex and endIndex are provided, endIndex must be greater than startIndex",
|
|
40
|
+
path: ["endIndex"],
|
|
41
|
+
});
|
|
42
|
+
export const TextFindParameter = z.object({
|
|
43
|
+
textToFind: z.string().min(1).describe('The exact text string to locate.'),
|
|
44
|
+
matchInstance: z.number().int().min(1).optional().default(1).describe('Which instance of the text to target (1st, 2nd, etc.). Defaults to 1.'),
|
|
45
|
+
});
|
|
46
|
+
// --- Style Parameter Schemas ---
|
|
47
|
+
export const TextStyleParameters = z.object({
|
|
48
|
+
bold: z.boolean().optional().describe('Apply bold formatting.'),
|
|
49
|
+
italic: z.boolean().optional().describe('Apply italic formatting.'),
|
|
50
|
+
underline: z.boolean().optional().describe('Apply underline formatting.'),
|
|
51
|
+
strikethrough: z.boolean().optional().describe('Apply strikethrough formatting.'),
|
|
52
|
+
fontSize: z.number().min(1).optional().describe('Set font size (in points, e.g., 12).'),
|
|
53
|
+
fontFamily: z.string().optional().describe('Set font family (e.g., "Arial", "Times New Roman").'),
|
|
54
|
+
foregroundColor: z.string()
|
|
55
|
+
.refine(validateHexColor, { message: "Invalid hex color format (e.g., #FF0000 or #F00)" })
|
|
56
|
+
.optional()
|
|
57
|
+
.describe('Set text color using hex format (e.g., "#FF0000").'),
|
|
58
|
+
backgroundColor: z.string()
|
|
59
|
+
.refine(validateHexColor, { message: "Invalid hex color format (e.g., #00FF00 or #0F0)" })
|
|
60
|
+
.optional()
|
|
61
|
+
.describe('Set text background color using hex format (e.g., "#FFFF00").'),
|
|
62
|
+
linkUrl: z.string().url().optional().describe('Make the text a hyperlink pointing to this URL.'),
|
|
63
|
+
// clearDirectFormatting: z.boolean().optional().describe('If true, attempts to clear all direct text formatting within the range before applying new styles.') // Harder to implement perfectly
|
|
64
|
+
}).describe("Parameters for character-level text formatting.");
|
|
65
|
+
export const ParagraphStyleParameters = z.object({
|
|
66
|
+
alignment: z.enum(['START', 'END', 'CENTER', 'JUSTIFIED']).optional().describe('Paragraph alignment. START=left for LTR languages, END=right for LTR languages.'),
|
|
67
|
+
indentStart: z.number().min(0).optional().describe('Left indentation in points.'),
|
|
68
|
+
indentEnd: z.number().min(0).optional().describe('Right indentation in points.'),
|
|
69
|
+
spaceAbove: z.number().min(0).optional().describe('Space before the paragraph in points.'),
|
|
70
|
+
spaceBelow: z.number().min(0).optional().describe('Space after the paragraph in points.'),
|
|
71
|
+
namedStyleType: z.enum([
|
|
72
|
+
'NORMAL_TEXT', 'TITLE', 'SUBTITLE',
|
|
73
|
+
'HEADING_1', 'HEADING_2', 'HEADING_3', 'HEADING_4', 'HEADING_5', 'HEADING_6'
|
|
74
|
+
]).optional().describe('Apply a built-in named paragraph style (e.g., HEADING_1).'),
|
|
75
|
+
keepWithNext: z.boolean().optional().describe('Keep this paragraph together with the next one on the same page.'),
|
|
76
|
+
// Borders are more complex, might need separate objects/tools
|
|
77
|
+
// clearDirectFormatting: z.boolean().optional().describe('If true, attempts to clear all direct paragraph formatting within the range before applying new styles.') // Harder to implement perfectly
|
|
78
|
+
}).describe("Parameters for paragraph-level formatting.");
|
|
79
|
+
// --- Combination Schemas for Tools ---
|
|
80
|
+
export const ApplyTextStyleToolParameters = DocumentIdParameter.extend({
|
|
81
|
+
// Target EITHER by range OR by finding text
|
|
82
|
+
target: z.union([
|
|
83
|
+
RangeParameters,
|
|
84
|
+
TextFindParameter
|
|
85
|
+
]).describe("Specify the target range either by start/end indices or by finding specific text."),
|
|
86
|
+
style: TextStyleParameters.refine(styleArgs => Object.values(styleArgs).some(v => v !== undefined), { message: "At least one text style option must be provided." }).describe("The text styling to apply.")
|
|
87
|
+
});
|
|
88
|
+
export const ApplyParagraphStyleToolParameters = DocumentIdParameter.extend({
|
|
89
|
+
// Target EITHER by range OR by finding text (tool logic needs to find paragraph boundaries)
|
|
90
|
+
target: z.union([
|
|
91
|
+
RangeParameters, // User provides paragraph start/end (less likely)
|
|
92
|
+
TextFindParameter, // Find text within paragraph to apply style
|
|
93
|
+
z.object({
|
|
94
|
+
indexWithinParagraph: z.number().int().min(1).describe("An index located anywhere within the target paragraph.")
|
|
95
|
+
})
|
|
96
|
+
]).describe("Specify the target paragraph either by start/end indices, by finding text within it, or by providing an index within it."),
|
|
97
|
+
style: ParagraphStyleParameters.refine(styleArgs => Object.values(styleArgs).some(v => v !== undefined), { message: "At least one paragraph style option must be provided." }).describe("The paragraph styling to apply.")
|
|
98
|
+
});
|
|
99
|
+
// --- Error Class ---
|
|
100
|
+
// Use FastMCP's UserError for client-facing issues
|
|
101
|
+
// Define a custom error for internal issues if needed
|
|
102
|
+
export class NotImplementedError extends Error {
|
|
103
|
+
constructor(message = "This feature is not yet implemented.") {
|
|
104
|
+
super(message);
|
|
105
|
+
this.name = "NotImplementedError";
|
|
106
|
+
}
|
|
107
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brainwavesio/google-docs-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"fastmcp": "^3.24.0",
|
|
31
31
|
"google-auth-library": "^9.15.1",
|
|
32
32
|
"googleapis": "^148.0.0",
|
|
33
|
+
"open": "^10.1.0",
|
|
33
34
|
"zod": "^3.24.2"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
package/.repomix/bundles.json
DELETED
package/SAMPLE_TASKS.md
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
# 15 Powerful Tasks with the Ultimate Google Docs & Drive MCP Server
|
|
2
|
-
|
|
3
|
-
This document showcases practical examples of what you can accomplish with the enhanced Google Docs & Drive MCP Server. These examples demonstrate how AI assistants like Claude can perform sophisticated document formatting, structuring, and file management tasks through the MCP interface.
|
|
4
|
-
|
|
5
|
-
## Document Formatting & Structure Tasks
|
|
6
|
-
|
|
7
|
-
## 1. Create and Format a Document Header
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
Task: "Create a professional document header for my project proposal."
|
|
11
|
-
|
|
12
|
-
Steps:
|
|
13
|
-
1. Insert the title "Project Proposal: AI Integration Strategy" at the beginning of the document
|
|
14
|
-
2. Apply Heading 1 style to the title using applyParagraphStyle
|
|
15
|
-
3. Add a horizontal line below the title
|
|
16
|
-
4. Insert the date and author information
|
|
17
|
-
5. Apply a subtle background color to the header section
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## 2. Generate and Format a Table of Contents
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
Task: "Create a table of contents for my document based on its headings."
|
|
24
|
-
|
|
25
|
-
Steps:
|
|
26
|
-
1. Find all text with Heading styles (1-3) using findParagraphsMatchingStyle
|
|
27
|
-
2. Create a "Table of Contents" section at the beginning of the document
|
|
28
|
-
3. Insert each heading with appropriate indentation based on its level
|
|
29
|
-
4. Format the TOC entries with page numbers and dotted lines
|
|
30
|
-
5. Apply consistent styling to the entire TOC
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## 3. Structure a Document with Consistent Formatting
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
Task: "Apply consistent formatting throughout my document based on content type."
|
|
37
|
-
|
|
38
|
-
Steps:
|
|
39
|
-
1. Format all section headings with applyParagraphStyle (Heading styles, alignment)
|
|
40
|
-
2. Style all bullet points with consistent indentation and formatting
|
|
41
|
-
3. Format code samples with monospace font and background color
|
|
42
|
-
4. Apply consistent paragraph spacing throughout the document
|
|
43
|
-
5. Format all hyperlinks with a consistent color and underline style
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## 4. Create a Professional Table for Data Presentation
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
Task: "Create a formatted comparison table of product features."
|
|
50
|
-
|
|
51
|
-
Steps:
|
|
52
|
-
1. Insert a table with insertTable (5 rows x 4 columns)
|
|
53
|
-
2. Add header row with product names
|
|
54
|
-
3. Add feature rows with consistent formatting
|
|
55
|
-
4. Apply alternating row background colors for readability
|
|
56
|
-
5. Format the header row with bold text and background color
|
|
57
|
-
6. Align numeric columns to the right
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## 5. Prepare a Document for Formal Submission
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
Task: "Format my research paper according to academic guidelines."
|
|
64
|
-
|
|
65
|
-
Steps:
|
|
66
|
-
1. Set the title with centered alignment and appropriate font size
|
|
67
|
-
2. Format all headings according to the required style guide
|
|
68
|
-
3. Apply double spacing to the main text
|
|
69
|
-
4. Insert page numbers with appropriate format
|
|
70
|
-
5. Format citations consistently
|
|
71
|
-
6. Apply indentation to block quotes
|
|
72
|
-
7. Format the bibliography section
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## 6. Create an Executive Summary with Highlights
|
|
76
|
-
|
|
77
|
-
```
|
|
78
|
-
Task: "Create an executive summary that emphasizes key points from my report."
|
|
79
|
-
|
|
80
|
-
Steps:
|
|
81
|
-
1. Insert a page break and create an "Executive Summary" section
|
|
82
|
-
2. Extract and format key points from the document
|
|
83
|
-
3. Apply bullet points for clarity
|
|
84
|
-
4. Highlight critical figures or statistics in bold
|
|
85
|
-
5. Use color to emphasize particularly important points
|
|
86
|
-
6. Format the summary with appropriate spacing and margins
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## 7. Format a Document for Different Audiences
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
Task: "Create two versions of my presentation - one technical and one for executives."
|
|
93
|
-
|
|
94
|
-
Steps:
|
|
95
|
-
1. Duplicate the document content
|
|
96
|
-
2. For the technical version:
|
|
97
|
-
- Add detailed technical sections
|
|
98
|
-
- Include code examples with monospace formatting
|
|
99
|
-
- Use technical terminology
|
|
100
|
-
3. For the executive version:
|
|
101
|
-
- Emphasize business impact with bold and color
|
|
102
|
-
- Simplify technical concepts
|
|
103
|
-
- Add executive summary
|
|
104
|
-
- Use more visual formatting elements
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## 8. Create a Response Form with Structured Fields
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
Task: "Create a form-like document with fields for respondents to complete."
|
|
111
|
-
|
|
112
|
-
Steps:
|
|
113
|
-
1. Create section headers for different parts of the form
|
|
114
|
-
2. Insert tables for structured response areas
|
|
115
|
-
3. Add form fields with clear instructions
|
|
116
|
-
4. Use formatting to distinguish between instructions and response areas
|
|
117
|
-
5. Add checkbox lists using special characters with consistent formatting
|
|
118
|
-
6. Apply consistent spacing and alignment throughout
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## 9. Format a Document with Multi-Level Lists
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
Task: "Create a project plan with properly formatted nested task lists."
|
|
125
|
-
|
|
126
|
-
Steps:
|
|
127
|
-
1. Insert the project title and apply Heading 1 style
|
|
128
|
-
2. Create main project phases with Heading 2 style
|
|
129
|
-
3. For each phase, create a properly formatted numbered list of tasks
|
|
130
|
-
4. Create sub-tasks with indented, properly formatted sub-lists
|
|
131
|
-
5. Apply consistent formatting to all list levels
|
|
132
|
-
6. Format task owners' names in bold
|
|
133
|
-
7. Format dates and deadlines with a consistent style
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
## 10. Prepare a Document with Advanced Layout
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
Task: "Create a newsletter-style document with columns and sections."
|
|
140
|
-
|
|
141
|
-
Steps:
|
|
142
|
-
1. Create a bold, centered title for the newsletter
|
|
143
|
-
2. Insert a horizontal line separator
|
|
144
|
-
3. Create differently formatted sections for:
|
|
145
|
-
- Main article (left-aligned paragraphs)
|
|
146
|
-
- Sidebar content (indented, smaller text)
|
|
147
|
-
- Highlighted quotes (centered, italic)
|
|
148
|
-
4. Insert and format images with captions
|
|
149
|
-
5. Add a formatted footer with contact information
|
|
150
|
-
6. Apply consistent spacing between sections
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
These examples demonstrate the power and flexibility of the enhanced Google Docs & Drive MCP Server, showcasing how AI assistants can help with sophisticated document formatting, structuring, and comprehensive file management tasks.
|
|
154
|
-
|
|
155
|
-
## Google Drive Management Tasks
|
|
156
|
-
|
|
157
|
-
## 11. Organize Project Files Automatically
|
|
158
|
-
|
|
159
|
-
```
|
|
160
|
-
Task: "Set up a complete project structure and organize existing files."
|
|
161
|
-
|
|
162
|
-
Steps:
|
|
163
|
-
1. Create a main project folder using createFolder
|
|
164
|
-
2. Create subfolders for different aspects (Documents, Templates, Archive)
|
|
165
|
-
3. Search for project-related documents using searchGoogleDocs
|
|
166
|
-
4. Move relevant documents to appropriate subfolders with moveFile
|
|
167
|
-
5. Create a project index document listing all resources
|
|
168
|
-
6. Format the index with links to all project documents
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
## 12. Create Document Templates and Generate Reports
|
|
172
|
-
|
|
173
|
-
```
|
|
174
|
-
Task: "Set up a template system and generate standardized reports."
|
|
175
|
-
|
|
176
|
-
Steps:
|
|
177
|
-
1. Create a Templates folder using createFolder
|
|
178
|
-
2. Create template documents with placeholder text ({{DATE}}, {{NAME}}, etc.)
|
|
179
|
-
3. Use createFromTemplate to generate new reports from templates
|
|
180
|
-
4. Apply text replacements to customize each report
|
|
181
|
-
5. Organize generated reports in appropriate folders
|
|
182
|
-
6. Create a tracking document listing all generated reports
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
## 13. Archive and Clean Up Old Documents
|
|
186
|
-
|
|
187
|
-
```
|
|
188
|
-
Task: "Archive outdated documents and organize current files."
|
|
189
|
-
|
|
190
|
-
Steps:
|
|
191
|
-
1. Create an Archive folder for old documents using createFolder
|
|
192
|
-
2. Use getRecentGoogleDocs to find documents older than 90 days
|
|
193
|
-
3. Review and move old documents to Archive using moveFile
|
|
194
|
-
4. Delete unnecessary duplicate files using deleteFile
|
|
195
|
-
5. Rename documents with consistent naming conventions using renameFile
|
|
196
|
-
6. Create an archive index document for reference
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## 14. Duplicate and Distribute Document Sets
|
|
200
|
-
|
|
201
|
-
```
|
|
202
|
-
Task: "Create personalized versions of documents for different teams."
|
|
203
|
-
|
|
204
|
-
Steps:
|
|
205
|
-
1. Create team-specific folders using createFolder
|
|
206
|
-
2. Copy master documents to each team folder using copyFile
|
|
207
|
-
3. Rename copied documents with team-specific names using renameFile
|
|
208
|
-
4. Customize document content for each team using text replacement
|
|
209
|
-
5. Apply team-specific formatting and branding
|
|
210
|
-
6. Create distribution tracking documents
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
## 15. Comprehensive File Management and Reporting
|
|
214
|
-
|
|
215
|
-
```
|
|
216
|
-
Task: "Generate a complete inventory and management report of all documents."
|
|
217
|
-
|
|
218
|
-
Steps:
|
|
219
|
-
1. Use listFolderContents to catalog all folders and their contents
|
|
220
|
-
2. Use getDocumentInfo to gather detailed metadata for each document
|
|
221
|
-
3. Create a master inventory document with all file information
|
|
222
|
-
4. Format the inventory as a searchable table with columns for:
|
|
223
|
-
- Document name and ID
|
|
224
|
-
- Creation and modification dates
|
|
225
|
-
- Owner and last modifier
|
|
226
|
-
- Folder location
|
|
227
|
-
- File size and sharing status
|
|
228
|
-
5. Add summary statistics and organization recommendations
|
|
229
|
-
6. Set up automated folder structures for better organization
|
|
230
|
-
```
|
|
Binary file
|
package/claude.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Google Docs MCP Server
|
|
2
|
-
|
|
3
|
-
FastMCP server with 42 tools for Google Docs, Sheets, and Drive.
|
|
4
|
-
|
|
5
|
-
## Tool Categories
|
|
6
|
-
|
|
7
|
-
| Category | Count | Examples |
|
|
8
|
-
|----------|-------|----------|
|
|
9
|
-
| Docs | 5 | `readGoogleDoc`, `appendToGoogleDoc`, `insertText`, `deleteRange`, `listDocumentTabs` |
|
|
10
|
-
| Formatting | 3 | `applyTextStyle`, `applyParagraphStyle`, `formatMatchingText` |
|
|
11
|
-
| Structure | 7 | `insertTable`, `insertPageBreak`, `insertImageFromUrl`, `insertLocalImage`, `editTableCell`*, `findElement`*, `fixListFormatting`* |
|
|
12
|
-
| Comments | 6 | `listComments`, `getComment`, `addComment`, `replyToComment`, `resolveComment`, `deleteComment` |
|
|
13
|
-
| Sheets | 8 | `readSpreadsheet`, `writeSpreadsheet`, `appendSpreadsheetRows`, `clearSpreadsheetRange`, `createSpreadsheet`, `listGoogleSheets` |
|
|
14
|
-
| Drive | 13 | `listGoogleDocs`, `searchGoogleDocs`, `getDocumentInfo`, `createFolder`, `moveFile`, `copyFile`, `createDocument` |
|
|
15
|
-
|
|
16
|
-
*Not fully implemented
|
|
17
|
-
|
|
18
|
-
## Known Limitations
|
|
19
|
-
|
|
20
|
-
- **Comment anchoring:** Programmatically created comments appear in "All Comments" but aren't visibly anchored to text in the UI
|
|
21
|
-
- **Resolved status:** May not persist in Google Docs UI (Drive API limitation)
|
|
22
|
-
- **editTableCell:** Not implemented (complex cell index calculation)
|
|
23
|
-
- **fixListFormatting:** Experimental, may not work reliably
|
|
24
|
-
|
|
25
|
-
## Parameter Patterns
|
|
26
|
-
|
|
27
|
-
- **Document ID:** Extract from URL: `docs.google.com/document/d/DOCUMENT_ID/edit`
|
|
28
|
-
- **Text targeting:** Use `textToFind` + `matchInstance` OR `startIndex`/`endIndex`
|
|
29
|
-
- **Colors:** Hex format `#RRGGBB` or `#RGB`
|
|
30
|
-
- **Alignment:** `START`, `END`, `CENTER`, `JUSTIFIED` (not LEFT/RIGHT)
|
|
31
|
-
- **Indices:** 1-based, ranges are [start, end)
|
|
32
|
-
- **Tabs:** Optional `tabId` parameter (defaults to first tab)
|
|
33
|
-
|
|
34
|
-
## Source Files (for implementation details)
|
|
35
|
-
|
|
36
|
-
| File | Contains |
|
|
37
|
-
|------|----------|
|
|
38
|
-
| `src/types.ts` | Zod schemas, hex color validation, style parameter definitions |
|
|
39
|
-
| `src/googleDocsApiHelpers.ts` | `findTextRange`, `executeBatchUpdate`, style request builders |
|
|
40
|
-
| `src/googleSheetsApiHelpers.ts` | A1 notation parsing, range operations |
|
|
41
|
-
| `src/server.ts` | All 42 tool definitions with full parameter schemas |
|
|
42
|
-
|
|
43
|
-
## See Also
|
|
44
|
-
|
|
45
|
-
- `README.md` - Setup instructions and usage examples
|
|
46
|
-
- `SAMPLE_TASKS.md` - 15 example workflows
|
package/docs/index.html
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>FastMCP Google Docs Server Docs</title>
|
|
7
|
-
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
8
|
-
<style>
|
|
9
|
-
body { font-family: sans-serif; line-height: 1.6; padding: 20px; }
|
|
10
|
-
pre { background-color: #f4f4f4; padding: 10px; border-radius: 5px; overflow-x: auto; }
|
|
11
|
-
code { font-family: monospace; }
|
|
12
|
-
h1, h2, h3 { border-bottom: 1px solid #eee; padding-bottom: 5px; margin-top: 20px; }
|
|
13
|
-
</style>
|
|
14
|
-
</head>
|
|
15
|
-
<body>
|
|
16
|
-
<div id="content"></div>
|
|
17
|
-
|
|
18
|
-
<script type="text/markdown" id="markdown-content">
|
|
19
|
-
# FastMCP Google Docs Server
|
|
20
|
-
|
|
21
|
-
Connect Claude Desktop (or other MCP clients) to your Google Docs!
|
|
22
|
-
|
|
23
|
-
This server uses the Model Context Protocol (MCP) and the `fastmcp` library to provide tools for reading and appending text to Google Documents. It acts as a bridge, allowing AI assistants like Claude to interact with your documents programmatically.
|
|
24
|
-
|
|
25
|
-
**Features:**
|
|
26
|
-
|
|
27
|
-
- **Read Documents:** Provides a `readGoogleDoc` tool to fetch the text content of a specified Google Doc.
|
|
28
|
-
- **Append to Documents:** Provides an `appendToGoogleDoc` tool to add text to the end of a specified Google Doc.
|
|
29
|
-
- **Google Authentication:** Handles the OAuth 2.0 flow to securely authorize access to your Google Account.
|
|
30
|
-
- **MCP Compliant:** Designed for use with MCP clients like Claude Desktop.
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## Prerequisites
|
|
35
|
-
|
|
36
|
-
Before you start, make sure you have:
|
|
37
|
-
|
|
38
|
-
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).
|
|
39
|
-
2. **Git:** Required for cloning this repository. ([Download Git](https://git-scm.com/downloads)).
|
|
40
|
-
3. **A Google Account:** The account that owns or has access to the Google Docs you want to interact with.
|
|
41
|
-
4. **Command Line Familiarity:** Basic comfort using a terminal or command prompt (like Terminal on macOS/Linux, or Command Prompt/PowerShell on Windows).
|
|
42
|
-
5. **Claude Desktop (Optional):** If your goal is to connect this server to Claude, you'll need the Claude Desktop application installed.
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## Setup Instructions
|
|
47
|
-
|
|
48
|
-
Follow these steps carefully to get your own instance of the server running.
|
|
49
|
-
|
|
50
|
-
### Step 1: Google Cloud Project & Credentials (The Important Bit!)
|
|
51
|
-
|
|
52
|
-
This server needs permission to talk to Google APIs on your behalf. You'll create special "keys" (credentials) that only your server will use.
|
|
53
|
-
|
|
54
|
-
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.
|
|
55
|
-
2. **Create or Select a Project:**
|
|
56
|
-
- 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".
|
|
57
|
-
- If you have existing projects, you can select one or create a new one.
|
|
58
|
-
3. **Enable APIs:** You need to turn on the specific Google services this server uses.
|
|
59
|
-
- In the search bar at the top, type "APIs & Services" and select "Library".
|
|
60
|
-
- Search for "**Google Docs API**" and click on it. Then click the "**ENABLE**" button.
|
|
61
|
-
- Search for "**Google Drive API**" and click on it. Then click the "**ENABLE**" button (this is often needed for finding files or permissions).
|
|
62
|
-
4. **Configure OAuth Consent Screen:** This screen tells users (usually just you) what your app wants permission for.
|
|
63
|
-
- On the left menu, click "APIs & Services" -> "**OAuth consent screen**".
|
|
64
|
-
- Choose User Type: Select "**External**" and click "CREATE".
|
|
65
|
-
- Fill in App Information:
|
|
66
|
-
- **App name:** Give it a name users will see (e.g., "Claude Docs MCP Access").
|
|
67
|
-
- **User support email:** Select your email address.
|
|
68
|
-
- **Developer contact information:** Enter your email address.
|
|
69
|
-
- Click "**SAVE AND CONTINUE**".
|
|
70
|
-
- **Scopes:** Click "**ADD OR REMOVE SCOPES**". Search for and add the following scopes:
|
|
71
|
-
- `https://www.googleapis.com/auth/documents` (Allows reading/writing docs)
|
|
72
|
-
- `https://www.googleapis.com/auth/drive.file` (Allows access to specific files opened/created by the app)
|
|
73
|
-
- Click "**UPDATE**".
|
|
74
|
-
- Click "**SAVE AND CONTINUE**".
|
|
75
|
-
- **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.
|
|
76
|
-
- Click "**SAVE AND CONTINUE**". Review the summary and click "**BACK TO DASHBOARD**".
|
|
77
|
-
5. **Create Credentials (The Keys!):**
|
|
78
|
-
- On the left menu, click "APIs & Services" -> "**Credentials**".
|
|
79
|
-
- Click "**+ CREATE CREDENTIALS**" at the top and choose "**OAuth client ID**".
|
|
80
|
-
- **Application type:** Select "**Desktop app**" from the dropdown.
|
|
81
|
-
- **Name:** Give it a name (e.g., "MCP Docs Desktop Client").
|
|
82
|
-
- Click "**CREATE**".
|
|
83
|
-
6. **⬇️ DOWNLOAD THE CREDENTIALS FILE:** A box will pop up showing your Client ID. Click the "**DOWNLOAD JSON**" button.
|
|
84
|
-
- Save this file. It will likely be named something like `client_secret_....json`.
|
|
85
|
-
- **IMPORTANT:** Rename the downloaded file to exactly `credentials.json`.
|
|
86
|
-
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).
|
|
87
|
-
|
|
88
|
-
### Step 2: Get the Server Code
|
|
89
|
-
|
|
90
|
-
1. **Clone the Repository:** Open your terminal/command prompt and run:
|
|
91
|
-
```bash
|
|
92
|
-
git clone https://github.com/a-bonus/google-docs-mcp.git mcp-googledocs-server
|
|
93
|
-
```
|
|
94
|
-
2. **Navigate into Directory:**
|
|
95
|
-
```bash
|
|
96
|
-
cd mcp-googledocs-server
|
|
97
|
-
```
|
|
98
|
-
3. **Place Credentials:** Move or copy the `credentials.json` file you downloaded and renamed (from Step 1.6) directly into this `mcp-googledocs-server` folder.
|
|
99
|
-
|
|
100
|
-
### Step 3: Install Dependencies
|
|
101
|
-
|
|
102
|
-
Your server needs some helper libraries specified in the `package.json` file.
|
|
103
|
-
|
|
104
|
-
1. In your terminal (make sure you are inside the `mcp-googledocs-server` directory), run:
|
|
105
|
-
```bash
|
|
106
|
-
npm install
|
|
107
|
-
```
|
|
108
|
-
This will download and install all the necessary packages into a `node_modules` folder.
|
|
109
|
-
|
|
110
|
-
### Step 4: Build the Server Code
|
|
111
|
-
|
|
112
|
-
The server is written in TypeScript (`.ts`), but we need to compile it into JavaScript (`.js`) that Node.js can run directly.
|
|
113
|
-
|
|
114
|
-
1. In your terminal, run:
|
|
115
|
-
```bash
|
|
116
|
-
npm run build
|
|
117
|
-
```
|
|
118
|
-
This uses the TypeScript compiler (`tsc`) to create a `dist` folder containing the compiled JavaScript files.
|
|
119
|
-
|
|
120
|
-
### Step 5: First Run & Google Authorization (One Time Only)
|
|
121
|
-
|
|
122
|
-
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.
|
|
123
|
-
|
|
124
|
-
1. In your terminal, run the _compiled_ server using `node`:
|
|
125
|
-
```bash
|
|
126
|
-
node ./dist/server.js
|
|
127
|
-
```
|
|
128
|
-
2. **Watch the Terminal:** The script will print:
|
|
129
|
-
- Status messages (like "Attempting to authorize...").
|
|
130
|
-
- An "Authorize this app by visiting this url:" message followed by a long `https://accounts.google.com/...` URL.
|
|
131
|
-
3. **Authorize in Browser:**
|
|
132
|
-
- Copy the entire long URL from the terminal.
|
|
133
|
-
- Paste the URL into your web browser and press Enter.
|
|
134
|
-
- Log in with the **same Google account** you added as a Test User in Step 1.4.
|
|
135
|
-
- Google will show a screen asking for permission for your app ("Claude Docs MCP Access" or similar) to access Google Docs/Drive. Review and click "**Allow**" or "**Grant**".
|
|
136
|
-
4. **Get the Authorization Code:**
|
|
137
|
-
- 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!**
|
|
138
|
-
- Look **carefully** at the URL in your browser's address bar. It will look like `http://localhost/?code=4/0Axxxxxxxxxxxxxx&scope=...`
|
|
139
|
-
- Copy the long string of characters **between `code=` and the `&scope` part**. This is your single-use authorization code.
|
|
140
|
-
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.
|
|
141
|
-
6. **Press Enter.**
|
|
142
|
-
7. **Success!** The script should print:
|
|
143
|
-
- "Authentication successful!"
|
|
144
|
-
- "Token stored to .../token.json"
|
|
145
|
-
- 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).
|
|
146
|
-
8. ✅ **Check:** You should now see a new file named `token.json` in your `mcp-googledocs-server` folder.
|
|
147
|
-
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.
|
|
148
|
-
|
|
149
|
-
### Step 6: Configure Claude Desktop (Optional)
|
|
150
|
-
|
|
151
|
-
If you want to use this server with Claude Desktop, you need to tell Claude how to run it.
|
|
152
|
-
|
|
153
|
-
1. **Find Your Absolute Path:** You need the full path to the server code.
|
|
154
|
-
- In your terminal, make sure you are still inside the `mcp-googledocs-server` directory.
|
|
155
|
-
- Run the `pwd` command (on macOS/Linux) or `cd` (on Windows, just displays the path).
|
|
156
|
-
- Copy the full path (e.g., `/Users/yourname/projects/mcp-googledocs-server` or `C:\Users\yourname\projects\mcp-googledocs-server`).
|
|
157
|
-
2. **Locate `mcp_config.json`:** Find Claude's configuration file:
|
|
158
|
-
- **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/`)
|
|
159
|
-
- **Windows:** `%APPDATA%\Claude\mcp_config.json` (Paste `%APPDATA%\Claude` into File Explorer's address bar)
|
|
160
|
-
- **Linux:** `~/.config/Claude/mcp_config.json`
|
|
161
|
-
- _If the `Claude` folder or `mcp_config.json` file doesn't exist, create them._
|
|
162
|
-
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**:
|
|
163
|
-
|
|
164
|
-
```json
|
|
165
|
-
{
|
|
166
|
-
"mcpServers": {
|
|
167
|
-
"google-docs-mcp": {
|
|
168
|
-
"command": "node",
|
|
169
|
-
"args": [
|
|
170
|
-
"/PATH/TO/YOUR/CLONED/REPO/mcp-googledocs-server/dist/server.js"
|
|
171
|
-
],
|
|
172
|
-
"env": {}
|
|
173
|
-
}
|
|
174
|
-
// Add commas here if you have other servers defined
|
|
175
|
-
}
|
|
176
|
-
// Other Claude settings might be here
|
|
177
|
-
}
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
- **Make sure the path in `"args"` is correct and absolute!**
|
|
181
|
-
- If the file already existed, carefully merge this entry into the existing `mcpServers` object. Ensure the JSON is valid (check commas!).
|
|
182
|
-
|
|
183
|
-
4. **Save `mcp_config.json`.**
|
|
184
|
-
5. **Restart Claude Desktop:** Close Claude completely and reopen it.
|
|
185
|
-
|
|
186
|
-
---
|
|
187
|
-
|
|
188
|
-
## Usage with Claude Desktop
|
|
189
|
-
|
|
190
|
-
Once configured, you should be able to use the tools in your chats with Claude:
|
|
191
|
-
|
|
192
|
-
- "Use the `google-docs-mcp` server to read the document with ID `YOUR_GOOGLE_DOC_ID`."
|
|
193
|
-
- "Can you get the content of Google Doc `YOUR_GOOGLE_DOC_ID`?"
|
|
194
|
-
- "Append 'This was added by Claude!' to document `YOUR_GOOGLE_DOC_ID` using the `google-docs-mcp` tool."
|
|
195
|
-
|
|
196
|
-
Remember to replace `YOUR_GOOGLE_DOC_ID` with the actual ID from a Google Doc's URL (the long string between `/d/` and `/edit`).
|
|
197
|
-
|
|
198
|
-
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.
|
|
199
|
-
|
|
200
|
-
---
|
|
201
|
-
|
|
202
|
-
## Security & Token Storage
|
|
203
|
-
|
|
204
|
-
- **`.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`**.
|
|
205
|
-
- **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.
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## Troubleshooting
|
|
210
|
-
|
|
211
|
-
- **Claude shows "Failed" or "Could not attach":**
|
|
212
|
-
- Double-check the absolute path in `mcp_config.json`.
|
|
213
|
-
- Ensure you ran `npm run build` successfully and the `dist` folder exists.
|
|
214
|
-
- Try running the command from `mcp_config.json` manually in your terminal: `node /PATH/TO/YOUR/CLONED/REPO/mcp-googledocs-server/dist/server.js`. Look for any errors printed.
|
|
215
|
-
- Check the Claude Desktop logs (see the official MCP debugging guide).
|
|
216
|
-
- Make sure all `console.log` status messages in the server code were changed to `console.error`.
|
|
217
|
-
- **Google Authorization Errors:**
|
|
218
|
-
- Ensure you enabled the correct APIs (Docs, Drive).
|
|
219
|
-
- Make sure you added your email as a Test User on the OAuth Consent Screen.
|
|
220
|
-
- Verify the `credentials.json` file is correctly placed in the project root.
|
|
221
|
-
|
|
222
|
-
---
|
|
223
|
-
|
|
224
|
-
## License
|
|
225
|
-
|
|
226
|
-
This project is licensed under the MIT License - see the `LICENSE` file for details. (Note: You should add a `LICENSE` file containing the MIT License text to your repository).
|
|
227
|
-
|
|
228
|
-
---
|
package/google docs mcp.mp4
DELETED
|
Binary file
|
package/pages/pages.md
DELETED
|
File without changes
|