@piotr-agier/google-drive-mcp 1.3.2 → 1.3.3
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/dist/index.js +67 -28
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1861,7 +1861,8 @@ var DeleteRangeSchema = z2.object({
|
|
|
1861
1861
|
var ReadGoogleDocSchema = z2.object({
|
|
1862
1862
|
documentId: z2.string().min(1, "Document ID is required"),
|
|
1863
1863
|
format: z2.enum(["text", "json", "markdown"]).optional().default("text"),
|
|
1864
|
-
maxLength: z2.number().int().min(1).optional()
|
|
1864
|
+
maxLength: z2.number().int().min(1).optional(),
|
|
1865
|
+
tabId: z2.string().optional()
|
|
1865
1866
|
});
|
|
1866
1867
|
var ListDocumentTabsSchema = z2.object({
|
|
1867
1868
|
documentId: z2.string().min(1, "Document ID is required"),
|
|
@@ -2018,13 +2019,14 @@ var toolDefinitions2 = [
|
|
|
2018
2019
|
},
|
|
2019
2020
|
{
|
|
2020
2021
|
name: "readGoogleDoc",
|
|
2021
|
-
description: "Read content of a Google Doc with format options",
|
|
2022
|
+
description: "Read content of a Google Doc with format options. Supports multi-tab documents.",
|
|
2022
2023
|
inputSchema: {
|
|
2023
2024
|
type: "object",
|
|
2024
2025
|
properties: {
|
|
2025
2026
|
documentId: { type: "string", description: "The document ID" },
|
|
2026
2027
|
format: { type: "string", enum: ["text", "json", "markdown"], description: "Output format (default: text)" },
|
|
2027
|
-
maxLength: { type: "number", description: "Maximum characters to return" }
|
|
2028
|
+
maxLength: { type: "number", description: "Maximum characters to return" },
|
|
2029
|
+
tabId: { type: "string", description: "Read a specific tab by ID (from listDocumentTabs). If omitted, all tabs are returned." }
|
|
2028
2030
|
},
|
|
2029
2031
|
required: ["documentId"]
|
|
2030
2032
|
}
|
|
@@ -2588,6 +2590,36 @@ Total length: ${totalLength} characters`
|
|
|
2588
2590
|
};
|
|
2589
2591
|
}
|
|
2590
2592
|
case "readGoogleDoc": {
|
|
2593
|
+
let extractText2 = function(bodyContent) {
|
|
2594
|
+
let result = "";
|
|
2595
|
+
for (const element of bodyContent) {
|
|
2596
|
+
if (element.paragraph?.elements) {
|
|
2597
|
+
for (const elem of element.paragraph.elements) {
|
|
2598
|
+
if (elem.textRun?.content) {
|
|
2599
|
+
result += elem.textRun.content;
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
} else if (element.table) {
|
|
2603
|
+
for (const row of element.table.tableRows || []) {
|
|
2604
|
+
for (const cell of row.tableCells || []) {
|
|
2605
|
+
for (const cellContent of cell.content || []) {
|
|
2606
|
+
if (cellContent.paragraph?.elements) {
|
|
2607
|
+
for (const elem of cellContent.paragraph.elements) {
|
|
2608
|
+
if (elem.textRun?.content) {
|
|
2609
|
+
result += elem.textRun.content;
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
result += " ";
|
|
2615
|
+
}
|
|
2616
|
+
result += "\n";
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
return result;
|
|
2621
|
+
};
|
|
2622
|
+
var extractText = extractText2;
|
|
2591
2623
|
const validation = ReadGoogleDocSchema.safeParse(args);
|
|
2592
2624
|
if (!validation.success) {
|
|
2593
2625
|
return errorResponse(validation.error.errors[0].message);
|
|
@@ -2595,7 +2627,8 @@ Total length: ${totalLength} characters`
|
|
|
2595
2627
|
const a = validation.data;
|
|
2596
2628
|
const docs = ctx.google.docs({ version: "v1", auth: ctx.authClient });
|
|
2597
2629
|
const docResponse = await docs.documents.get({
|
|
2598
|
-
documentId: a.documentId
|
|
2630
|
+
documentId: a.documentId,
|
|
2631
|
+
includeTabsContent: true
|
|
2599
2632
|
});
|
|
2600
2633
|
const doc = docResponse.data;
|
|
2601
2634
|
const format = a.format || "text";
|
|
@@ -2610,33 +2643,39 @@ Total length: ${totalLength} characters`
|
|
|
2610
2643
|
};
|
|
2611
2644
|
}
|
|
2612
2645
|
let text = "";
|
|
2613
|
-
const
|
|
2614
|
-
if (
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
}
|
|
2633
|
-
}
|
|
2634
|
-
text += " ";
|
|
2635
|
-
}
|
|
2636
|
-
text += "\n";
|
|
2646
|
+
const tabs = doc.tabs;
|
|
2647
|
+
if (tabs && tabs.length > 0) {
|
|
2648
|
+
if (a.tabId) {
|
|
2649
|
+
const tab = tabs.find((t) => t.tabProperties?.tabId === a.tabId);
|
|
2650
|
+
if (!tab) {
|
|
2651
|
+
return errorResponse(`Tab with ID "${a.tabId}" not found. Use listDocumentTabs to see available tabs.`);
|
|
2652
|
+
}
|
|
2653
|
+
const bodyContent = tab.documentTab?.body?.content;
|
|
2654
|
+
if (bodyContent) {
|
|
2655
|
+
text = extractText2(bodyContent);
|
|
2656
|
+
}
|
|
2657
|
+
} else if (tabs.length > 1) {
|
|
2658
|
+
for (const tab of tabs) {
|
|
2659
|
+
const title = tab.tabProperties?.title || "Untitled";
|
|
2660
|
+
text += `=== Tab: ${title} ===
|
|
2661
|
+
`;
|
|
2662
|
+
const bodyContent = tab.documentTab?.body?.content;
|
|
2663
|
+
if (bodyContent) {
|
|
2664
|
+
text += extractText2(bodyContent);
|
|
2637
2665
|
}
|
|
2666
|
+
text += "\n";
|
|
2667
|
+
}
|
|
2668
|
+
} else {
|
|
2669
|
+
const bodyContent = tabs[0].documentTab?.body?.content;
|
|
2670
|
+
if (bodyContent) {
|
|
2671
|
+
text = extractText2(bodyContent);
|
|
2638
2672
|
}
|
|
2639
2673
|
}
|
|
2674
|
+
} else {
|
|
2675
|
+
const body = doc.body;
|
|
2676
|
+
if (body?.content) {
|
|
2677
|
+
text = extractText2(body.content);
|
|
2678
|
+
}
|
|
2640
2679
|
}
|
|
2641
2680
|
if (format === "markdown") {
|
|
2642
2681
|
text = `# ${doc.title}
|