sad-mcp 0.1.11 → 0.1.12

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/drive.d.ts CHANGED
@@ -7,5 +7,6 @@ export interface DriveFile {
7
7
  modifiedTime?: string;
8
8
  }
9
9
  export declare function listAllFiles(): Promise<DriveFile[]>;
10
+ export declare function isGoogleWorkspaceFile(file: DriveFile): boolean;
10
11
  export declare function downloadFile(file: DriveFile): Promise<Buffer>;
11
12
  export declare function categorizeFile(file: DriveFile): string;
package/dist/drive.js CHANGED
@@ -80,6 +80,15 @@ export async function listAllFiles() {
80
80
  saveCacheIndex(index);
81
81
  return files;
82
82
  }
83
+ // Google Workspace mimeTypes that need export (not direct download)
84
+ const EXPORT_MIME_MAP = {
85
+ "application/vnd.google-apps.presentation": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
86
+ "application/vnd.google-apps.document": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
87
+ "application/vnd.google-apps.spreadsheet": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
88
+ };
89
+ export function isGoogleWorkspaceFile(file) {
90
+ return file.mimeType in EXPORT_MIME_MAP;
91
+ }
83
92
  export async function downloadFile(file) {
84
93
  const index = loadCacheIndex();
85
94
  const cached = index.files[file.id];
@@ -88,9 +97,18 @@ export async function downloadFile(file) {
88
97
  return readFileSync(cached.localPath);
89
98
  }
90
99
  const drive = await getDrive();
91
- // Download the file
92
- const res = await drive.files.get({ fileId: file.id, alt: "media" }, { responseType: "arraybuffer" });
93
- const buffer = Buffer.from(res.data);
100
+ let buffer;
101
+ // Google Workspace files need export, not direct download
102
+ const exportMime = EXPORT_MIME_MAP[file.mimeType];
103
+ if (exportMime) {
104
+ const res = await drive.files.export({ fileId: file.id, mimeType: exportMime }, { responseType: "arraybuffer" });
105
+ buffer = Buffer.from(res.data);
106
+ }
107
+ else {
108
+ // Regular file — direct download
109
+ const res = await drive.files.get({ fileId: file.id, alt: "media" }, { responseType: "arraybuffer" });
110
+ buffer = Buffer.from(res.data);
111
+ }
94
112
  // Cache locally
95
113
  mkdirSync(CACHE_DIR, { recursive: true });
96
114
  const sanitizedName = file.path.replace(/[/\\:*?"<>|]/g, "_");
@@ -1,3 +1,3 @@
1
- import type { DriveFile } from "./drive.js";
1
+ import { type DriveFile } from "./drive.js";
2
2
  export declare function extractText(file: DriveFile, buffer: Buffer): Promise<string>;
3
3
  export declare function isExtractable(file: DriveFile): boolean;
@@ -1,5 +1,6 @@
1
1
  import officeparser from "officeparser";
2
2
  import pdf from "pdf-parse";
3
+ import { isGoogleWorkspaceFile } from "./drive.js";
3
4
  // pdf-parse uses console.log('Warning: ...') internally, which writes to stdout
4
5
  // and corrupts the MCP JSON-RPC transport. Redirect console.log to stderr during parsing.
5
6
  function withSilentStdout(fn) {
@@ -18,8 +19,15 @@ function withSilentStdout(fn) {
18
19
  throw e;
19
20
  }
20
21
  }
22
+ // Map Google Workspace mimeTypes to their exported Office equivalents
23
+ const GOOGLE_MIME_TO_OFFICE = {
24
+ "application/vnd.google-apps.presentation": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
25
+ "application/vnd.google-apps.document": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
26
+ "application/vnd.google-apps.spreadsheet": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
27
+ };
21
28
  export async function extractText(file, buffer) {
22
- const mimeType = file.mimeType;
29
+ // After export, Google Workspace files arrive in Office format — use that mimeType
30
+ const mimeType = GOOGLE_MIME_TO_OFFICE[file.mimeType] || file.mimeType;
23
31
  const name = file.name.toLowerCase();
24
32
  // Plain text files — return as-is
25
33
  if (mimeType === "text/plain" ||
@@ -81,5 +89,7 @@ export function isExtractable(file) {
81
89
  name.endsWith(".pdf") ||
82
90
  name.endsWith(".pptx") ||
83
91
  name.endsWith(".docx") ||
84
- name.endsWith(".xlsx"));
92
+ name.endsWith(".xlsx") ||
93
+ isGoogleWorkspaceFile(file) // Google Slides, Docs, Sheets — exported then extracted
94
+ );
85
95
  }
package/dist/tools.js CHANGED
@@ -25,8 +25,8 @@ async function ensureTextCache() {
25
25
  textCache.set(file.id, { file, text });
26
26
  saveTextEntry(file.id, { modifiedTime: file.modifiedTime, text });
27
27
  }
28
- catch {
29
- // Skip files that fail to download/extract
28
+ catch (err) {
29
+ console.error(`[sad-mcp] Failed to process "${file.name}": ${err instanceof Error ? err.message : String(err)}`);
30
30
  }
31
31
  }
32
32
  }
package/dist/tracking.js CHANGED
@@ -4,7 +4,7 @@ import { homedir } from "os";
4
4
  import { randomUUID } from "crypto";
5
5
  const CONFIG_DIR = join(homedir(), ".sad-mcp");
6
6
  const ANON_ID_PATH = join(CONFIG_DIR, "anonymous-id.txt");
7
- const VERSION = "0.1.11";
7
+ const VERSION = "0.1.12";
8
8
  const WEBHOOK_URL = "https://script.google.com/macros/s/AKfycbxGraOdki3CUMz6Ch9u17qt_9P01nTAsWeZZN_wrOL9mRUosNriXZmBdEG5RTS2cCjr/exec";
9
9
  // Session ID — unique per server process lifetime
10
10
  const sessionId = randomUUID().slice(0, 8);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sad-mcp",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "MCP server for Software Analysis and Design course materials at BGU",
5
5
  "type": "module",
6
6
  "bin": {