@mcp-z/mcp-drive 1.1.3 → 1.2.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.
Files changed (93) hide show
  1. package/dist/cjs/index.js.map +1 -1
  2. package/dist/cjs/lib/google-auth.d.cts +9 -0
  3. package/dist/cjs/lib/google-auth.d.ts +9 -0
  4. package/dist/cjs/lib/google-auth.js +16 -0
  5. package/dist/cjs/lib/google-auth.js.map +1 -0
  6. package/dist/cjs/mcp/prompts/query-syntax.d.cts +2 -3
  7. package/dist/cjs/mcp/prompts/query-syntax.d.ts +2 -3
  8. package/dist/cjs/mcp/prompts/query-syntax.js.map +1 -1
  9. package/dist/cjs/mcp/resources/file.d.cts +2 -9
  10. package/dist/cjs/mcp/resources/file.d.ts +2 -9
  11. package/dist/cjs/mcp/resources/file.js +8 -6
  12. package/dist/cjs/mcp/resources/file.js.map +1 -1
  13. package/dist/cjs/mcp/tools/file-move-to-trash.d.cts +1 -1
  14. package/dist/cjs/mcp/tools/file-move-to-trash.d.ts +1 -1
  15. package/dist/cjs/mcp/tools/file-move-to-trash.js +9 -7
  16. package/dist/cjs/mcp/tools/file-move-to-trash.js.map +1 -1
  17. package/dist/cjs/mcp/tools/file-move.d.cts +1 -1
  18. package/dist/cjs/mcp/tools/file-move.d.ts +1 -1
  19. package/dist/cjs/mcp/tools/file-move.js +15 -10
  20. package/dist/cjs/mcp/tools/file-move.js.map +1 -1
  21. package/dist/cjs/mcp/tools/file-upload.d.cts +1 -1
  22. package/dist/cjs/mcp/tools/file-upload.d.ts +1 -1
  23. package/dist/cjs/mcp/tools/file-upload.js +9 -7
  24. package/dist/cjs/mcp/tools/file-upload.js.map +1 -1
  25. package/dist/cjs/mcp/tools/files-search.d.cts +1 -1
  26. package/dist/cjs/mcp/tools/files-search.d.ts +1 -1
  27. package/dist/cjs/mcp/tools/files-search.js +14 -8
  28. package/dist/cjs/mcp/tools/files-search.js.map +1 -1
  29. package/dist/cjs/mcp/tools/folder-contents.d.cts +1 -1
  30. package/dist/cjs/mcp/tools/folder-contents.d.ts +1 -1
  31. package/dist/cjs/mcp/tools/folder-contents.js +14 -8
  32. package/dist/cjs/mcp/tools/folder-contents.js.map +1 -1
  33. package/dist/cjs/mcp/tools/folder-create.d.cts +1 -1
  34. package/dist/cjs/mcp/tools/folder-create.d.ts +1 -1
  35. package/dist/cjs/mcp/tools/folder-create.js +11 -8
  36. package/dist/cjs/mcp/tools/folder-create.js.map +1 -1
  37. package/dist/cjs/mcp/tools/folder-path.d.cts +1 -1
  38. package/dist/cjs/mcp/tools/folder-path.d.ts +1 -1
  39. package/dist/cjs/mcp/tools/folder-path.js +9 -7
  40. package/dist/cjs/mcp/tools/folder-path.js.map +1 -1
  41. package/dist/cjs/mcp/tools/folder-search.d.cts +1 -1
  42. package/dist/cjs/mcp/tools/folder-search.d.ts +1 -1
  43. package/dist/cjs/mcp/tools/folder-search.js +18 -10
  44. package/dist/cjs/mcp/tools/folder-search.js.map +1 -1
  45. package/dist/cjs/setup/http.d.cts +0 -2
  46. package/dist/cjs/setup/http.d.ts +0 -2
  47. package/dist/cjs/setup/http.js +18 -11
  48. package/dist/cjs/setup/http.js.map +1 -1
  49. package/dist/cjs/setup/stdio.d.cts +0 -2
  50. package/dist/cjs/setup/stdio.d.ts +0 -2
  51. package/dist/cjs/setup/stdio.js +18 -11
  52. package/dist/cjs/setup/stdio.js.map +1 -1
  53. package/dist/esm/index.js +1 -1
  54. package/dist/esm/index.js.map +1 -1
  55. package/dist/esm/lib/google-auth.d.ts +9 -0
  56. package/dist/esm/lib/google-auth.js +11 -0
  57. package/dist/esm/lib/google-auth.js.map +1 -0
  58. package/dist/esm/mcp/prompts/query-syntax.d.ts +2 -3
  59. package/dist/esm/mcp/prompts/query-syntax.js.map +1 -1
  60. package/dist/esm/mcp/resources/file.d.ts +2 -9
  61. package/dist/esm/mcp/resources/file.js +7 -5
  62. package/dist/esm/mcp/resources/file.js.map +1 -1
  63. package/dist/esm/mcp/tools/file-move-to-trash.d.ts +1 -1
  64. package/dist/esm/mcp/tools/file-move-to-trash.js +9 -7
  65. package/dist/esm/mcp/tools/file-move-to-trash.js.map +1 -1
  66. package/dist/esm/mcp/tools/file-move.d.ts +1 -1
  67. package/dist/esm/mcp/tools/file-move.js +15 -10
  68. package/dist/esm/mcp/tools/file-move.js.map +1 -1
  69. package/dist/esm/mcp/tools/file-upload.d.ts +1 -1
  70. package/dist/esm/mcp/tools/file-upload.js +9 -7
  71. package/dist/esm/mcp/tools/file-upload.js.map +1 -1
  72. package/dist/esm/mcp/tools/files-search.d.ts +1 -1
  73. package/dist/esm/mcp/tools/files-search.js +15 -9
  74. package/dist/esm/mcp/tools/files-search.js.map +1 -1
  75. package/dist/esm/mcp/tools/folder-contents.d.ts +1 -1
  76. package/dist/esm/mcp/tools/folder-contents.js +15 -9
  77. package/dist/esm/mcp/tools/folder-contents.js.map +1 -1
  78. package/dist/esm/mcp/tools/folder-create.d.ts +1 -1
  79. package/dist/esm/mcp/tools/folder-create.js +11 -8
  80. package/dist/esm/mcp/tools/folder-create.js.map +1 -1
  81. package/dist/esm/mcp/tools/folder-path.d.ts +1 -1
  82. package/dist/esm/mcp/tools/folder-path.js +9 -7
  83. package/dist/esm/mcp/tools/folder-path.js.map +1 -1
  84. package/dist/esm/mcp/tools/folder-search.d.ts +1 -1
  85. package/dist/esm/mcp/tools/folder-search.js +19 -11
  86. package/dist/esm/mcp/tools/folder-search.js.map +1 -1
  87. package/dist/esm/setup/http.d.ts +0 -2
  88. package/dist/esm/setup/http.js +18 -11
  89. package/dist/esm/setup/http.js.map +1 -1
  90. package/dist/esm/setup/stdio.d.ts +0 -2
  91. package/dist/esm/setup/stdio.js +18 -11
  92. package/dist/esm/setup/stdio.js.map +1 -1
  93. package/package.json +9 -10
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/index.ts"],"sourcesContent":["import { handleVersionHelp } from './setup/version-help.ts';\nimport type { ServerConfig } from './types.ts';\n\nexport { GOOGLE_SCOPE } from './constants.ts';\nexport * as mcp from './mcp/index.ts';\nexport * as schemas from './schemas/index.ts';\nexport * as setup from './setup/index.ts';\nexport * from './types.ts';\n\nexport async function startServer(config: ServerConfig): Promise<void> {\n // createHTTPServer/createStdioServer pull in @modelcontextprotocol/sdk and every mcp/tools/*.ts\n // (googleapis included); deferred so a --version/--help run never reaches them.\n const { createHTTPServer } = await import('./setup/http.ts');\n const { createStdioServer } = await import('./setup/stdio.ts');\n const { logger, close } = config.transport.type === 'stdio' ? await createStdioServer(config) : await createHTTPServer(config);\n\n process.on('SIGINT', async () => {\n await close();\n process.exit(0);\n });\n\n logger.info(`Server started with ${config.transport.type} transport`);\n await new Promise(() => {});\n}\n\nexport default async function main(): Promise<void> {\n // Check for help/version flags FIRST, before config parsing\n const versionHelpResult = handleVersionHelp(process.argv);\n if (versionHelpResult.handled) {\n console.log(versionHelpResult.output);\n process.exit(0);\n }\n\n // Only parse config if no help/version flags. config.ts's own heavy imports (@mcp-z/oauth-google,\n // @mcp-z/server) are deferred internally, so this static-looking call stays cheap until here.\n const { createConfig } = await import('./setup/config.ts');\n const config = createConfig();\n await startServer(config);\n}\n\nif (process.argv[1] === new URL(import.meta.url).pathname) {\n main();\n}\n"],"names":["GOOGLE_SCOPE","main","mcp","schemas","setup","startServer","config","createHTTPServer","createStdioServer","logger","close","transport","type","process","on","exit","info","Promise","versionHelpResult","createConfig","handleVersionHelp","argv","handled","console","log","output","URL","pathname"],"mappings":";;;;;;;;;;;QAGSA;eAAAA,yBAAY;;QAsBrB;eAA8BC;;QArBlBC;;;QACAC;;;QACAC;;;QAGUC;eAAAA;;;6BATY;2BAGL;+DACR;gEACI;gEACF;qBACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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elp } from './setup/version-help.ts';\nimport type { ServerConfig } from './types.ts';\n\nexport { GOOGLE_SCOPE } from './constants.ts';\nexport * as mcp from './mcp/index.ts';\nexport * as schemas from './schemas/index.ts';\nexport * as setup from './setup/index.ts';\nexport * from './types.ts';\n\nexport async function startServer(config: ServerConfig): Promise<void> {\n // createHTTPServer/createStdioServer pull in @mcp-z/server and every mcp/tools/*.ts\n // (googleapis included); deferred so a --version/--help run never reaches them.\n const { createHTTPServer } = await import('./setup/http.ts');\n const { createStdioServer } = await import('./setup/stdio.ts');\n const { logger, close } = config.transport.type === 'stdio' ? await createStdioServer(config) : await createHTTPServer(config);\n\n process.on('SIGINT', async () => {\n await close();\n process.exit(0);\n });\n\n logger.info(`Server started with ${config.transport.type} transport`);\n await new Promise(() => {});\n}\n\nexport default async function main(): Promise<void> {\n // Check for help/version flags FIRST, before config parsing\n const versionHelpResult = handleVersionHelp(process.argv);\n if (versionHelpResult.handled) {\n console.log(versionHelpResult.output);\n process.exit(0);\n }\n\n // Only parse config if no help/version flags. config.ts's own heavy imports (@mcp-z/oauth-google,\n // @mcp-z/server) are deferred internally, so this static-looking call stays cheap until here.\n const { createConfig } = await import('./setup/config.ts');\n const config = createConfig();\n await startServer(config);\n}\n\nif (process.argv[1] === new URL(import.meta.url).pathname) {\n main();\n}\n"],"names":["GOOGLE_SCOPE","main","mcp","schemas","setup","startServer","config","createHTTPServer","createStdioServer","logger","close","transport","type","process","on","exit","info","Promise","versionHelpResult","createConfig","handleVersionHelp","argv","handled","console","log","output","URL","pathname"],"mappings":";;;;;;;;;;;QAGSA;eAAAA,yBAAY;;QAsBrB;eAA8BC;;QArBlBC;;;QACAC;;;QACAC;;;QAGUC;eAAAA;;;6BATY;2BAGL;+DACR;gEACI;gEACF;qBACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ound to this request's token provider.
4
+ *
5
+ * `@mcp-z/oauth-google` mints tokens and depends on no Google SDK, so the client
6
+ * is built here, from this package's own SDK. That keeps one copy of
7
+ * `google-auth-library` in the tree by construction rather than by matching pins.
8
+ */
9
+ export declare function googleAuth(auth: GoogleAuthProvider): import("google-auth-library").OAuth2Client;
@@ -0,0 +1,9 @@
1
+ import { type GoogleAuthProvider } from '@mcp-z/oauth-google';
2
+ /**
3
+ * A Google API client bound to this request's token provider.
4
+ *
5
+ * `@mcp-z/oauth-google` mints tokens and depends on no Google SDK, so the client
6
+ * is built here, from this package's own SDK. That keeps one copy of
7
+ * `google-auth-library` in the tree by construction rather than by matching pins.
8
+ */
9
+ export declare function googleAuth(auth: GoogleAuthProvider): import("google-auth-library").OAuth2Client;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "googleAuth", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return googleAuth;
9
+ }
10
+ });
11
+ var _drive = require("@googleapis/drive");
12
+ var _oauthgoogle = require("@mcp-z/oauth-google");
13
+ function googleAuth(auth) {
14
+ return (0, _oauthgoogle.attachTokenProvider)(new _drive.auth.OAuth2(), auth);
15
+ }
16
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/lib/google-auth.ts"],"sourcesContent":["import { auth as googleAuthPlus } from '@googleapis/drive';\nimport { attachTokenProvider, type GoogleAuthProvider } from '@mcp-z/oauth-google';\n\n/**\n * A Google API client bound to this request's token provider.\n *\n * `@mcp-z/oauth-google` mints tokens and depends on no Google SDK, so the client\n * is built here, from this package's own SDK. That keeps one copy of\n * `google-auth-library` in the tree by construction rather than by matching pins.\n */\nexport function googleAuth(auth: GoogleAuthProvider) {\n return attachTokenProvider(new googleAuthPlus.OAuth2(), auth);\n}\n"],"names":["googleAuth","auth","attachTokenProvider","googleAuthPlus","OAuth2"],"mappings":";;;;+BAUgBA;;;eAAAA;;;qBAVuB;2BACsB;AAStD,SAASA,WAAWC,IAAwB;IACjD,OAAOC,IAAAA,gCAAmB,EAAC,IAAIC,WAAc,CAACC,MAAM,IAAIH;AAC1D"}
@@ -1,5 +1,4 @@
1
- import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
2
- import type { ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
1
+ import type { ServerContext } from '@mcp-z/server';
3
2
  export default function createPrompt(): {
4
3
  name: string;
5
4
  config: {
@@ -7,7 +6,7 @@ export default function createPrompt(): {
7
6
  };
8
7
  handler: (_args: {
9
8
  [x: string]: unknown;
10
- }, _extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => Promise<{
9
+ }, _extra: ServerContext) => Promise<{
11
10
  messages: {
12
11
  role: "user";
13
12
  content: {
@@ -1,5 +1,4 @@
1
- import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
2
- import type { ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
1
+ import type { ServerContext } from '@mcp-z/server';
3
2
  export default function createPrompt(): {
4
3
  name: string;
5
4
  config: {
@@ -7,7 +6,7 @@ export default function createPrompt(): {
7
6
  };
8
7
  handler: (_args: {
9
8
  [x: string]: unknown;
10
- }, _extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => Promise<{
9
+ }, _extra: ServerContext) => Promise<{
11
10
  messages: {
12
11
  role: "user";
13
12
  content: {
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/mcp/prompts/query-syntax.ts"],"sourcesContent":["import type { PromptModule } from '@mcp-z/server';\nimport type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport type { ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\nexport default function createPrompt() {\n const config = {\n description: 'Reference guide for Google Drive query syntax',\n };\n\n const handler = async (_args: { [x: string]: unknown }, _extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => {\n return {\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: `# Google Drive Query Syntax Reference\n\n## Logical Operators\n- \\`$and\\`: Array of conditions that ALL must match\n- \\`$or\\`: Array of conditions where ANY must match\n- \\`$not\\`: Condition that must NOT match\n\n## File/Folder Fields\n- \\`name\\`: Search by name (partial match, case-insensitive)\n- \\`mimeType\\`: Filter by MIME type\n- \\`fullText\\`: Search file content and metadata\n- \\`parentId\\`: Search within folder (use \"root\" for My Drive)\n- \\`owner\\`: Filter by owner email\n\n## Boolean Flags\n- \\`starred\\`: true/false\n- \\`sharedWithMe\\`: true/false\n- \\`trashed\\`: true/false\n\n## Date Range\n\\`\\`\\`json\n{ \"modifiedTime\": { \"$gte\": \"2024-01-01\", \"$lt\": \"2024-12-31\" } }\n\\`\\`\\`\n\n## Common MIME Types\n- \\`application/vnd.google-apps.folder\\`: Folders\n- \\`application/vnd.google-apps.document\\`: Google Docs\n- \\`application/vnd.google-apps.spreadsheet\\`: Google Sheets\n- \\`application/vnd.google-apps.presentation\\`: Google Slides\n- \\`application/pdf\\`: PDF files\n- \\`image/jpeg\\`, \\`image/png\\`: Images\n\n## Field Operators (for multi-value fields)\n- \\`$any\\`: OR - matches if ANY value matches\n- \\`$all\\`: AND - matches if ALL values match\n- \\`$none\\`: NOT - matches if NONE match\n\n## Escape Hatch\n- \\`rawDriveQuery\\`: Raw Google Drive query syntax\n\n## Example Queries\n\\`\\`\\`json\n// PDFs modified this year\n{ \"mimeType\": \"application/pdf\", \"modifiedTime\": { \"$gte\": \"2024-01-01\" } }\n\n// Starred spreadsheets\n{ \"mimeType\": \"application/vnd.google-apps.spreadsheet\", \"starred\": true }\n\n// Files in specific folder\n{ \"parentId\": \"1abc123xyz\" }\n\n// Search by name\n{ \"name\": \"budget\" }\n\n// Complex: shared PDFs or Docs\n{ \"$or\": [\n { \"mimeType\": \"application/pdf\", \"sharedWithMe\": true },\n { \"mimeType\": \"application/vnd.google-apps.document\", \"sharedWithMe\": true }\n]}\n\\`\\`\\``,\n },\n },\n ],\n };\n };\n\n return {\n name: 'query-syntax',\n config,\n handler,\n } satisfies PromptModule;\n}\n"],"names":["createPrompt","config","description","handler","_args","_extra","messages","role","content","type","text","name"],"mappings":";;;;+BAIA;;;eAAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAT,SAASA;IACtB,IAAMC,SAAS;QACbC,aAAa;IACf;IAEA,IAAMC,UAAU,iBAAOC,OAAiCC;;;gBACtD;;oBAAO;wBACLC,QAAQ;4BACN;gCACEC,MAAM;gCACNC,SAAS;oCACPC,MAAM;oCACNC,MAAM;gCA4DR;4BACF;;oBAEJ;;;QACF;;IAEA,OAAO;QACLC,MAAM;QACNV,QAAAA;QACAE,SAAAA;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/mcp/prompts/query-syntax.ts"],"sourcesContent":["import type { PromptModule, ServerContext } from '@mcp-z/server';\n\nexport default function createPrompt() {\n const config = {\n description: 'Reference guide for Google Drive query syntax',\n };\n\n const handler = async (_args: { [x: string]: unknown }, _extra: ServerContext) => {\n return {\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: `# Google Drive Query Syntax Reference\n\n## Logical Operators\n- \\`$and\\`: Array of conditions that ALL must match\n- \\`$or\\`: Array of conditions where ANY must match\n- \\`$not\\`: Condition that must NOT match\n\n## File/Folder Fields\n- \\`name\\`: Search by name (partial match, case-insensitive)\n- \\`mimeType\\`: Filter by MIME type\n- \\`fullText\\`: Search file content and metadata\n- \\`parentId\\`: Search within folder (use \"root\" for My Drive)\n- \\`owner\\`: Filter by owner email\n\n## Boolean Flags\n- \\`starred\\`: true/false\n- \\`sharedWithMe\\`: true/false\n- \\`trashed\\`: true/false\n\n## Date Range\n\\`\\`\\`json\n{ \"modifiedTime\": { \"$gte\": \"2024-01-01\", \"$lt\": \"2024-12-31\" } }\n\\`\\`\\`\n\n## Common MIME Types\n- \\`application/vnd.google-apps.folder\\`: Folders\n- \\`application/vnd.google-apps.document\\`: Google Docs\n- \\`application/vnd.google-apps.spreadsheet\\`: Google Sheets\n- \\`application/vnd.google-apps.presentation\\`: Google Slides\n- \\`application/pdf\\`: PDF files\n- \\`image/jpeg\\`, \\`image/png\\`: Images\n\n## Field Operators (for multi-value fields)\n- \\`$any\\`: OR - matches if ANY value matches\n- \\`$all\\`: AND - matches if ALL values match\n- \\`$none\\`: NOT - matches if NONE match\n\n## Escape Hatch\n- \\`rawDriveQuery\\`: Raw Google Drive query syntax\n\n## Example Queries\n\\`\\`\\`json\n// PDFs modified this year\n{ \"mimeType\": \"application/pdf\", \"modifiedTime\": { \"$gte\": \"2024-01-01\" } }\n\n// Starred spreadsheets\n{ \"mimeType\": \"application/vnd.google-apps.spreadsheet\", \"starred\": true }\n\n// Files in specific folder\n{ \"parentId\": \"1abc123xyz\" }\n\n// Search by name\n{ \"name\": \"budget\" }\n\n// Complex: shared PDFs or Docs\n{ \"$or\": [\n { \"mimeType\": \"application/pdf\", \"sharedWithMe\": true },\n { \"mimeType\": \"application/vnd.google-apps.document\", \"sharedWithMe\": true }\n]}\n\\`\\`\\``,\n },\n },\n ],\n };\n };\n\n return {\n name: 'query-syntax',\n config,\n handler,\n } satisfies PromptModule;\n}\n"],"names":["createPrompt","config","description","handler","_args","_extra","messages","role","content","type","text","name"],"mappings":";;;;+BAEA;;;eAAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAT,SAASA;IACtB,IAAMC,SAAS;QACbC,aAAa;IACf;IAEA,IAAMC,UAAU,iBAAOC,OAAiCC;;;gBACtD;;oBAAO;wBACLC,QAAQ;4BACN;gCACEC,MAAM;gCACNC,SAAS;oCACPC,MAAM;oCACNC,MAAM;gCA4DR;4BACF;;oBAEJ;;;QACF;;IAEA,OAAO;QACLC,MAAM;QACNV,QAAAA;QACAE,SAAAA;IACF;AACF"}
@@ -1,9 +1,2 @@
1
- import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
3
- import type { ReadResourceResult, ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
4
- export default function createResource(): {
5
- name: string;
6
- template: ResourceTemplate;
7
- config: import("@modelcontextprotocol/sdk/server/mcp.js").ResourceMetadata;
8
- handler: (uri: URL, variables: Record<string, string | string[]>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => Promise<ReadResourceResult>;
9
- };
1
+ import type { ResourceModule } from '@mcp-z/server';
2
+ export default function createResource(): ResourceModule;
@@ -1,9 +1,2 @@
1
- import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
3
- import type { ReadResourceResult, ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
4
- export default function createResource(): {
5
- name: string;
6
- template: ResourceTemplate;
7
- config: import("@modelcontextprotocol/sdk/server/mcp.js").ResourceMetadata;
8
- handler: (uri: URL, variables: Record<string, string | string[]>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => Promise<ReadResourceResult>;
9
- };
1
+ import type { ResourceModule } from '@mcp-z/server';
2
+ export default function createResource(): ResourceModule;
@@ -8,8 +8,9 @@ Object.defineProperty(exports, "default", {
8
8
  return createResource;
9
9
  }
10
10
  });
11
- var _mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
12
- var _googleapis = require("googleapis");
11
+ var _drive = require("@googleapis/drive");
12
+ var _server = require("@mcp-z/server");
13
+ var _googleauthts = require("../../lib/google-auth.js");
13
14
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
14
15
  try {
15
16
  var info = gen[key](arg);
@@ -136,7 +137,7 @@ function _ts_generator(thisArg, body) {
136
137
  }
137
138
  }
138
139
  function createResource() {
139
- var template = new _mcp.ResourceTemplate('drive://files/{fileId}', {
140
+ var template = new _server.ResourceTemplate('drive://files/{fileId}', {
140
141
  list: undefined
141
142
  });
142
143
  var config = {
@@ -178,15 +179,16 @@ function createResource() {
178
179
  }
179
180
  // Safe type guard to access middleware-enriched extra
180
181
  logger = extra.logger, authContext = extra.authContext;
181
- drive = _googleapis.google.drive({
182
+ drive = (0, _drive.drive)({
182
183
  version: 'v3',
183
- auth: authContext.auth
184
+ auth: (0, _googleauthts.googleAuth)(authContext.auth)
184
185
  });
185
186
  return [
186
187
  4,
187
188
  drive.files.get({
188
189
  fileId: fileId,
189
- fields: 'id,name,mimeType,size,modifiedTime,owners,webViewLink'
190
+ fields: 'id,name,mimeType,size,modifiedTime,owners,webViewLink',
191
+ supportsAllDrives: true
190
192
  })
191
193
  ];
192
194
  case 2:
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/mcp/resources/file.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport type { ResourceConfig, ResourceModule } from '@mcp-z/server';\nimport { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport type { ReadResourceResult, ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';\nimport { google } from 'googleapis';\n\nexport default function createResource() {\n const template = new ResourceTemplate('drive://files/{fileId}', {\n list: undefined,\n });\n const config: ResourceConfig = {\n description: 'Drive file resource',\n mimeType: 'application/json',\n };\n\n const handler = async (uri: URL, variables: Record<string, string | string[]>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>): Promise<ReadResourceResult> => {\n // Extract fileId and handle both string and string[] cases\n const fileId = Array.isArray(variables.fileId) ? variables.fileId[0] : variables.fileId;\n\n try {\n // Validate fileId exists and is a string\n if (!fileId || typeof fileId !== 'string') {\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify({\n error: 'Missing or invalid fileId in resource URI',\n }),\n },\n ],\n };\n }\n\n // Safe type guard to access middleware-enriched extra\n const { logger, authContext } = extra as unknown as EnrichedExtra;\n const drive = google.drive({ version: 'v3', auth: authContext.auth });\n const resp = await drive.files.get({\n fileId,\n fields: 'id,name,mimeType,size,modifiedTime,owners,webViewLink',\n });\n const data = resp.data;\n logger.debug?.({ fileId, fileName: data?.name }, 'drive-file resource fetch success');\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(data || {}),\n },\n ],\n };\n } catch (error) {\n const { logger } = extra as unknown as EnrichedExtra;\n logger.debug?.(error as Record<string, unknown>, 'drive resource fetch failed');\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify({ error: (error as Error).message }),\n },\n ],\n };\n }\n };\n\n return {\n name: 'file',\n template,\n config,\n handler,\n } satisfies ResourceModule;\n}\n"],"names":["createResource","template","ResourceTemplate","list","undefined","config","description","mimeType","handler","uri","variables","extra","fileId","logger","authContext","drive","resp","data","error","Array","isArray","contents","href","text","JSON","stringify","google","version","auth","files","get","fields","debug","fileName","name","message"],"mappings":";;;;+BAOA;;;eAAwBA;;;mBALS;0BAGV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAWF,MAAXE;yBACRA,iBAAAA,QAAOmB,KAAK,cAAZnB,qCAAAA,oBAAAA,SAAeK,OAAkC;wBACjD;;4BAAO;gCACLG,QAAQ;oCACN;wCACEZ,KAAKA,IAAIa,IAAI;wCACbf,UAAU;wCACVgB,MAAMC,KAAKC,SAAS,CAAC;4CAAEP,OAAO,AAACA,MAAgBiB,OAAO;wCAAC;oCACzD;;4BAEJ;;;;;;;;QAEJ;;IAEA,OAAO;QACLD,MAAM;QACNjC,UAAAA;QACAI,QAAAA;QACAG,SAAAA;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/mcp/resources/file.ts"],"sourcesContent":["import { drive as driveApi } from '@googleapis/drive';\nimport type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport type { ReadResourceResult, ResourceConfig, ResourceModule, ServerContext } from '@mcp-z/server';\nimport { ResourceTemplate } from '@mcp-z/server';\nimport { googleAuth } from '../../lib/google-auth.ts';\n\nexport default function createResource(): ResourceModule {\n const template = new ResourceTemplate('drive://files/{fileId}', {\n list: undefined,\n });\n const config: ResourceConfig = {\n description: 'Drive file resource',\n mimeType: 'application/json',\n };\n\n const handler = async (uri: URL, variables: Record<string, string | string[]>, extra: ServerContext): Promise<ReadResourceResult> => {\n // Extract fileId and handle both string and string[] cases\n const fileId = Array.isArray(variables.fileId) ? variables.fileId[0] : variables.fileId;\n\n try {\n // Validate fileId exists and is a string\n if (!fileId || typeof fileId !== 'string') {\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify({\n error: 'Missing or invalid fileId in resource URI',\n }),\n },\n ],\n };\n }\n\n // Safe type guard to access middleware-enriched extra\n const { logger, authContext } = extra as unknown as EnrichedExtra;\n const drive = driveApi({ version: 'v3', auth: googleAuth(authContext.auth) });\n const resp = await drive.files.get({\n fileId,\n fields: 'id,name,mimeType,size,modifiedTime,owners,webViewLink',\n supportsAllDrives: true,\n });\n const data = resp.data;\n logger.debug?.({ fileId, fileName: data?.name }, 'drive-file resource fetch success');\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(data || {}),\n },\n ],\n };\n } catch (error) {\n const { logger } = extra as unknown as EnrichedExtra;\n logger.debug?.(error as Record<string, unknown>, 'drive resource fetch failed');\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify({ error: (error as Error).message }),\n },\n ],\n };\n }\n };\n\n return {\n name: 'file',\n template,\n config,\n handler,\n } satisfies ResourceModule;\n}\n"],"names":["createResource","template","ResourceTemplate","list","undefined","config","description","mimeType","handler","uri","variables","extra","fileId","logger","authContext","drive","resp","data","error","Array","isArray","contents","href","text","JSON","stringify","driveApi","version","auth","googleAuth","files","get","fields","supportsAllDrives","debug","fileName","name","message"],"mappings":";;;;+BAMA;;;eAAwBA;;;qBANU;sBAGD;4BACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEZ,SAASA;IACtB,IAAMC,WAAW,IAAIC,wBAAgB,CAAC,0BAA0B;QAC9DC,MAAMC;IACR;IACA,IAAMC,SAAyB;QAC7BC,aAAa;QACbC,UAAU;IACZ;IAEA,IAAMC,UAAU,iBAAOC,KAAUC,WAA8CC;;gBAEvEC,QA2BJC,eARQA,QAAQC,aACVC,OACAC,MAKAC,MAWCC,OAEPL,gBADQA;;;;wBAvCV,2DAA2D;wBACrDD,SAASO,MAAMC,OAAO,CAACV,UAAUE,MAAM,IAAIF,UAAUE,MAAM,CAAC,EAAE,GAAGF,UAAUE,MAAM;;;;;;;;;wBAGrF,yCAAyC;wBACzC,IAAI,CAACA,UAAU,OAAOA,WAAW,UAAU;4BACzC;;gCAAO;oCACLS,QAAQ;wCACN;4CACEZ,KAAKA,IAAIa,IAAI;4CACbf,UAAU;4CACVgB,MAAMC,KAAKC,SAAS,CAAC;gDACnBP,OAAO;4CACT;wCACF;;gCAEJ;;wBACF;wBAEA,sDAAsD;wBAC9CL,SAAwBF,MAAxBE,QAAQC,cAAgBH,MAAhBG;wBACVC,QAAQW,IAAAA,YAAQ,EAAC;4BAAEC,SAAS;4BAAMC,MAAMC,IAAAA,wBAAU,EAACf,YAAYc,IAAI;wBAAE;wBAC9D;;4BAAMb,MAAMe,KAAK,CAACC,GAAG,CAAC;gCACjCnB,QAAAA;gCACAoB,QAAQ;gCACRC,mBAAmB;4BACrB;;;wBAJMjB,OAAO;wBAKPC,OAAOD,KAAKC,IAAI;yBACtBJ,gBAAAA,OAAOqB,KAAK,cAAZrB,oCAAAA,mBAAAA,QAAe;4BAAED,QAAAA;4BAAQuB,QAAQ,EAAElB,iBAAAA,2BAAAA,KAAMmB,IAAI;wBAAC,GAAG;wBACjD;;4BAAO;gCACLf,QAAQ;oCACN;wCACEZ,KAAKA,IAAIa,IAAI;wCACbf,UAAU;wCACVgB,MAAMC,KAAKC,SAAS,CAACR,QAAQ,CAAC;oCAChC;;4BAEJ;;;wBACOC;wBACCL,UAAWF,MAAXE;yBACRA,iBAAAA,QAAOqB,KAAK,cAAZrB,qCAAAA,oBAAAA,SAAeK,OAAkC;wBACjD;;4BAAO;gCACLG,QAAQ;oCACN;wCACEZ,KAAKA,IAAIa,IAAI;wCACbf,UAAU;wCACVgB,MAAMC,KAAKC,SAAS,CAAC;4CAAEP,OAAO,AAACA,MAAgBmB,OAAO;wCAAC;oCACzD;;4BAEJ;;;;;;;;QAEJ;;IAEA,OAAO;QACLD,MAAM;QACNnC,UAAAA;QACAI,QAAAA;QACAG,SAAAA;IACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import type { EnrichedExtra } from '@mcp-z/oauth-google';
2
- import { type CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import { type CallToolResult } from '@mcp-z/server';
3
3
  import { z } from 'zod';
4
4
  declare const inputSchema: z.ZodObject<{
5
5
  ids: z.ZodArray<z.ZodString>;
@@ -1,5 +1,5 @@
1
1
  import type { EnrichedExtra } from '@mcp-z/oauth-google';
2
- import { type CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import { type CallToolResult } from '@mcp-z/server';
3
3
  import { z } from 'zod';
4
4
  declare const inputSchema: z.ZodObject<{
5
5
  ids: z.ZodArray<z.ZodString>;
@@ -9,9 +9,10 @@ Object.defineProperty(exports, "default", {
9
9
  }
10
10
  });
11
11
  var _oauthgoogle = require("@mcp-z/oauth-google");
12
- var _types = require("@modelcontextprotocol/sdk/types.js");
13
- var _googleapis = require("googleapis");
12
+ var _drive = require("@googleapis/drive");
13
+ var _server = require("@mcp-z/server");
14
14
  var _zod = require("zod");
15
+ var _googleauthts = require("../../lib/google-auth.js");
15
16
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
16
17
  try {
17
18
  var info = gen[key](arg);
@@ -220,9 +221,9 @@ function handler(_0, _1) {
220
221
  ,
221
222
  4
222
223
  ]);
223
- drive = _googleapis.google.drive({
224
+ drive = (0, _drive.drive)({
224
225
  version: 'v3',
225
- auth: extra.authContext.auth
226
+ auth: (0, _googleauthts.googleAuth)(extra.authContext.auth)
226
227
  });
227
228
  return [
228
229
  4,
@@ -237,7 +238,8 @@ function handler(_0, _1) {
237
238
  fileId: id,
238
239
  requestBody: {
239
240
  trashed: true
240
- }
241
+ },
242
+ supportsAllDrives: true
241
243
  })
242
244
  ];
243
245
  case 1:
@@ -306,8 +308,8 @@ function handler(_0, _1) {
306
308
  logger.error('drive.file.moveToTrash error', {
307
309
  error: message
308
310
  });
309
- // Throw McpError
310
- throw new _types.McpError(_types.ErrorCode.InternalError, "Error moving files to trash: ".concat(message), {
311
+ // Throw ProtocolError
312
+ throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error moving files to trash: ".concat(message), {
311
313
  stack: _instanceof(error, Error) ? error.stack : undefined
312
314
  });
313
315
  case 4:
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/mcp/tools/file-move-to-trash.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport { type CallToolResult, ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\nimport { google } from 'googleapis';\nimport { z } from 'zod';\n\nconst MAX_BATCH_SIZE = 1000;\n\nconst inputSchema = z.object({\n ids: z.array(z.string().min(1)).min(1).max(MAX_BATCH_SIZE).describe('File IDs to soft delete (move to trash)'),\n});\n\n// Success branch schema\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n operationSummary: z.string().describe('Human-readable summary of the operation'),\n totalCount: z.number().describe('Total number of files requested to trash'),\n successCount: z.number().describe('Number of files successfully moved to trash'),\n failureCount: z.number().describe('Number of files that failed to move'),\n recoverable: z.boolean().describe('Whether trashed files can be restored'),\n recoverableDays: z.number().describe('Days until permanent deletion'),\n failures: z\n .array(\n z.object({\n id: z.string().describe('ID of the file that failed'),\n error: z.string().describe('Error message explaining the failure'),\n })\n )\n .optional()\n .describe('Details of any files that failed to trash'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n title: 'Move Files to Trash',\n description: 'Move files to trash (recoverable for 30 days).',\n inputSchema: inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ ids }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('drive.file.moveToTrash called', { count: ids.length });\n\n try {\n const drive = google.drive({ version: 'v3', auth: extra.authContext.auth });\n\n const results = await Promise.allSettled(\n ids.map(async (id) => {\n await drive.files.update({\n fileId: id,\n requestBody: { trashed: true },\n });\n return id;\n })\n );\n\n // Separate successes and failures\n const failures: Array<{ id: string; error: string }> = [];\n\n results.forEach((result, index) => {\n const id = ids[index];\n if (!id) return;\n\n if (result.status === 'rejected') {\n const errorMessage = result.reason instanceof Error ? result.reason.message : String(result.reason);\n failures.push({ id, error: errorMessage });\n }\n });\n\n const successCount = ids.length - failures.length;\n const failureCount = failures.length;\n const totalCount = ids.length;\n\n logger.info('drive.file.moveToTrash completed', {\n totalCount,\n successCount,\n failureCount,\n });\n\n const operationSummary = failureCount === 0 ? `Moved ${successCount} file${successCount === 1 ? '' : 's'} to trash (recoverable for 30 days)` : `Moved ${successCount} of ${totalCount} file${totalCount === 1 ? '' : 's'} to trash (${failureCount} failed, recoverable for 30 days)`;\n\n const result: Output = {\n type: 'success' as const,\n operationSummary,\n totalCount,\n successCount,\n failureCount,\n recoverable: true,\n recoverableDays: 30,\n ...(failures.length > 0 && { failures }),\n };\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result),\n },\n ],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('drive.file.moveToTrash error', { error: message });\n\n // Throw McpError\n throw new McpError(ErrorCode.InternalError, `Error moving files to trash: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'file-move-to-trash' as const,\n config,\n handler,\n };\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","MAX_BATCH_SIZE","inputSchema","z","object","ids","array","string","min","max","describe","successBranchSchema","type","literal","operationSummary","totalCount","number","successCount","failureCount","recoverable","boolean","recoverableDays","failures","id","error","optional","outputSchema","discriminatedUnion","config","title","description","result","handler","extra","logger","drive","results","message","info","count","length","google","version","auth","authContext","Promise","allSettled","map","files","update","fileId","requestBody","trashed","forEach","index","status","errorMessage","reason","Error","String","push","content","text","JSON","stringify","structuredContent","McpError","ErrorCode","InternalError","stack","undefined","name"],"mappings":";;;;+BA2HA;;;eAAwBA;;;2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E7BN,OAAOI,IAAI,CAAC,oCAAoC;wBAC9CvB,YAAAA;wBACAE,cAAAA;wBACAC,cAAAA;oBACF;oBAEMJ,mBAAmBI,iBAAiB,IAAI,AAAC,SAA4BD,OAApBA,cAAa,SAAqC,OAA9BA,iBAAiB,IAAI,KAAK,KAAI,yCAAuC,AAAC,SAA2BF,OAAnBE,cAAa,QAAwBF,OAAlBA,YAAW,SAAgDG,OAAzCH,eAAe,IAAI,KAAK,KAAI,eAA0B,OAAbG,cAAa;oBAE9Oa,SAAiB;wBACrBnB,MAAM;wBACNE,kBAAAA;wBACAC,YAAAA;wBACAE,cAAAA;wBACAC,cAAAA;wBACAC,aAAa;wBACbE,iBAAiB;uBACbC,SAASkB,MAAM,GAAG,KAAK;wBAAElB,UAAAA;oBAAS;oBAGxC;;wBAAO;4BACLuC,OAAO;gCACL;oCACEjD,MAAM;oCACNkD,MAAMC,KAAKC,SAAS,CAACjC;gCACvB;;4BAEFkC,mBAAmB;gCAAElC,QAAAA;4BAAO;wBAC9B;;;oBACOP;oBACDa,UAAUb,AAAK,YAALA,OAAiBkC,SAAQlC,MAAMa,OAAO,GAAGsB,OAAOnC;oBAChEU,OAAOV,KAAK,CAAC,gCAAgC;wBAAEA,OAAOa;oBAAQ;oBAE9D,iBAAiB;oBACjB,MAAM,IAAI6B,eAAQ,CAACC,gBAAS,CAACC,aAAa,EAAE,AAAC,gCAAuC,OAAR/B,UAAW;wBACrFgC,OAAO7C,AAAK,YAALA,OAAiBkC,SAAQlC,MAAM6C,KAAK,GAAGC;oBAChD;;;;;;;IAEJ;;AAEe,SAASxE;IACtB,OAAO;QACLyE,MAAM;QACN3C,QAAAA;QACAI,SAAAA;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/mcp/tools/file-move-to-trash.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport { drive as driveApi } from '@googleapis/drive';\nimport { type CallToolResult, ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { z } from 'zod';\nimport { googleAuth } from '../../lib/google-auth.ts';\n\nconst MAX_BATCH_SIZE = 1000;\n\nconst inputSchema = z.object({\n ids: z.array(z.string().min(1)).min(1).max(MAX_BATCH_SIZE).describe('File IDs to soft delete (move to trash)'),\n});\n\n// Success branch schema\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n operationSummary: z.string().describe('Human-readable summary of the operation'),\n totalCount: z.number().describe('Total number of files requested to trash'),\n successCount: z.number().describe('Number of files successfully moved to trash'),\n failureCount: z.number().describe('Number of files that failed to move'),\n recoverable: z.boolean().describe('Whether trashed files can be restored'),\n recoverableDays: z.number().describe('Days until permanent deletion'),\n failures: z\n .array(\n z.object({\n id: z.string().describe('ID of the file that failed'),\n error: z.string().describe('Error message explaining the failure'),\n })\n )\n .optional()\n .describe('Details of any files that failed to trash'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n title: 'Move Files to Trash',\n description: 'Move files to trash (recoverable for 30 days).',\n inputSchema: inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ ids }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('drive.file.moveToTrash called', { count: ids.length });\n\n try {\n const drive = driveApi({ version: 'v3', auth: googleAuth(extra.authContext.auth) });\n\n const results = await Promise.allSettled(\n ids.map(async (id) => {\n await drive.files.update({\n fileId: id,\n requestBody: { trashed: true },\n supportsAllDrives: true,\n });\n return id;\n })\n );\n\n // Separate successes and failures\n const failures: Array<{ id: string; error: string }> = [];\n\n results.forEach((result, index) => {\n const id = ids[index];\n if (!id) return;\n\n if (result.status === 'rejected') {\n const errorMessage = result.reason instanceof Error ? result.reason.message : String(result.reason);\n failures.push({ id, error: errorMessage });\n }\n });\n\n const successCount = ids.length - failures.length;\n const failureCount = failures.length;\n const totalCount = ids.length;\n\n logger.info('drive.file.moveToTrash completed', {\n totalCount,\n successCount,\n failureCount,\n });\n\n const operationSummary = failureCount === 0 ? `Moved ${successCount} file${successCount === 1 ? '' : 's'} to trash (recoverable for 30 days)` : `Moved ${successCount} of ${totalCount} file${totalCount === 1 ? '' : 's'} to trash (${failureCount} failed, recoverable for 30 days)`;\n\n const result: Output = {\n type: 'success' as const,\n operationSummary,\n totalCount,\n successCount,\n failureCount,\n recoverable: true,\n recoverableDays: 30,\n ...(failures.length > 0 && { failures }),\n };\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result),\n },\n ],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('drive.file.moveToTrash error', { error: message });\n\n // Throw ProtocolError\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error moving files to trash: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'file-move-to-trash' as const,\n config,\n handler,\n };\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","MAX_BATCH_SIZE","inputSchema","z","object","ids","array","string","min","max","describe","successBranchSchema","type","literal","operationSummary","totalCount","number","successCount","failureCount","recoverable","boolean","recoverableDays","failures","id","error","optional","outputSchema","discriminatedUnion","config","title","description","result","handler","extra","logger","drive","results","message","info","count","length","driveApi","version","auth","googleAuth","authContext","Promise","allSettled","map","files","update","fileId","requestBody","trashed","supportsAllDrives","forEach","index","status","errorMessage","reason","Error","String","push","content","text","JSON","stringify","structuredContent","ProtocolError","ProtocolErrorCode","InternalError","stack","undefined","name"],"mappings":";;;;+BA6HA;;;eAAwBA;;;2BA5HA;qBAIU;sBACoC;mBACpD;4BACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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9CvB,YAAAA;wBACAE,cAAAA;wBACAC,cAAAA;oBACF;oBAEMJ,mBAAmBI,iBAAiB,IAAI,AAAC,SAA4BD,OAApBA,cAAa,SAAqC,OAA9BA,iBAAiB,IAAI,KAAK,KAAI,yCAAuC,AAAC,SAA2BF,OAAnBE,cAAa,QAAwBF,OAAlBA,YAAW,SAAgDG,OAAzCH,eAAe,IAAI,KAAK,KAAI,eAA0B,OAAbG,cAAa;oBAE9Oa,SAAiB;wBACrBnB,MAAM;wBACNE,kBAAAA;wBACAC,YAAAA;wBACAE,cAAAA;wBACAC,cAAAA;wBACAC,aAAa;wBACbE,iBAAiB;uBACbC,SAASkB,MAAM,GAAG,KAAK;wBAAElB,UAAAA;oBAAS;oBAGxC;;wBAAO;4BACLyC,OAAO;gCACL;oCACEnD,MAAM;oCACNoD,MAAMC,KAAKC,SAAS,CAACnC;gCACvB;;4BAEFoC,mBAAmB;gCAAEpC,QAAAA;4BAAO;wBAC9B;;;oBACOP;oBACDa,UAAUb,AAAK,YAALA,OAAiBoC,SAAQpC,MAAMa,OAAO,GAAGwB,OAAOrC;oBAChEU,OAAOV,KAAK,CAAC,gCAAgC;wBAAEA,OAAOa;oBAAQ;oBAE9D,sBAAsB;oBACtB,MAAM,IAAI+B,qBAAa,CAACC,yBAAiB,CAACC,aAAa,EAAE,AAAC,gCAAuC,OAARjC,UAAW;wBAClGkC,OAAO/C,AAAK,YAALA,OAAiBoC,SAAQpC,MAAM+C,KAAK,GAAGC;oBAChD;;;;;;;IAEJ;;AAEe,SAAS1E;IACtB,OAAO;QACL2E,MAAM;QACN7C,QAAAA;QACAI,SAAAA;IACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import type { EnrichedExtra } from '@mcp-z/oauth-google';
2
- import { type CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import { type CallToolResult } from '@mcp-z/server';
3
3
  import { z } from 'zod';
4
4
  declare const inputSchema: z.ZodObject<{
5
5
  fileIds: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
@@ -1,5 +1,5 @@
1
1
  import type { EnrichedExtra } from '@mcp-z/oauth-google';
2
- import { type CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import { type CallToolResult } from '@mcp-z/server';
3
3
  import { z } from 'zod';
4
4
  declare const inputSchema: z.ZodObject<{
5
5
  fileIds: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
@@ -9,9 +9,10 @@ Object.defineProperty(exports, "default", {
9
9
  }
10
10
  });
11
11
  var _oauthgoogle = require("@mcp-z/oauth-google");
12
- var _types = require("@modelcontextprotocol/sdk/types.js");
13
- var _googleapis = require("googleapis");
12
+ var _drive = require("@googleapis/drive");
13
+ var _server = require("@mcp-z/server");
14
14
  var _zod = require("zod");
15
+ var _googleauthts = require("../../lib/google-auth.js");
15
16
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
16
17
  try {
17
18
  var info = gen[key](arg);
@@ -258,7 +259,8 @@ var config = {
258
259
  4,
259
260
  drive.files.get({
260
261
  fileId: fileId,
261
- fields: 'id,name,parents,webViewLink'
262
+ fields: 'id,name,parents,webViewLink',
263
+ supportsAllDrives: true
262
264
  })
263
265
  ];
264
266
  case 1:
@@ -273,7 +275,8 @@ var config = {
273
275
  fileId: fileId,
274
276
  addParents: destinationFolderId,
275
277
  removeParents: oldParents.join(','),
276
- fields: 'id,name,parents,webViewLink'
278
+ fields: 'id,name,parents,webViewLink',
279
+ supportsAllDrives: true
277
280
  })
278
281
  ];
279
282
  case 2:
@@ -349,7 +352,8 @@ var config = {
349
352
  4,
350
353
  drive.files.get({
351
354
  fileId: fileId,
352
- fields: 'id,name,parents,webViewLink'
355
+ fields: 'id,name,parents,webViewLink',
356
+ supportsAllDrives: true
353
357
  })
354
358
  ];
355
359
  case 1:
@@ -420,7 +424,8 @@ var config = {
420
424
  fileId: file.fileId,
421
425
  addParents: destinationFolderId,
422
426
  removeParents: file.parents.join(','),
423
- fields: 'id'
427
+ fields: 'id',
428
+ supportsAllDrives: true
424
429
  })
425
430
  ];
426
431
  case 1:
@@ -507,9 +512,9 @@ function handler(_0, _1) {
507
512
  ,
508
513
  7
509
514
  ]);
510
- drive = _googleapis.google.drive({
515
+ drive = (0, _drive.drive)({
511
516
  version: 'v3',
512
- auth: extra.authContext.auth
517
+ auth: (0, _googleauthts.googleAuth)(extra.authContext.auth)
513
518
  });
514
519
  moved = [];
515
520
  failed = [];
@@ -584,8 +589,8 @@ function handler(_0, _1) {
584
589
  logger.error('drive.file.move error', {
585
590
  error: message
586
591
  });
587
- // Throw McpError
588
- throw new _types.McpError(_types.ErrorCode.InternalError, "Error moving files: ".concat(message), {
592
+ // Throw ProtocolError
593
+ throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error moving files: ".concat(message), {
589
594
  stack: _instanceof(error, Error) ? error.stack : undefined
590
595
  });
591
596
  case 7:
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/mcp/tools/file-move.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport { type CallToolResult, ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\nimport type { drive_v3 } from 'googleapis';\nimport { google } from 'googleapis';\nimport { z } from 'zod';\nimport type { Logger } from '../../types.ts';\n\n// Type guard for Google Drive API errors\ninterface DriveApiError {\n message?: string;\n code?: number | string;\n}\n\nfunction isDriveApiError(error: unknown): error is DriveApiError {\n return typeof error === 'object' && error !== null && ('message' in error || 'code' in error);\n}\n\n// Types for results\ninterface MoveResult {\n fileId: string;\n fileName: string;\n oldParents: string[];\n newParent: string;\n webViewLink?: string;\n}\n\ninterface FailedMove {\n fileId: string;\n error: string;\n code?: string;\n}\n\nconst inputSchema = z.object({\n fileIds: z.union([z.string().min(1), z.array(z.string().min(1)).min(1).max(100)]).describe('File or folder ID(s) to move. Single ID or array (max 100 for batch)'),\n destinationFolderId: z.string().min(1).describe('Destination folder ID (use \"root\" for My Drive root)'),\n returnOldParents: z.boolean().optional().describe('Include old parent IDs in response for manual undo (recommended: true)'),\n});\n\n// Success branch schema\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n moved: z\n .array(\n z.object({\n fileId: z.string().describe('ID of the moved file'),\n fileName: z.string().describe('Name of the moved file'),\n oldParents: z.array(z.string()).describe('Previous parent folder IDs (for undo)'),\n newParent: z.string().describe('New parent folder ID'),\n webViewLink: z.string().optional().describe('URL to view the file'),\n })\n )\n .describe('Successfully moved files'),\n failed: z\n .array(\n z.object({\n fileId: z.string().describe('ID of the file that failed to move'),\n error: z.string().describe('Error message explaining the failure'),\n code: z.string().optional().describe('API error code if available'),\n })\n )\n .optional()\n .describe('Files that failed to move'),\n totalRequested: z.number().describe('Total number of files requested to move'),\n totalMoved: z.number().describe('Number of files successfully moved'),\n totalFailed: z.number().describe('Number of files that failed to move'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n title: 'Move Files',\n description: 'Move files/folders to destination folder. Returns oldParents for undo. Use \"root\" for My Drive root.',\n inputSchema: inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\n/**\n * Move a single file to a new parent folder\n */\nasync function moveSingleFile(\n drive: drive_v3.Drive,\n fileId: string,\n destinationFolderId: string,\n returnOldParents: boolean,\n logger: Logger\n): Promise<{\n success: boolean;\n result?: MoveResult;\n error?: FailedMove;\n}> {\n try {\n // Get current file metadata to get old parents\n const fileMetadata = await drive.files.get({\n fileId: fileId,\n fields: 'id,name,parents,webViewLink',\n });\n\n const oldParents = (fileMetadata.data.parents as string[] | undefined) || [];\n const fileName = (fileMetadata.data.name as string | undefined) || fileId;\n const webViewLink = fileMetadata.data.webViewLink as string | undefined;\n\n // Move file using addParents and removeParents\n await drive.files.update({\n fileId: fileId,\n addParents: destinationFolderId,\n removeParents: oldParents.join(','),\n fields: 'id,name,parents,webViewLink',\n });\n\n const result: MoveResult = {\n fileId: fileId,\n fileName: fileName,\n oldParents: returnOldParents ? oldParents : [],\n newParent: destinationFolderId,\n ...(webViewLink && { webViewLink }),\n };\n\n return { success: true, result };\n } catch (e: unknown) {\n const errorMessage = isDriveApiError(e) && e.message ? e.message : 'Unknown error';\n const errorCode = isDriveApiError(e) && e.code ? String(e.code) : undefined;\n logger.info('Failed to move file', { fileId, error: errorMessage });\n return {\n success: false,\n error: {\n fileId: fileId,\n error: errorMessage,\n ...(errorCode && { code: errorCode }),\n },\n };\n }\n}\n\n/**\n * Move multiple files using batch requests\n */\nasync function moveBatchFiles(\n drive: drive_v3.Drive,\n fileIds: string[],\n destinationFolderId: string,\n returnOldParents: boolean,\n _logger: Logger\n): Promise<{\n moved: MoveResult[];\n failed: FailedMove[];\n}> {\n const moved: MoveResult[] = [];\n const failed: FailedMove[] = [];\n\n // First, fetch metadata for all files in batch\n const metadataResults = await Promise.allSettled(\n fileIds.map(async (fileId) => {\n try {\n const response = await drive.files.get({\n fileId: fileId,\n fields: 'id,name,parents,webViewLink',\n });\n const webViewLink = response.data.webViewLink as string | undefined;\n return {\n fileId: fileId,\n name: (response.data.name as string | undefined) || fileId,\n parents: (response.data.parents as string[] | undefined) || [],\n ...(webViewLink && { webViewLink }),\n };\n } catch (e: unknown) {\n const message = isDriveApiError(e) && e.message ? e.message : String(e);\n throw new Error(`Failed to fetch metadata: ${message}`);\n }\n })\n );\n\n // Process metadata results\n const filesToMove: Array<{\n fileId: string;\n name: string;\n parents: string[];\n webViewLink?: string;\n }> = [];\n for (let i = 0; i < metadataResults.length; i++) {\n const result = metadataResults[i];\n if (result && result.status === 'fulfilled') {\n filesToMove.push(result.value);\n } else if (result && result.status === 'rejected') {\n const fileId = fileIds[i];\n if (fileId) {\n const errorCode = result.reason?.code ? String(result.reason.code) : undefined;\n failed.push({\n fileId: fileId,\n error: result.reason?.message || 'Failed to fetch file metadata',\n ...(errorCode && { code: errorCode }),\n });\n }\n }\n }\n\n // Now move files in batch\n const moveResults = await Promise.allSettled(\n filesToMove.map(async (file) => {\n try {\n await drive.files.update({\n fileId: file.fileId,\n addParents: destinationFolderId,\n removeParents: file.parents.join(','),\n fields: 'id',\n });\n return {\n fileId: file.fileId,\n fileName: file.name,\n oldParents: returnOldParents ? file.parents : [],\n newParent: destinationFolderId,\n ...(file.webViewLink && { webViewLink: file.webViewLink }),\n };\n } catch (e: unknown) {\n const message = isDriveApiError(e) && e.message ? e.message : String(e);\n throw new Error(`Failed to move: ${message}`);\n }\n })\n );\n\n // Process move results\n for (let i = 0; i < moveResults.length; i++) {\n const result = moveResults[i];\n if (result && result.status === 'fulfilled') {\n moved.push(result.value);\n } else if (result && result.status === 'rejected') {\n const file = filesToMove[i];\n if (file) {\n const errorCode = result.reason?.code ? String(result.reason.code) : undefined;\n failed.push({\n fileId: file.fileId,\n error: result.reason?.message || 'Failed to move file',\n ...(errorCode && { code: errorCode }),\n });\n }\n }\n }\n\n return { moved, failed };\n}\n\nasync function handler({ fileIds, destinationFolderId, returnOldParents = true }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n const isBatch = Array.isArray(fileIds);\n const fileIdArray = Array.isArray(fileIds) ? fileIds : [fileIds];\n\n logger.info('drive.file.move called', {\n fileCount: fileIdArray.length,\n isBatch,\n destinationFolderId,\n returnOldParents,\n });\n\n try {\n const drive = google.drive({ version: 'v3', auth: extra.authContext.auth });\n\n let moved: MoveResult[] = [];\n let failed: FailedMove[] = [];\n\n if (isBatch && fileIdArray.length > 1) {\n // Use batch API for multiple files\n const batchResult = await moveBatchFiles(drive, fileIdArray, destinationFolderId, returnOldParents, logger);\n moved = batchResult.moved;\n failed = batchResult.failed;\n } else {\n // Single file operation\n const fileId = fileIdArray[0];\n if (fileId) {\n const singleResult = await moveSingleFile(drive, fileId, destinationFolderId, returnOldParents, logger);\n if (singleResult.success && singleResult.result) {\n moved.push(singleResult.result);\n } else if (singleResult.error) {\n failed.push(singleResult.error);\n }\n }\n }\n\n logger.info('drive.file.move returning', {\n totalRequested: fileIdArray.length,\n totalMoved: moved.length,\n totalFailed: failed.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n moved,\n ...(failed.length > 0 && { failed }),\n totalRequested: fileIdArray.length,\n totalMoved: moved.length,\n totalFailed: failed.length,\n };\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result),\n },\n ],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('drive.file.move error', { error: message });\n\n // Throw McpError\n throw new McpError(ErrorCode.InternalError, `Error moving files: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'file-move' as const,\n config,\n handler,\n };\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","isDriveApiError","error","inputSchema","z","object","fileIds","union","string","min","array","max","describe","destinationFolderId","returnOldParents","boolean","optional","successBranchSchema","type","literal","moved","fileId","fileName","oldParents","newParent","webViewLink","failed","code","totalRequested","number","totalMoved","totalFailed","outputSchema","discriminatedUnion","config","title","description","result","moveSingleFile","drive","logger","fileMetadata","e","errorMessage","errorCode","files","get","fields","data","parents","name","update","addParents","removeParents","join","success","message","String","undefined","info","moveBatchFiles","_logger","metadataResults","filesToMove","i","moveResults","file","Promise","allSettled","map","response","Error","length","status","push","value","reason","handler","extra","isBatch","fileIdArray","batchResult","singleResult","Array","isArray","fileCount","google","version","auth","authContext","content","text","JSON","stringify","structuredContent","McpError","ErrorCode","InternalError","stack"],"mappings":";;;;+BAiUA;;;eAAwBA;;;2BAhUA;qBAIiC;0BAElC;mBACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAO8C,MAAM,GAAG,KAAK;wBAAE9C,QAAAA;oBAAO;wBAClCE,gBAAgBoD,YAAYR,MAAM;wBAClC1C,YAAYV,MAAMoD,MAAM;wBACxBzC,aAAaL,OAAO8C,MAAM;;oBAG5B;;wBAAO;4BACLkB,OAAO;gCACL;oCACExE,MAAM;oCACNyE,MAAMC,KAAKC,SAAS,CAACxD;gCACvB;;4BAEFyD,mBAAmB;gCAAEzD,QAAAA;4BAAO;wBAC9B;;;oBACOnC;oBACDsD,UAAUtD,AAAK,YAALA,OAAiBqE,SAAQrE,MAAMsD,OAAO,GAAGC,OAAOvD;oBAChEsC,OAAOtC,KAAK,CAAC,yBAAyB;wBAAEA,OAAOsD;oBAAQ;oBAEvD,iBAAiB;oBACjB,MAAM,IAAIuC,eAAQ,CAACC,gBAAS,CAACC,aAAa,EAAE,AAAC,uBAA8B,OAARzC,UAAW;wBAC5E0C,OAAOhG,AAAK,YAALA,OAAiBqE,SAAQrE,MAAMgG,KAAK,GAAGxC;oBAChD;;;;;;;IAEJ;;AAEe,SAAS5D;IACtB,OAAO;QACLoD,MAAM;QACNhB,QAAAA;QACA2C,SAAAA;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/mcp/tools/file-move.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { drive_v3 } from '@googleapis/drive';\nimport { drive as driveApi } from '@googleapis/drive';\nimport { type CallToolResult, ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { z } from 'zod';\nimport { googleAuth } from '../../lib/google-auth.ts';\nimport type { Logger } from '../../types.ts';\n\n// Type guard for Google Drive API errors\ninterface DriveApiError {\n message?: string;\n code?: number | string;\n}\n\nfunction isDriveApiError(error: unknown): error is DriveApiError {\n return typeof error === 'object' && error !== null && ('message' in error || 'code' in error);\n}\n\n// Types for results\ninterface MoveResult {\n fileId: string;\n fileName: string;\n oldParents: string[];\n newParent: string;\n webViewLink?: string;\n}\n\ninterface FailedMove {\n fileId: string;\n error: string;\n code?: string;\n}\n\nconst inputSchema = z.object({\n fileIds: z.union([z.string().min(1), z.array(z.string().min(1)).min(1).max(100)]).describe('File or folder ID(s) to move. Single ID or array (max 100 for batch)'),\n destinationFolderId: z.string().min(1).describe('Destination folder ID (use \"root\" for My Drive root)'),\n returnOldParents: z.boolean().optional().describe('Include old parent IDs in response for manual undo (recommended: true)'),\n});\n\n// Success branch schema\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n moved: z\n .array(\n z.object({\n fileId: z.string().describe('ID of the moved file'),\n fileName: z.string().describe('Name of the moved file'),\n oldParents: z.array(z.string()).describe('Previous parent folder IDs (for undo)'),\n newParent: z.string().describe('New parent folder ID'),\n webViewLink: z.string().optional().describe('URL to view the file'),\n })\n )\n .describe('Successfully moved files'),\n failed: z\n .array(\n z.object({\n fileId: z.string().describe('ID of the file that failed to move'),\n error: z.string().describe('Error message explaining the failure'),\n code: z.string().optional().describe('API error code if available'),\n })\n )\n .optional()\n .describe('Files that failed to move'),\n totalRequested: z.number().describe('Total number of files requested to move'),\n totalMoved: z.number().describe('Number of files successfully moved'),\n totalFailed: z.number().describe('Number of files that failed to move'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n title: 'Move Files',\n description: 'Move files/folders to destination folder. Returns oldParents for undo. Use \"root\" for My Drive root.',\n inputSchema: inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\n/**\n * Move a single file to a new parent folder\n */\nasync function moveSingleFile(\n drive: drive_v3.Drive,\n fileId: string,\n destinationFolderId: string,\n returnOldParents: boolean,\n logger: Logger\n): Promise<{\n success: boolean;\n result?: MoveResult;\n error?: FailedMove;\n}> {\n try {\n // Get current file metadata to get old parents\n const fileMetadata = await drive.files.get({\n fileId: fileId,\n fields: 'id,name,parents,webViewLink',\n supportsAllDrives: true,\n });\n\n const oldParents = (fileMetadata.data.parents as string[] | undefined) || [];\n const fileName = (fileMetadata.data.name as string | undefined) || fileId;\n const webViewLink = fileMetadata.data.webViewLink as string | undefined;\n\n // Move file using addParents and removeParents\n await drive.files.update({\n fileId: fileId,\n addParents: destinationFolderId,\n removeParents: oldParents.join(','),\n fields: 'id,name,parents,webViewLink',\n supportsAllDrives: true,\n });\n\n const result: MoveResult = {\n fileId: fileId,\n fileName: fileName,\n oldParents: returnOldParents ? oldParents : [],\n newParent: destinationFolderId,\n ...(webViewLink && { webViewLink }),\n };\n\n return { success: true, result };\n } catch (e: unknown) {\n const errorMessage = isDriveApiError(e) && e.message ? e.message : 'Unknown error';\n const errorCode = isDriveApiError(e) && e.code ? String(e.code) : undefined;\n logger.info('Failed to move file', { fileId, error: errorMessage });\n return {\n success: false,\n error: {\n fileId: fileId,\n error: errorMessage,\n ...(errorCode && { code: errorCode }),\n },\n };\n }\n}\n\n/**\n * Move multiple files using batch requests\n */\nasync function moveBatchFiles(\n drive: drive_v3.Drive,\n fileIds: string[],\n destinationFolderId: string,\n returnOldParents: boolean,\n _logger: Logger\n): Promise<{\n moved: MoveResult[];\n failed: FailedMove[];\n}> {\n const moved: MoveResult[] = [];\n const failed: FailedMove[] = [];\n\n // First, fetch metadata for all files in batch\n const metadataResults = await Promise.allSettled(\n fileIds.map(async (fileId) => {\n try {\n const response = await drive.files.get({\n fileId: fileId,\n fields: 'id,name,parents,webViewLink',\n supportsAllDrives: true,\n });\n const webViewLink = response.data.webViewLink as string | undefined;\n return {\n fileId: fileId,\n name: (response.data.name as string | undefined) || fileId,\n parents: (response.data.parents as string[] | undefined) || [],\n ...(webViewLink && { webViewLink }),\n };\n } catch (e: unknown) {\n const message = isDriveApiError(e) && e.message ? e.message : String(e);\n throw new Error(`Failed to fetch metadata: ${message}`);\n }\n })\n );\n\n // Process metadata results\n const filesToMove: Array<{\n fileId: string;\n name: string;\n parents: string[];\n webViewLink?: string;\n }> = [];\n for (let i = 0; i < metadataResults.length; i++) {\n const result = metadataResults[i];\n if (result && result.status === 'fulfilled') {\n filesToMove.push(result.value);\n } else if (result && result.status === 'rejected') {\n const fileId = fileIds[i];\n if (fileId) {\n const errorCode = result.reason?.code ? String(result.reason.code) : undefined;\n failed.push({\n fileId: fileId,\n error: result.reason?.message || 'Failed to fetch file metadata',\n ...(errorCode && { code: errorCode }),\n });\n }\n }\n }\n\n // Now move files in batch\n const moveResults = await Promise.allSettled(\n filesToMove.map(async (file) => {\n try {\n await drive.files.update({\n fileId: file.fileId,\n addParents: destinationFolderId,\n removeParents: file.parents.join(','),\n fields: 'id',\n supportsAllDrives: true,\n });\n return {\n fileId: file.fileId,\n fileName: file.name,\n oldParents: returnOldParents ? file.parents : [],\n newParent: destinationFolderId,\n ...(file.webViewLink && { webViewLink: file.webViewLink }),\n };\n } catch (e: unknown) {\n const message = isDriveApiError(e) && e.message ? e.message : String(e);\n throw new Error(`Failed to move: ${message}`);\n }\n })\n );\n\n // Process move results\n for (let i = 0; i < moveResults.length; i++) {\n const result = moveResults[i];\n if (result && result.status === 'fulfilled') {\n moved.push(result.value);\n } else if (result && result.status === 'rejected') {\n const file = filesToMove[i];\n if (file) {\n const errorCode = result.reason?.code ? String(result.reason.code) : undefined;\n failed.push({\n fileId: file.fileId,\n error: result.reason?.message || 'Failed to move file',\n ...(errorCode && { code: errorCode }),\n });\n }\n }\n }\n\n return { moved, failed };\n}\n\nasync function handler({ fileIds, destinationFolderId, returnOldParents = true }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n const isBatch = Array.isArray(fileIds);\n const fileIdArray = Array.isArray(fileIds) ? fileIds : [fileIds];\n\n logger.info('drive.file.move called', {\n fileCount: fileIdArray.length,\n isBatch,\n destinationFolderId,\n returnOldParents,\n });\n\n try {\n const drive = driveApi({ version: 'v3', auth: googleAuth(extra.authContext.auth) });\n\n let moved: MoveResult[] = [];\n let failed: FailedMove[] = [];\n\n if (isBatch && fileIdArray.length > 1) {\n // Use batch API for multiple files\n const batchResult = await moveBatchFiles(drive, fileIdArray, destinationFolderId, returnOldParents, logger);\n moved = batchResult.moved;\n failed = batchResult.failed;\n } else {\n // Single file operation\n const fileId = fileIdArray[0];\n if (fileId) {\n const singleResult = await moveSingleFile(drive, fileId, destinationFolderId, returnOldParents, logger);\n if (singleResult.success && singleResult.result) {\n moved.push(singleResult.result);\n } else if (singleResult.error) {\n failed.push(singleResult.error);\n }\n }\n }\n\n logger.info('drive.file.move returning', {\n totalRequested: fileIdArray.length,\n totalMoved: moved.length,\n totalFailed: failed.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n moved,\n ...(failed.length > 0 && { failed }),\n totalRequested: fileIdArray.length,\n totalMoved: moved.length,\n totalFailed: failed.length,\n };\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result),\n },\n ],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('drive.file.move error', { error: message });\n\n // Throw ProtocolError\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error moving files: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'file-move' as const,\n config,\n handler,\n };\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","isDriveApiError","error","inputSchema","z","object","fileIds","union","string","min","array","max","describe","destinationFolderId","returnOldParents","boolean","optional","successBranchSchema","type","literal","moved","fileId","fileName","oldParents","newParent","webViewLink","failed","code","totalRequested","number","totalMoved","totalFailed","outputSchema","discriminatedUnion","config","title","description","result","moveSingleFile","drive","logger","fileMetadata","e","errorMessage","errorCode","files","get","fields","supportsAllDrives","data","parents","name","update","addParents","removeParents","join","success","message","String","undefined","info","moveBatchFiles","_logger","metadataResults","filesToMove","i","moveResults","file","Promise","allSettled","map","response","Error","length","status","push","value","reason","handler","extra","isBatch","fileIdArray","batchResult","singleResult","Array","isArray","fileCount","driveApi","version","auth","googleAuth","authContext","content","text","JSON","stringify","structuredContent","ProtocolError","ProtocolErrorCode","InternalError","stack"],"mappings":";;;;+BAsUA;;;eAAwBA;;;2BArUA;qBAKU;sBACoC;mBACpD;4BACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAN3B,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAeR,SAASE,gBAAgBC,KAAc;IACrC,OAAO,CAAA,OAAOA,sCAAP,SAAOA,MAAI,MAAM,YAAYA,UAAU,QAAS,CAAA,aAAaA,SAAS,UAAUA,KAAI;AAC7F;AAiBA,IAAMC,cAAcC,MAAC,CAACC,MAAM,CAAC;IAC3BC,SAASF,MAAC,CAACG,KAAK,CAAC;QAACH,MAAC,CAACI,MAAM,GAAGC,GAAG,CAAC;QAAIL,MAAC,CAACM,KAAK,CAACN,MAAC,CAACI,MAAM,GAAGC,GAAG,CAAC,IAAIA,GAAG,CAAC,GAAGE,GAAG,CAAC;KAAK,EAAEC,QAAQ,CAAC;IAC3FC,qBAAqBT,MAAC,CAACI,MAAM,GAAGC,GAAG,CAAC,GAAGG,QAAQ,CAAC;IAChDE,kBAAkBV,MAAC,CAACW,OAAO,GAAGC,QAAQ,GAAGJ,QAAQ,CAAC;AACpD;AAEA,wBAAwB;AACxB,IAAMK,sBAAsBb,MAAC,CAACC,MAAM,CAAC;IACnCa,MAAMd,MAAC,CAACe,OAAO,CAAC;IAChBC,OAAOhB,MAAC,CACLM,KAAK,CACJN,MAAC,CAACC,MAAM,CAAC;QACPgB,QAAQjB,MAAC,CAACI,MAA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C,eAAe;oBACrB,IAAIA,aAAa3B,OAAO,IAAI2B,aAAa9C,MAAM,EAAE;wBAC/CjB,MAAMuD,IAAI,CAACQ,aAAa9C,MAAM;oBAChC,OAAO,IAAI8C,aAAajF,KAAK,EAAE;wBAC7BwB,OAAOiD,IAAI,CAACQ,aAAajF,KAAK;oBAChC;;;oBAIJsC,OAAOoB,IAAI,CAAC,6BAA6B;wBACvChC,gBAAgBqD,YAAYR,MAAM;wBAClC3C,YAAYV,MAAMqD,MAAM;wBACxB1C,aAAaL,OAAO+C,MAAM;oBAC5B;oBAEMpC,SAAiB;wBACrBnB,MAAM;wBACNE,OAAAA;uBACIM,OAAO+C,MAAM,GAAG,KAAK;wBAAE/C,QAAAA;oBAAO;wBAClCE,gBAAgBqD,YAAYR,MAAM;wBAClC3C,YAAYV,MAAMqD,MAAM;wBACxB1C,aAAaL,OAAO+C,MAAM;;oBAG5B;;wBAAO;4BACLmB,OAAO;gCACL;oCACE1E,MAAM;oCACN2E,MAAMC,KAAKC,SAAS,CAAC1D;gCACvB;;4BAEF2D,mBAAmB;gCAAE3D,QAAAA;4BAAO;wBAC9B;;;oBACOnC;oBACDuD,UAAUvD,AAAK,YAALA,OAAiBsE,SAAQtE,MAAMuD,OAAO,GAAGC,OAAOxD;oBAChEsC,OAAOtC,KAAK,CAAC,yBAAyB;wBAAEA,OAAOuD;oBAAQ;oBAEvD,sBAAsB;oBACtB,MAAM,IAAIwC,qBAAa,CAACC,yBAAiB,CAACC,aAAa,EAAE,AAAC,uBAA8B,OAAR1C,UAAW;wBACzF2C,OAAOlG,AAAK,YAALA,OAAiBsE,SAAQtE,MAAMkG,KAAK,GAAGzC;oBAChD;;;;;;;IAEJ;;AAEe,SAAS7D;IACtB,OAAO;QACLqD,MAAM;QACNjB,QAAAA;QACA4C,SAAAA;IACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import type { EnrichedExtra } from '@mcp-z/oauth-google';
2
- import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import type { CallToolResult } from '@mcp-z/server';
3
3
  import { z } from 'zod';
4
4
  declare const inputSchema: z.ZodObject<{
5
5
  sourceUri: z.ZodString;
@@ -1,5 +1,5 @@
1
1
  import type { EnrichedExtra } from '@mcp-z/oauth-google';
2
- import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import type { CallToolResult } from '@mcp-z/server';
3
3
  import { z } from 'zod';
4
4
  declare const inputSchema: z.ZodObject<{
5
5
  sourceUri: z.ZodString;
@@ -9,10 +9,11 @@ Object.defineProperty(exports, "default", {
9
9
  }
10
10
  });
11
11
  var _oauthgoogle = require("@mcp-z/oauth-google");
12
- var _types = require("@modelcontextprotocol/sdk/types.js");
13
- var _googleapis = require("googleapis");
12
+ var _drive = require("@googleapis/drive");
13
+ var _server = require("@mcp-z/server");
14
14
  var _zod = require("zod");
15
15
  var _filestreamingts = require("../../lib/file-streaming.js");
16
+ var _googleauthts = require("../../lib/google-auth.js");
16
17
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
17
18
  try {
18
19
  var info = gen[key](arg);
@@ -227,9 +228,9 @@ function handler(_0, _1) {
227
228
  ,
228
229
  10
229
230
  ]);
230
- drive = _googleapis.google.drive({
231
+ drive = (0, _drive.drive)({
231
232
  version: 'v3',
232
- auth: extra.authContext.auth
233
+ auth: (0, _googleauthts.googleAuth)(extra.authContext.auth)
233
234
  });
234
235
  return [
235
236
  4,
@@ -299,7 +300,8 @@ function handler(_0, _1) {
299
300
  4,
300
301
  drive.files.get({
301
302
  fileId: actualParentId,
302
- fields: 'name'
303
+ fields: 'name',
304
+ supportsAllDrives: true
303
305
  })
304
306
  ];
305
307
  case 6:
@@ -365,8 +367,8 @@ function handler(_0, _1) {
365
367
  logger.error('drive.file.upload error', {
366
368
  error: message
367
369
  });
368
- // Throw McpError for proper MCP error handling
369
- throw new _types.McpError(_types.ErrorCode.InternalError, "Error uploading file: ".concat(message), {
370
+ // Throw ProtocolError for proper MCP error handling
371
+ throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error uploading file: ".concat(message), {
370
372
  stack: _instanceof(error, Error) ? error.stack : undefined
371
373
  });
372
374
  case 10: