@mcp-z/mcp-drive 1.1.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/cjs/index.js.map +1 -1
  2. package/dist/cjs/mcp/prompts/query-syntax.d.cts +2 -3
  3. package/dist/cjs/mcp/prompts/query-syntax.d.ts +2 -3
  4. package/dist/cjs/mcp/prompts/query-syntax.js.map +1 -1
  5. package/dist/cjs/mcp/resources/file.d.cts +2 -9
  6. package/dist/cjs/mcp/resources/file.d.ts +2 -9
  7. package/dist/cjs/mcp/resources/file.js +2 -2
  8. package/dist/cjs/mcp/resources/file.js.map +1 -1
  9. package/dist/cjs/mcp/tools/file-move-to-trash.d.cts +1 -1
  10. package/dist/cjs/mcp/tools/file-move-to-trash.d.ts +1 -1
  11. package/dist/cjs/mcp/tools/file-move-to-trash.js +3 -3
  12. package/dist/cjs/mcp/tools/file-move-to-trash.js.map +1 -1
  13. package/dist/cjs/mcp/tools/file-move.d.cts +1 -1
  14. package/dist/cjs/mcp/tools/file-move.d.ts +1 -1
  15. package/dist/cjs/mcp/tools/file-move.js +3 -3
  16. package/dist/cjs/mcp/tools/file-move.js.map +1 -1
  17. package/dist/cjs/mcp/tools/file-upload.d.cts +1 -1
  18. package/dist/cjs/mcp/tools/file-upload.d.ts +1 -1
  19. package/dist/cjs/mcp/tools/file-upload.js +3 -3
  20. package/dist/cjs/mcp/tools/file-upload.js.map +1 -1
  21. package/dist/cjs/mcp/tools/files-search.d.cts +1 -1
  22. package/dist/cjs/mcp/tools/files-search.d.ts +1 -1
  23. package/dist/cjs/mcp/tools/files-search.js +2 -3
  24. package/dist/cjs/mcp/tools/files-search.js.map +1 -1
  25. package/dist/cjs/mcp/tools/folder-contents.d.cts +1 -1
  26. package/dist/cjs/mcp/tools/folder-contents.d.ts +1 -1
  27. package/dist/cjs/mcp/tools/folder-contents.js +2 -3
  28. package/dist/cjs/mcp/tools/folder-contents.js.map +1 -1
  29. package/dist/cjs/mcp/tools/folder-create.d.cts +1 -1
  30. package/dist/cjs/mcp/tools/folder-create.d.ts +1 -1
  31. package/dist/cjs/mcp/tools/folder-create.js +3 -3
  32. package/dist/cjs/mcp/tools/folder-create.js.map +1 -1
  33. package/dist/cjs/mcp/tools/folder-path.d.cts +1 -1
  34. package/dist/cjs/mcp/tools/folder-path.d.ts +1 -1
  35. package/dist/cjs/mcp/tools/folder-path.js +3 -3
  36. package/dist/cjs/mcp/tools/folder-path.js.map +1 -1
  37. package/dist/cjs/mcp/tools/folder-search.d.cts +1 -1
  38. package/dist/cjs/mcp/tools/folder-search.d.ts +1 -1
  39. package/dist/cjs/mcp/tools/folder-search.js +2 -3
  40. package/dist/cjs/mcp/tools/folder-search.js.map +1 -1
  41. package/dist/cjs/setup/http.d.cts +1 -1
  42. package/dist/cjs/setup/http.d.ts +1 -1
  43. package/dist/cjs/setup/http.js +1 -2
  44. package/dist/cjs/setup/http.js.map +1 -1
  45. package/dist/cjs/setup/stdio.d.cts +1 -1
  46. package/dist/cjs/setup/stdio.d.ts +1 -1
  47. package/dist/cjs/setup/stdio.js +1 -2
  48. package/dist/cjs/setup/stdio.js.map +1 -1
  49. package/dist/esm/index.js +1 -1
  50. package/dist/esm/index.js.map +1 -1
  51. package/dist/esm/mcp/prompts/query-syntax.d.ts +2 -3
  52. package/dist/esm/mcp/prompts/query-syntax.js.map +1 -1
  53. package/dist/esm/mcp/resources/file.d.ts +2 -9
  54. package/dist/esm/mcp/resources/file.js +1 -1
  55. package/dist/esm/mcp/resources/file.js.map +1 -1
  56. package/dist/esm/mcp/tools/file-move-to-trash.d.ts +1 -1
  57. package/dist/esm/mcp/tools/file-move-to-trash.js +3 -3
  58. package/dist/esm/mcp/tools/file-move-to-trash.js.map +1 -1
  59. package/dist/esm/mcp/tools/file-move.d.ts +1 -1
  60. package/dist/esm/mcp/tools/file-move.js +3 -3
  61. package/dist/esm/mcp/tools/file-move.js.map +1 -1
  62. package/dist/esm/mcp/tools/file-upload.d.ts +1 -1
  63. package/dist/esm/mcp/tools/file-upload.js +3 -3
  64. package/dist/esm/mcp/tools/file-upload.js.map +1 -1
  65. package/dist/esm/mcp/tools/files-search.d.ts +1 -1
  66. package/dist/esm/mcp/tools/files-search.js +3 -4
  67. package/dist/esm/mcp/tools/files-search.js.map +1 -1
  68. package/dist/esm/mcp/tools/folder-contents.d.ts +1 -1
  69. package/dist/esm/mcp/tools/folder-contents.js +3 -4
  70. package/dist/esm/mcp/tools/folder-contents.js.map +1 -1
  71. package/dist/esm/mcp/tools/folder-create.d.ts +1 -1
  72. package/dist/esm/mcp/tools/folder-create.js +3 -3
  73. package/dist/esm/mcp/tools/folder-create.js.map +1 -1
  74. package/dist/esm/mcp/tools/folder-path.d.ts +1 -1
  75. package/dist/esm/mcp/tools/folder-path.js +3 -3
  76. package/dist/esm/mcp/tools/folder-path.js.map +1 -1
  77. package/dist/esm/mcp/tools/folder-search.d.ts +1 -1
  78. package/dist/esm/mcp/tools/folder-search.js +3 -4
  79. package/dist/esm/mcp/tools/folder-search.js.map +1 -1
  80. package/dist/esm/setup/http.d.ts +1 -1
  81. package/dist/esm/setup/http.js +1 -2
  82. package/dist/esm/setup/http.js.map +1 -1
  83. package/dist/esm/setup/stdio.d.ts +1 -1
  84. package/dist/esm/setup/stdio.js +1 -2
  85. package/dist/esm/setup/stdio.js.map +1 -1
  86. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/setup/http.ts"],"sourcesContent":["import { composeMiddleware, connectHttp, registerPrompts, registerResources, registerTools } from '@mcp-z/server';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport cors from 'cors';\nimport express from 'express';\nimport type { RuntimeOverrides, ServerConfig } from '../types.ts';\nimport { createDefaultRuntime } from './runtime.ts';\n\nexport async function createHTTPServer(config: ServerConfig, overrides?: RuntimeOverrides) {\n const runtime = await createDefaultRuntime(config, overrides);\n const modules = runtime.createDomainModules();\n const layers = runtime.middlewareFactories.map((factory) => factory(runtime.deps));\n const composed = composeMiddleware(modules, layers);\n const logger = runtime.deps.logger;\n const port = config.transport.port;\n if (!port) throw new Error('Port is required for HTTP transport');\n\n const tools = [...composed.tools, ...runtime.deps.oauthAdapters.accountTools];\n const prompts = [...composed.prompts, ...runtime.deps.oauthAdapters.accountPrompts];\n\n const mcpServer = new McpServer({ name: config.name, version: config.version });\n registerTools(mcpServer, tools);\n registerResources(mcpServer, composed.resources);\n registerPrompts(mcpServer, prompts);\n\n const app = express();\n app.use(express.json({ limit: '10mb' }));\n\n // Must mount '/mcp' before any permissive app-level cors(), or that layer answers its\n // preflight first; pass baseUrl's origin/host below or a public deployment 403s itself.\n const publicUrl = config.baseUrl ? new URL(config.baseUrl) : undefined;\n logger.info(`Starting ${config.name} MCP server (http)`);\n const { close, httpServer } = await connectHttp(mcpServer, {\n logger,\n app,\n port,\n allowedOrigins: publicUrl ? [publicUrl.origin] : undefined,\n allowedHosts: publicUrl ? [publicUrl.host] : undefined,\n });\n\n // The loopback OAuth callback and the DCR discovery/registration endpoints are\n // meant to be reached from a browser on another origin. Keep cors() for them,\n // scoped to their own routes - never in front of '/mcp'.\n if (runtime.deps.oauthAdapters.loopbackRouter) {\n app.use('/', cors(), runtime.deps.oauthAdapters.loopbackRouter);\n logger.info('Mounted loopback OAuth callback router');\n }\n\n if (runtime.deps.oauthAdapters.dcrRouter) {\n app.use('/', cors(), runtime.deps.oauthAdapters.dcrRouter);\n logger.info('Mounted DCR router with OAuth endpoints');\n }\n\n logger.info('http transport ready');\n\n return {\n httpServer,\n mcpServer,\n logger,\n close: async () => {\n await close();\n await runtime.close();\n },\n };\n}\n"],"names":["createHTTPServer","config","overrides","runtime","modules","layers","composed","logger","port","tools","prompts","mcpServer","app","publicUrl","close","httpServer","createDefaultRuntime","createDomainModules","middlewareFactories","map","factory","deps","composeMiddleware","transport","Error","oauthAdapters","accountTools","accountPrompts","McpServer","name","version","registerTools","registerResources","resources","registerPrompts","express","use","json","limit","baseUrl","URL","undefined","info","connectHttp","allowedOrigins","origin","allowedHosts","host","loopbackRouter","cors","dcrRouter"],"mappings":";;;;+BAOsBA;;;eAAAA;;;sBAP4E;mBACxE;2DACT;8DACG;yBAEiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9B,SAAeA,iBAAiBC,MAAoB,EAAEC,SAA4B;;YACjFC,SACAC,SACAC,QACAC,UACAC,QACAC,MAGAC,OACAC,SAEAC,WAKAC,KAKAC,WAEwB,MAAtBC,OAAOC;;;;oBAvBC;;wBAAMC,IAAAA,+BAAoB,EAACf,QAAQC;;;oBAA7CC,UAAU;oBACVC,UAAUD,QAAQc,mBAAmB;oBACrCZ,SAASF,QAAQe,mBAAmB,CAACC,GAAG,CAAC,SAACC;+BAAYA,QAAQjB,QAAQkB,IAAI;;oBAC1Ef,WAAWgB,IAAAA,yBAAiB,EAAClB,SAASC;oBACtCE,SAASJ,QAAQkB,IAAI,CAACd,MAAM;oBAC5BC,OAAOP,OAAOsB,SAAS,CAACf,IAAI;oBAClC,IAAI,CAACA,MAAM,MAAM,IAAIgB,MAAM;oBAErBf,QAAQ,AAAC,qBAAGH,SAASG,KAAK,SAAE,qBAAGN,QAAQkB,IAAI,CAACI,aAAa,CAACC,YAAY;oBACtEhB,UAAU,AAAC,qBAAGJ,SAASI,OAAO,SAAE,qBAAGP,QAAQkB,IAAI,CAACI,aAAa,CAACE,cAAc;oBAE5EhB,YAAY,IAAIiB,cAAS,CAAC;wBAAEC,MAAM5B,OAAO4B,IAAI;wBAAEC,SAAS7B,OAAO6B,OAAO;oBAAC;oBAC7EC,IAAAA,qBAAa,EAACpB,WAAWF;oBACzBuB,IAAAA,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AQW,KAAK;;;gDAAnB;;;;;;gCACF;;wBACF;;;;IACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/setup/http.ts"],"sourcesContent":["import { composeMiddleware, connectHttp, McpServer, registerPrompts, registerResources, registerTools } from '@mcp-z/server';\nimport cors from 'cors';\nimport express from 'express';\nimport type { RuntimeOverrides, ServerConfig } from '../types.ts';\nimport { createDefaultRuntime } from './runtime.ts';\n\nexport async function createHTTPServer(config: ServerConfig, overrides?: RuntimeOverrides) {\n const runtime = await createDefaultRuntime(config, overrides);\n const modules = runtime.createDomainModules();\n const layers = runtime.middlewareFactories.map((factory) => factory(runtime.deps));\n const composed = composeMiddleware(modules, layers);\n const logger = runtime.deps.logger;\n const port = config.transport.port;\n if (!port) throw new Error('Port is required for HTTP transport');\n\n const tools = [...composed.tools, ...runtime.deps.oauthAdapters.accountTools];\n const prompts = [...composed.prompts, ...runtime.deps.oauthAdapters.accountPrompts];\n\n const mcpServer = new McpServer({ name: config.name, version: config.version });\n registerTools(mcpServer, tools);\n registerResources(mcpServer, composed.resources);\n registerPrompts(mcpServer, prompts);\n\n const app = express();\n app.use(express.json({ limit: '10mb' }));\n\n // Must mount '/mcp' before any permissive app-level cors(), or that layer answers its\n // preflight first; pass baseUrl's origin/host below or a public deployment 403s itself.\n const publicUrl = config.baseUrl ? new URL(config.baseUrl) : undefined;\n logger.info(`Starting ${config.name} MCP server (http)`);\n const { close, httpServer } = await connectHttp(mcpServer, {\n logger,\n app,\n port,\n allowedOrigins: publicUrl ? [publicUrl.origin] : undefined,\n allowedHosts: publicUrl ? [publicUrl.host] : undefined,\n });\n\n // The loopback OAuth callback and the DCR discovery/registration endpoints are\n // meant to be reached from a browser on another origin. Keep cors() for them,\n // scoped to their own routes - never in front of '/mcp'.\n if (runtime.deps.oauthAdapters.loopbackRouter) {\n app.use('/', cors(), runtime.deps.oauthAdapters.loopbackRouter);\n logger.info('Mounted loopback OAuth callback router');\n }\n\n if (runtime.deps.oauthAdapters.dcrRouter) {\n app.use('/', cors(), runtime.deps.oauthAdapters.dcrRouter);\n logger.info('Mounted DCR router with OAuth endpoints');\n }\n\n logger.info('http transport ready');\n\n return {\n httpServer,\n mcpServer,\n logger,\n close: async () => {\n await close();\n await runtime.close();\n },\n };\n}\n"],"names":["createHTTPServer","config","overrides","runtime","modules","layers","composed","logger","port","tools","prompts","mcpServer","app","publicUrl","close","httpServer","createDefaultRuntime","createDomainModules","middlewareFactories","map","factory","deps","composeMiddleware","transport","Error","oauthAdapters","accountTools","accountPrompts","McpServer","name","version","registerTools","registerResources","resources","registerPrompts","express","use","json","limit","baseUrl","URL","undefined","info","connectHttp","allowedOrigins","origin","allowedHosts","host","loopbackRouter","cors","dcrRouter"],"mappings":";;;;+BAMsBA;;;eAAAA;;;sBANuF;2DAC5F;8DACG;yBAEiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9B,SAAeA,iBAAiBC,MAAoB,EAAEC,SAA4B;;YACjFC,SACAC,SACAC,QACAC,UACAC,QACAC,MAGAC,OACAC,SAEAC,WAKAC,KAKAC,WAEwB,MAAtBC,OAAOC;;;;oBAvBC;;wBAAMC,IAAAA,+BAAoB,EAACf,QAAQC;;;oBAA7CC,UAAU;oBACVC,UAAUD,QAAQc,mBAAmB;oBACrCZ,SAASF,QAAQe,mBAAmB,CAACC,GAAG,CAAC,SAACC;+BAAYA,QAAQjB,QAAQkB,IAAI;;oBAC1Ef,WAAWgB,IAAAA,yBAAiB,EAAClB,SAASC;oBACtCE,SAASJ,QAAQkB,IAAI,CAACd,MAAM;oBAC5BC,OAAOP,OAAOsB,SAAS,CAACf,IAAI;oBAClC,IAAI,CAACA,MAAM,MAAM,IAAIgB,MAAM;o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A,IAAIvC,QAAQkB,IAAI,CAACI,aAAa,CAACyB,SAAS,EAAE;wBACxCtC,IAAIwB,GAAG,CAAC,KAAKa,IAAAA,aAAI,KAAI9C,QAAQkB,IAAI,CAACI,aAAa,CAACyB,SAAS;wBACzD3C,OAAOmC,IAAI,CAAC;oBACd;oBAEAnC,OAAOmC,IAAI,CAAC;oBAEZ;;wBAAO;4BACL3B,YAAAA;4BACAJ,WAAAA;4BACAJ,QAAAA;4BACAO,OAAO,SAAPA;;;;;gDACE;;oDAAMA;;;gDAAN;gDACA;;oDAAMX,QAAQW,KAAK;;;gDAAnB;;;;;;gCACF;;wBACF;;;;IACF"}
@@ -1,4 +1,4 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
1
+ import { McpServer } from '@mcp-z/server';
2
2
  import type { RuntimeOverrides, ServerConfig } from '../types.js';
3
3
  export declare function createStdioServer(config: ServerConfig, overrides?: RuntimeOverrides): Promise<{
4
4
  mcpServer: McpServer;
@@ -1,4 +1,4 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
1
+ import { McpServer } from '@mcp-z/server';
2
2
  import type { RuntimeOverrides, ServerConfig } from '../types.js';
3
3
  export declare function createStdioServer(config: ServerConfig, overrides?: RuntimeOverrides): Promise<{
4
4
  mcpServer: McpServer;
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "createStdioServer", {
9
9
  }
10
10
  });
11
11
  var _server = require("@mcp-z/server");
12
- var _mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
13
12
  var _runtimets = require("./runtime.js");
14
13
  function _array_like_to_array(arr, len) {
15
14
  if (len == null || len > arr.length) len = arr.length;
@@ -183,7 +182,7 @@ function createStdioServer(config, overrides) {
183
182
  logger = runtime.deps.logger;
184
183
  tools = _to_consumable_array(composed.tools).concat(_to_consumable_array(runtime.deps.oauthAdapters.accountTools));
185
184
  prompts = _to_consumable_array(composed.prompts).concat(_to_consumable_array(runtime.deps.oauthAdapters.accountPrompts));
186
- mcpServer = new _mcp.McpServer({
185
+ mcpServer = new _server.McpServer({
187
186
  name: config.name,
188
187
  version: config.version
189
188
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/setup/stdio.ts"],"sourcesContent":["import { composeMiddleware, connectStdio, registerPrompts, registerResources, registerTools } from '@mcp-z/server';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { RuntimeOverrides, ServerConfig } from '../types.ts';\nimport { createDefaultRuntime } from './runtime.ts';\n\nexport async function createStdioServer(config: ServerConfig, overrides?: RuntimeOverrides) {\n const runtime = await createDefaultRuntime(config, overrides);\n const modules = runtime.createDomainModules();\n const layers = runtime.middlewareFactories.map((factory) => factory(runtime.deps));\n const composed = composeMiddleware(modules, layers);\n const logger = runtime.deps.logger;\n\n const tools = [...composed.tools, ...runtime.deps.oauthAdapters.accountTools];\n const prompts = [...composed.prompts, ...runtime.deps.oauthAdapters.accountPrompts];\n\n const mcpServer = new McpServer({ name: config.name, version: config.version });\n registerTools(mcpServer, tools);\n registerResources(mcpServer, composed.resources);\n registerPrompts(mcpServer, prompts);\n\n logger.info(`Starting ${config.name} MCP server (stdio)`);\n const { close } = await connectStdio(mcpServer, { logger });\n logger.info('stdio transport ready');\n\n return {\n mcpServer,\n logger,\n close: async () => {\n await close();\n await runtime.close();\n },\n };\n}\n"],"names":["createStdioServer","config","overrides","runtime","modules","layers","composed","logger","tools","prompts","mcpServer","close","createDefaultRuntime","createDomainModules","middlewareFactories","map","factory","deps","composeMiddleware","oauthAdapters","accountTools","accountPrompts","McpServer","name","version","registerTools","registerResources","resources","registerPrompts","info","connectStdio"],"mappings":";;;;+BAKsBA;;;eAAAA;;;sBAL6E;mBACzE;yBAEW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/setup/stdio.ts"],"sourcesContent":["import { composeMiddleware, connectStdio, McpServer, registerPrompts, registerResources, registerTools } from '@mcp-z/server';\nimport type { RuntimeOverrides, ServerConfig } from '../types.ts';\nimport { createDefaultRuntime } from './runtime.ts';\n\nexport async function createStdioServer(config: ServerConfig, overrides?: RuntimeOverrides) {\n const runtime = await createDefaultRuntime(config, overrides);\n const modules = runtime.createDomainModules();\n const layers = runtime.middlewareFactories.map((factory) => factory(runtime.deps));\n const composed = composeMiddleware(modules, layers);\n const logger = runtime.deps.logger;\n\n const tools = [...composed.tools, ...runtime.deps.oauthAdapters.accountTools];\n const prompts = [...composed.prompts, ...runtime.deps.oauthAdapters.accountPrompts];\n\n const mcpServer = new McpServer({ name: config.name, version: config.version });\n registerTools(mcpServer, tools);\n registerResources(mcpServer, composed.resources);\n registerPrompts(mcpServer, prompts);\n\n logger.info(`Starting ${config.name} MCP server (stdio)`);\n const { close } = await connectStdio(mcpServer, { logger });\n logger.info('stdio transport ready');\n\n return {\n mcpServer,\n logger,\n close: async () => {\n await close();\n await runtime.close();\n },\n };\n}\n"],"names":["createStdioServer","config","overrides","runtime","modules","layers","composed","logger","tools","prompts","mcpServer","close","createDefaultRuntime","createDomainModules","middlewareFactories","map","factory","deps","composeMiddleware","oauthAdapters","accountTools","accountPrompts","McpServer","name","version","registerTools","registerResources","resources","registerPrompts","info","connectStdio"],"mappings":";;;;+BAIsBA;;;eAAAA;;;sBAJwF;yBAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9B,SAAeA,kBAAkBC,MAAoB,EAAEC,SAA4B;;YAClFC,SACAC,SACAC,QACAC,UACAC,QAEAC,OACAC,SAEAC,WAMEC;;;;oBAfQ;;wBAAMC,IAAAA,+BAAoB,EAACX,QAAQC;;;oBAA7CC,UAAU;oBACVC,UAAUD,QAAQU,mBAAmB;oBACrCR,SAASF,QAAQW,mBAAmB,CAACC,GAAG,CAAC,SAACC;+BAAYA,QAAQb,QAAQc,IAAI;;oBAC1EX,WAAWY,IAAAA,yBAAiB,EAACd,SAASC;oBACtCE,SAASJ,QAAQc,IAAI,CAACV,MAAM;oBAE5BC,QAAQ,AAAC,qBAAGF,SAASE,KAAK,SAAE,qBAAGL,QAAQc,IAAI,CAACE,aAAa,CAACC,YAAY;oBACtEX,UAAU,AAAC,qBAAGH,SAASG,OAAO,SAAE,qBAAGN,QAAQc,IAAI,CAACE,aAAa,CAACE,cAAc;oBAE5EX,YAAY,IAAIY,iBAAS,CAAC;wBAAEC,MAAMtB,OAAOsB,IAAI;wBAAEC,SAASvB,OAAOuB,OAAO;oBAAC;oBAC7EC,IAAAA,qBAAa,EAACf,WAAWF;oBACzBkB,IAAAA,yBAAiB,EAAChB,WAAWJ,SAASqB,SAAS;oBAC/CC,IAAAA,uBAAe,EAAClB,WAAWD;oBAE3BF,OAAOsB,IAAI,CAAC,AAAC,YAAuB,OAAZ5B,OAAOsB,IAAI,EAAC;oBAClB;;wBAAMO,IAAAA,oBAAY,EAACpB,WAAW;4BAAEH,QAAAA;wBAAO;;;oBAAjDI,QAAU,cAAVA;oBACRJ,OAAOsB,IAAI,CAAC;oBAEZ;;wBAAO;4BACLnB,WAAAA;4BACAH,QAAAA;4BACAI,OAAO,SAAPA;;;;;gDACE;;oDAAMA;;;gDAAN;gDACA;;oDAAMR,QAAQQ,KAAK;;;gDAAnB;;;;;;gCACF;;wBACF;;;;IACF"}
package/dist/esm/index.js CHANGED
@@ -8,7 +8,7 @@ import * as _setup from './setup/index.js';
8
8
  export { _setup as setup };
9
9
  export * from './types.js';
10
10
  export async function startServer(config) {
11
- // createHTTPServer/createStdioServer pull in @modelcontextprotocol/sdk and every mcp/tools/*.ts
11
+ // createHTTPServer/createStdioServer pull in @mcp-z/server and every mcp/tools/*.ts
12
12
  // (googleapis included); deferred so a --version/--help run never reaches them.
13
13
  const { createHTTPServer } = await import('./setup/http.js');
14
14
  const { createStdioServer } = await import('./setup/stdio.js');
@@ -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":["handleVersionHelp","GOOGLE_SCOPE","mcp","schemas","setup","startServer","config","createHTTPServer","createStdioServer","logger","close","transport","type","process","on","exit","info","Promise","main","versionHelpResult","argv","handled","console","log","output","createConfig","URL","url","pathname"],"mappings":"AAAA,SAASA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/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 @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":["handleVersionHelp","GOOGLE_SCOPE","mcp","schemas","setup","startServer","config","createHTTPServer","createStdioServer","logger","close","transport","type","process","on","exit","info","Promise","main","versionHelpResult","argv","handled","console","log","output","createConfig","URL","url","pathname"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,0BAA0B;AAG5D,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,sBAAqB,iBAAiB;AAAtC,SAAO,QAAKC,GAAG,GAAuB;AACtC,0BAAyB,qBAAqB;AAA9C,SAAO,YAAKC,OAAO,GAA2B;AAC9C,wBAAuB,mBAAmB;AAA1C,SAAO,UAAKC,KAAK,GAAyB;AAC1C,cAAc,aAAa;AAE3B,OAAO,eAAeC,YAAYC,MAAoB;IACpD,oFAAoF;IACpF,gFAAgF;IAChF,MAAM,EAAEC,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC;IAC1C,MAAM,EAAEC,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC;IAC3C,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGJ,OAAOK,SAAS,CAACC,IAAI,KAAK,UAAU,MAAMJ,kBAAkBF,UAAU,MAAMC,iBAAiBD;IAEvHO,QAAQC,EAAE,CAAC,UAAU;QACnB,MAAMJ;QACNG,QAAQE,IAAI,CAAC;IACf;IAEAN,OAAOO,IAAI,CAAC,CAAC,oBAAoB,EAAEV,OAAOK,SAAS,CAACC,IAAI,CAAC,UAAU,CAAC;IACpE,MAAM,IAAIK,QAAQ,KAAO;AAC3B;AAEA,eAAe,eAAeC;IAC5B,4DAA4D;IAC5D,MAAMC,oBAAoBnB,kBAAkBa,QAAQO,IAAI;IACxD,IAAID,kBAAkBE,OAAO,EAAE;QAC7BC,QAAQC,GAAG,CAACJ,kBAAkBK,MAAM;QACpCX,QAAQE,IAAI,CAAC;IACf;IAEA,kGAAkG;IAClG,8FAA8F;IAC9F,MAAM,EAAEU,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC;IACtC,MAAMnB,SAASmB;IACf,MAAMpB,YAAYC;AACpB;AAEA,IAAIO,QAAQO,IAAI,CAAC,EAAE,KAAK,IAAIM,IAAI,YAAYC,GAAG,EAAEC,QAAQ,EAAE;IACzDV;AACF"}
@@ -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":"AAIA,eAAe,SAASA;IACtB,MAAMC,SAAS;QACbC,aAAa;IACf;IAEA,MAAMC,UAAU,OAAOC,OAAiCC;QACtD,OAAO;YACLC,UAAU;gBACR;oBACEC,MAAM;oBACNC,SAAS;wBACPC,MAAM;wBACNC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2Db,CAAC;oBACG;gBACF;aACD;QACH;IACF;IAEA,OAAO;QACLC,MAAM;QACNV;QACAE;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":"AAEA,eAAe,SAASA;IACtB,MAAMC,SAAS;QACbC,aAAa;IACf;IAEA,MAAMC,UAAU,OAAOC,OAAiCC;QACtD,OAAO;YACLC,UAAU;gBACR;oBACEC,MAAM;oBACNC,SAAS;wBACPC,MAAM;wBACNC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2Db,CAAC;oBACG;gBACF;aACD;QACH;IACF;IAEA,OAAO;QACLC,MAAM;QACNV;QACAE;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,4 +1,4 @@
1
- import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
1
+ import { ResourceTemplate } from '@mcp-z/server';
2
2
  import { google } from 'googleapis';
3
3
  export default function createResource() {
4
4
  const template = new ResourceTemplate('drive://files/{fileId}', {
@@ -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":["ResourceTemplate","google","createResource","template","list","undefined","config","description","mimeType","handler","uri","variables","extra","fileId","Array","isArray","logger","contents","href","text","JSON","stringify","error","authContext","drive","version","auth","resp","files","get","fields","data","debug","fileName","name","message"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,0CAA0C;AAG3E,SAASC,MAAM,QAAQ,aAAa;AAEpC,eAAe,SAASC;IACtB,MAAMC,WAAW,IAAIH,iBAAiB,0BAA0B;QAC9DI,MAAMC;IACR;IACA,MAAMC,SAAyB;QAC7BC,aAAa;QACbC,UAAU;IACZ;IAEA,MAAMC,UAAU,OAAOC,KAAUC,WAA8CC;QAC7E,2DAA2D;QAC3D,MAAMC,SAASC,MAAMC,OAAO,CAACJ,UAAUE,MAAM,IAAIF,UAAUE,MAAM,CAAC,EAAE,GAAGF,UAAUE,MAAM;QAEvF,IAAI;gBAwBFG;YAvBA,yCAAyC;YACzC,IAAI,CAACH,UAAU,OAAOA,WAAW,UAAU;gBACzC,OAAO;oBACLI,UAAU;wBACR;4BACEP,KAAKA,IAAIQ,IAAI;4BACbV,UAAU;4BACVW,MAAMC,KAAKC,SAAS,CAAC;gCACnBC,OAAO;4BACT;wBACF;qBACD;gBACH;YACF;YAEA,sDAAsD;YACtD,MAAM,EAAEN,MAAM,EAAEO,WAAW,EAAE,GAAGX;YAChC,MAAMY,QAAQvB,OAAOuB,KAAK,CAAC;gBAAEC,SAAS;gBAAMC,MAAMH,YAAYG,IAAI;YAAC;YACnE,MAAMC,OAAO,MAAMH,MAAMI,KAAK,CAACC,GAAG,CAAC;gBACjChB;gBACAiB,QAAQ;YACV;YACA,MAAMC,OAAOJ,KAAKI,IAAI;aACtBf,gBAAAA,OAAOgB,KAAK,cAAZhB,oCAAAA,mBAAAA,QAAe;gBAAEH;gBAAQoB,QAAQ,EAAEF,iBAAAA,2BAAAA,KAAMG,IAAI;YAAC,GAAG;YACjD,OAAO;gBACLjB,UAAU;oBACR;wBACEP,KAAKA,IAAIQ,IAAI;wBACbV,UAAU;wBACVW,MAAMC,KAAKC,SAAS,CAACU,QAAQ,CAAC;oBAChC;iBACD;YACH;QACF,EAAE,OAAOT,OAAO;gBAEdN;YADA,MAAM,EAAEA,MAAM,EAAE,GAAGJ;aACnBI,iBAAAA,OAAOgB,KAAK,cAAZhB,qCAAAA,oBAAAA,QAAeM,OAAkC;YACjD,OAAO;gBACLL,UAAU;oBACR;wBACEP,KAAKA,IAAIQ,IAAI;wBACbV,UAAU;wBACVW,MAAMC,KAAKC,SAAS,CAAC;4BAAEC,OAAO,AAACA,MAAgBa,OAAO;wBAAC;oBACzD;iBACD;YACH;QACF;IACF;IAEA,OAAO;QACLD,MAAM;QACN/B;QACAG;QACAG;IACF;AACF"}
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 { ReadResourceResult, ResourceConfig, ResourceModule, ServerContext } from '@mcp-z/server';\nimport { ResourceTemplate } from '@mcp-z/server';\nimport { google } from 'googleapis';\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 = 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":["ResourceTemplate","google","createResource","template","list","undefined","config","description","mimeType","handler","uri","variables","extra","fileId","Array","isArray","logger","contents","href","text","JSON","stringify","error","authContext","drive","version","auth","resp","files","get","fields","data","debug","fileName","name","message"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,gBAAgB;AACjD,SAASC,MAAM,QAAQ,aAAa;AAEpC,eAAe,SAASC;IACtB,MAAMC,WAAW,IAAIH,iBAAiB,0BAA0B;QAC9DI,MAAMC;IACR;IACA,MAAMC,SAAyB;QAC7BC,aAAa;QACbC,UAAU;IACZ;IAEA,MAAMC,UAAU,OAAOC,KAAUC,WAA8CC;QAC7E,2DAA2D;QAC3D,MAAMC,SAASC,MAAMC,OAAO,CAACJ,UAAUE,MAAM,IAAIF,UAAUE,MAAM,CAAC,EAAE,GAAGF,UAAUE,MAAM;QAEvF,IAAI;gBAwBFG;YAvBA,yCAAyC;YACzC,IAAI,CAACH,UAAU,OAAOA,WAAW,UAAU;gBACzC,OAAO;oBACLI,UAAU;wBACR;4BACEP,KAAKA,IAAIQ,IAAI;4BACbV,UAAU;4BACVW,MAAMC,KAAKC,SAAS,CAAC;gCACnBC,OAAO;4BACT;wBACF;qBACD;gBACH;YACF;YAEA,sDAAsD;YACtD,MAAM,EAAEN,MAAM,EAAEO,WAAW,EAAE,GAAGX;YAChC,MAAMY,QAAQvB,OAAOuB,KAAK,CAAC;gBAAEC,SAAS;gBAAMC,MAAMH,YAAYG,IAAI;YAAC;YACnE,MAAMC,OAAO,MAAMH,MAAMI,KAAK,CAACC,GAAG,CAAC;gBACjChB;gBACAiB,QAAQ;YACV;YACA,MAAMC,OAAOJ,KAAKI,IAAI;aACtBf,gBAAAA,OAAOgB,KAAK,cAAZhB,oCAAAA,mBAAAA,QAAe;gBAAEH;gBAAQoB,QAAQ,EAAEF,iBAAAA,2BAAAA,KAAMG,IAAI;YAAC,GAAG;YACjD,OAAO;gBACLjB,UAAU;oBACR;wBACEP,KAAKA,IAAIQ,IAAI;wBACbV,UAAU;wBACVW,MAAMC,KAAKC,SAAS,CAACU,QAAQ,CAAC;oBAChC;iBACD;YACH;QACF,EAAE,OAAOT,OAAO;gBAEdN;YADA,MAAM,EAAEA,MAAM,EAAE,GAAGJ;aACnBI,iBAAAA,OAAOgB,KAAK,cAAZhB,qCAAAA,oBAAAA,QAAeM,OAAkC;YACjD,OAAO;gBACLL,UAAU;oBACR;wBACEP,KAAKA,IAAIQ,IAAI;wBACbV,UAAU;wBACVW,MAAMC,KAAKC,SAAS,CAAC;4BAAEC,OAAO,AAACA,MAAgBa,OAAO;wBAAC;oBACzD;iBACD;YACH;QACF;IACF;IAEA,OAAO;QACLD,MAAM;QACN/B;QACAG;QACAG;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,6 +1,6 @@
1
1
  import { schemas } from '@mcp-z/oauth-google';
2
2
  const { AuthRequiredBranchSchema } = schemas;
3
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
3
+ import { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';
4
4
  import { google } from 'googleapis';
5
5
  import { z } from 'zod';
6
6
  const MAX_BATCH_SIZE = 1000;
@@ -103,8 +103,8 @@ async function handler({ ids }, extra) {
103
103
  logger.error('drive.file.moveToTrash error', {
104
104
  error: message
105
105
  });
106
- // Throw McpError
107
- throw new McpError(ErrorCode.InternalError, `Error moving files to trash: ${message}`, {
106
+ // Throw ProtocolError
107
+ throw new ProtocolError(ProtocolErrorCode.InternalError, `Error moving files to trash: ${message}`, {
108
108
  stack: error instanceof Error ? error.stack : undefined
109
109
  });
110
110
  }
@@ -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":["schemas","AuthRequiredBranchSchema","ErrorCode","McpError","google","z","MAX_BATCH_SIZE","inputSchema","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","info","count","length","drive","version","auth","authContext","results","Promise","allSettled","map","files","update","fileId","requestBody","trashed","forEach","index","status","errorMessage","reason","Error","message","String","push","content","text","JSON","stringify","structuredContent","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAErC,SAA8BE,SAAS,EAAEC,QAAQ,QAAQ,qCAAqC;AAC9F,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AAExB,MAAMC,iBAAiB;AAEvB,MAAMC,cAAcF,EAAEG,MAAM,CAAC;IAC3BC,KAAKJ,EAAEK,KAAK,CAACL,EAAEM,MAAM,GAAGC,GAAG,CAAC,IAAIA,GAAG,CAAC,GAAGC,GAAG,CAACP,gBAAgBQ,QAAQ,CAAC;AACtE;AAEA,wBAAwB;AACxB,MAAMC,sBAAsBV,EAAEG,MAAM,CAAC;IACnCQ,MAAMX,EAAEY,OAAO,CAAC;IAChBC,kBAAkBb,EAAEM,MAAM,GAAGG,QAAQ,CAAC;IACtCK,YAAYd,EAAEe,MAAM,GAAGN,QAAQ,CAAC;IAChCO,cAAchB,EAAEe,MAAM,GAAGN,QAAQ,CAAC;IAClCQ,cAAcjB,EAAEe,MAAM,GAAGN,QAAQ,CAAC;IAClCS,aAAalB,EAAEmB,OAAO,GAAGV,QAAQ,CAAC;IAClCW,iBAAiBpB,EAAEe,MAAM,GAAGN,QAAQ,CAAC;IACrCY,UAAUrB,EACPK,KAAK,CACJL,EAAEG,MAAM,CAAC;QACPmB,IAAItB,EAAEM,MAAM,GAAGG,QAAQ,CAAC;QACxBc,OAAOvB,EAAEM,MAAM,GAAGG,QAAQ,CAAC;IAC7B,IAEDe,QAAQ,GACRf,QAAQ,CAAC;AACd;AAEA,2CAA2C;AAC3C,MAAMgB,eAAezB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AAmBI,iBAAiB,IAAI,CAAC,MAAM,EAAED,aAAa,KAAK,EAAEA,iBAAiB,IAAI,KAAK,IAAI,mCAAmC,CAAC,GAAG,CAAC,MAAM,EAAEA,aAAa,IAAI,EAAEF,WAAW,KAAK,EAAEA,eAAe,IAAI,KAAK,IAAI,WAAW,EAAEG,aAAa,iCAAiC,CAAC;QAEtR,MAAMa,SAAiB;YACrBnB,MAAM;YACNE;YACAC;YACAE;YACAC;YACAC,aAAa;YACbE,iBAAiB;YACjB,GAAIC,SAASe,MAAM,GAAG,KAAK;gBAAEf;YAAS,CAAC;QACzC;QAEA,OAAO;YACLsC,SAAS;gBACP;oBACEhD,MAAM;oBACNiD,MAAMC,KAAKC,SAAS,CAAChC;gBACvB;aACD;YACDiC,mBAAmB;gBAAEjC;YAAO;QAC9B;IACF,EAAE,OAAOP,OAAO;QACd,MAAMiC,UAAUjC,iBAAiBgC,QAAQhC,MAAMiC,OAAO,GAAGC,OAAOlC;QAChEU,OAAOV,KAAK,CAAC,gCAAgC;YAAEA,OAAOiC;QAAQ;QAE9D,iBAAiB;QACjB,MAAM,IAAI1D,SAASD,UAAUmE,aAAa,EAAE,CAAC,6BAA6B,EAAER,SAAS,EAAE;YACrFS,OAAO1C,iBAAiBgC,QAAQhC,MAAM0C,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLC,MAAM;QACNzC;QACAI;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 { type CallToolResult, ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\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 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":["schemas","AuthRequiredBranchSchema","ProtocolError","ProtocolErrorCode","google","z","MAX_BATCH_SIZE","inputSchema","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","info","count","length","drive","version","auth","authContext","results","Promise","allSettled","map","files","update","fileId","requestBody","trashed","forEach","index","status","errorMessage","reason","Error","message","String","push","content","text","JSON","stringify","structuredContent","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAErC,SAA8BE,aAAa,EAAEC,iBAAiB,QAAQ,gBAAgB;AACtF,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AAExB,MAAMC,iBAAiB;AAEvB,MAAMC,cAAcF,EAAEG,MAAM,CAAC;IAC3BC,KAAKJ,EAAEK,KAAK,CAACL,EAAEM,MAAM,GAAGC,GAAG,CAAC,IAAIA,GAAG,CAAC,GAAGC,GAAG,CAAC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OAAO,GAAGC,OAAOlC;QAChEU,OAAOV,KAAK,CAAC,gCAAgC;YAAEA,OAAOiC;QAAQ;QAE9D,sBAAsB;QACtB,MAAM,IAAI3D,cAAcC,kBAAkBkE,aAAa,EAAE,CAAC,6BAA6B,EAAER,SAAS,EAAE;YAClGS,OAAO1C,iBAAiBgC,QAAQhC,MAAM0C,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLC,MAAM;QACNzC;QACAI;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,6 +1,6 @@
1
1
  import { schemas } from '@mcp-z/oauth-google';
2
2
  const { AuthRequiredBranchSchema } = schemas;
3
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
3
+ import { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';
4
4
  import { google } from 'googleapis';
5
5
  import { z } from 'zod';
6
6
  function isDriveApiError(error) {
@@ -259,8 +259,8 @@ async function handler({ fileIds, destinationFolderId, returnOldParents = true }
259
259
  logger.error('drive.file.move error', {
260
260
  error: message
261
261
  });
262
- // Throw McpError
263
- throw new McpError(ErrorCode.InternalError, `Error moving files: ${message}`, {
262
+ // Throw ProtocolError
263
+ throw new ProtocolError(ProtocolErrorCode.InternalError, `Error moving files: ${message}`, {
264
264
  stack: error instanceof Error ? error.stack : undefined
265
265
  });
266
266
  }
@@ -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":["schemas","AuthRequiredBranchSchema","ErrorCode","McpError","google","z","isDriveApiError","error","inputSchema","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","files","get","fields","data","parents","name","update","addParents","removeParents","join","success","e","errorMessage","message","errorCode","String","undefined","info","moveBatchFiles","_logger","metadataResults","Promise","allSettled","map","response","Error","filesToMove","i","length","status","push","value","reason","moveResults","file","handler","extra","isBatch","Array","isArray","fileIdArray","fileCount","version","auth","authContext","batchResult","singleResult","content","text","JSON","stringify","structuredContent","InternalError","stack","createTool"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAErC,SAA8BE,SAAS,EAAEC,QAAQ,QAAQ,qCAAqC;AAE9F,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AASxB,SAASC,gBAAgBC,KAAc;IACrC,OAAO,OAAOA,UAAU,YAAYA,UAAU,QAAS,CAAA,aAAaA,SAAS,UAAUA,KAAI;AAC7F;AAiBA,MAAMC,cAAcH,EAAEI,MAAM,CAAC;IAC3BC,SAASL,EAAEM,KAAK,CAAC;QAACN,EAAEO,MAAM,GAAGC,GAAG,CAAC;QAAIR,EAAES,KAAK,CAACT,EAAEO,MAAM,GAAGC,GAAG,CAAC,IAAIA,GAAG,CAAC,GAAGE,GAAG,CAAC;KAAK,EAAEC,QAAQ,CAAC;IAC3FC,qBAAqBZ,EAAEO,MAAM,GAAGC,GAAG,CAAC,GAAGG,QAAQ,CAAC;IAChDE,kBAAkBb,EAAEc,OAAO,GAAGC,QAAQ,GAAGJ,QAAQ,CAAC;AACpD;AAEA,wBAAwB;AACxB,MAAMK,sBAAsBhB,EAAEI,MAAM,CAAC;IACnCa,MAAMjB,EAAEkB,OAAO,CAAC;IAChBC,OAAOnB,EACJS,KAAK,CACJT,EAAEI,MAAM,CAAC;QACPgB,QAAQpB,EAAEO,MAAM,GAAGI,QAAQ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AAaL,OAAO4C,MAAM;QAC5B;QAEA,MAAMjC,SAAiB;YACrBnB,MAAM;YACNE;YACA,GAAIM,OAAO4C,MAAM,GAAG,KAAK;gBAAE5C;YAAO,CAAC;YACnCE,gBAAgBsD,YAAYZ,MAAM;YAClCxC,YAAYV,MAAMkD,MAAM;YACxBvC,aAAaL,OAAO4C,MAAM;QAC5B;QAEA,OAAO;YACLmB,SAAS;gBACP;oBACEvE,MAAM;oBACNwE,MAAMC,KAAKC,SAAS,CAACvD;gBACvB;aACD;YACDwD,mBAAmB;gBAAExD;YAAO;QAC9B;IACF,EAAE,OAAOlC,OAAO;QACd,MAAMoD,UAAUpD,iBAAiBgE,QAAQhE,MAAMoD,OAAO,GAAGE,OAAOtD;QAChEqC,OAAOrC,KAAK,CAAC,yBAAyB;YAAEA,OAAOoD;QAAQ;QAEvD,iBAAiB;QACjB,MAAM,IAAIxD,SAASD,UAAUgG,aAAa,EAAE,CAAC,oBAAoB,EAAEvC,SAAS,EAAE;YAC5EwC,OAAO5F,iBAAiBgE,QAAQhE,MAAM4F,KAAK,GAAGrC;QAChD;IACF;AACF;AAEA,eAAe,SAASsC;IACtB,OAAO;QACLjD,MAAM;QACNb;QACA2C;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 CallToolResult, ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\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 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":["schemas","AuthRequiredBranchSchema","ProtocolError","ProtocolErrorCode","google","z","isDriveApiError","error","inputSchema","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","files","get","fields","data","parents","name","update","addParents","removeParents","join","success","e","errorMessage","message","errorCode","String","undefined","info","moveBatchFiles","_logger","metadataResults","Promise","allSettled","map","response","Error","filesToMove","i","length","status","push","value","reason","moveResults","file","handler","extra","isBatch","Array","isArray","fileIdArray","fileCount","version","auth","authContext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,CAACvD;gBACvB;aACD;YACDwD,mBAAmB;gBAAExD;YAAO;QAC9B;IACF,EAAE,OAAOlC,OAAO;QACd,MAAMoD,UAAUpD,iBAAiBgE,QAAQhE,MAAMoD,OAAO,GAAGE,OAAOtD;QAChEqC,OAAOrC,KAAK,CAAC,yBAAyB;YAAEA,OAAOoD;QAAQ;QAEvD,sBAAsB;QACtB,MAAM,IAAIzD,cAAcC,kBAAkB+F,aAAa,EAAE,CAAC,oBAAoB,EAAEvC,SAAS,EAAE;YACzFwC,OAAO5F,iBAAiBgE,QAAQhE,MAAM4F,KAAK,GAAGrC;QAChD;IACF;AACF;AAEA,eAAe,SAASsC;IACtB,OAAO;QACLjD,MAAM;QACNb;QACA2C;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,6 +1,6 @@
1
1
  import { schemas } from '@mcp-z/oauth-google';
2
2
  const { AuthRequiredBranchSchema } = schemas;
3
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
3
+ import { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';
4
4
  import { google } from 'googleapis';
5
5
  import { z } from 'zod';
6
6
  import { getFileReadStream, guessMimeType } from '../../lib/file-streaming.js';
@@ -148,8 +148,8 @@ async function handler({ sourceUri, name, mimeType, parentId, description }, ext
148
148
  logger.error('drive.file.upload error', {
149
149
  error: message
150
150
  });
151
- // Throw McpError for proper MCP error handling
152
- throw new McpError(ErrorCode.InternalError, `Error uploading file: ${message}`, {
151
+ // Throw ProtocolError for proper MCP error handling
152
+ throw new ProtocolError(ProtocolErrorCode.InternalError, `Error uploading file: ${message}`, {
153
153
  stack: error instanceof Error ? error.stack : undefined
154
154
  });
155
155
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/mcp/tools/file-upload.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 } from '@modelcontextprotocol/sdk/types.js';\nimport { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\nimport { google } from 'googleapis';\nimport { z } from 'zod';\nimport { getFileReadStream, guessMimeType } from '../../lib/file-streaming.ts';\n\nconst inputSchema = z.object({\n sourceUri: z.string().trim().min(1).describe('File URI to upload (file://, http://, https://)'),\n name: z.string().trim().min(1).optional().describe('File name in Drive, including extension (defaults to the source file name)'),\n mimeType: z.string().trim().min(1).optional().describe('MIME type, e.g. application/pdf (defaults to the Content-Type header or detection from the file extension)'),\n parentId: z.string().optional().describe('Parent folder ID (omit to upload to My Drive root)'),\n description: z.string().optional().describe('Description to store in the file metadata'),\n});\n\n// Success branch schema\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n operationSummary: z.string().describe('Summary of the file upload operation'),\n itemsProcessed: z.number().describe('Total items attempted (always 1 for single file)'),\n itemsChanged: z.number().describe('Successfully uploaded files (always 1 on success)'),\n completedAt: z.string().describe('ISO datetime when operation completed'),\n id: z.string().describe('ID of the uploaded file'),\n name: z.string().describe('Name of the uploaded file'),\n mimeType: z.string().describe('MIME type of the uploaded file'),\n size: z.string().describe('Size of the uploaded file in bytes'),\n webViewLink: z.string().describe('URL to view the file in Drive'),\n parentId: z.string().optional().describe('ID of the parent folder'),\n parentName: z.string().optional().describe('Name of the parent folder'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n title: 'Upload File',\n description: 'Upload a file to Google Drive from a file:// or http(s):// URI. Content is streamed from the source (no temp files) in a single multipart request. Returns file ID for use in other operations.',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\n// Export types for strong typing in tests\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ sourceUri, name, mimeType, parentId, description }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('drive.file.upload called', {\n sourceUri,\n name: name || 'auto',\n parentId: parentId || 'root',\n });\n\n try {\n const drive = google.drive({ version: 'v3', auth: extra.authContext.auth });\n\n // Stream source content directly from URI (no temp files)\n const source = await getFileReadStream(sourceUri);\n const finalName = name || source.fileName;\n const finalMimeType = mimeType || source.contentType || guessMimeType(finalName);\n\n // Create the file with streamed content (multipart upload; the client pipes the\n // stream body through without buffering it into memory)\n const response = await drive.files.create({\n requestBody: {\n name: finalName,\n mimeType: finalMimeType,\n parents: parentId ? [parentId] : null,\n ...(description && { description }),\n },\n media: { mimeType: finalMimeType, body: source.stream },\n supportsAllDrives: true,\n fields: 'id,name,mimeType,size,webViewLink,parents',\n });\n\n const res = response.data;\n const id = res.id ?? '';\n const resultName = res.name ?? finalName;\n const resultMimeType = res.mimeType ?? finalMimeType;\n const size = res.size ?? String(source.size ?? 0);\n const webViewLink = res.webViewLink ?? '';\n const parents = (res.parents as string[] | undefined) || [];\n\n // Fetch parent name if parentId was provided\n let parentName: string | undefined;\n let actualParentId: string | undefined;\n\n if (parents.length > 0) {\n actualParentId = parents[0];\n\n if (actualParentId === 'root') {\n parentName = 'My Drive';\n } else if (actualParentId) {\n try {\n const parentResponse = await drive.files.get({\n fileId: actualParentId,\n fields: 'name',\n });\n parentName = (parentResponse.data.name as string | undefined) || actualParentId;\n } catch (e) {\n logger.info('Failed to fetch parent name', {\n parentId: actualParentId,\n error: e,\n });\n parentName = actualParentId; // Fallback to ID\n }\n }\n }\n\n const locationSummary = parentName ? ` in \"${parentName}\"` : ' in My Drive';\n\n logger.info('drive.file.upload success', {\n id,\n name: resultName,\n size,\n parentId: actualParentId,\n });\n\n // Build result object with operation metadata\n const result: Output = {\n type: 'success' as const,\n operationSummary: `Uploaded \"${resultName}\"${locationSummary}`,\n itemsProcessed: 1,\n itemsChanged: 1,\n completedAt: new Date().toISOString(),\n id,\n name: resultName,\n mimeType: resultMimeType,\n size,\n webViewLink,\n ...(actualParentId && { parentId: actualParentId }),\n ...(parentName && { parentName }),\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.upload error', { error: message });\n\n // Throw McpError for proper MCP error handling\n throw new McpError(ErrorCode.InternalError, `Error uploading file: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'file-upload' as const,\n config,\n handler,\n };\n}\n"],"names":["schemas","AuthRequiredBranchSchema","ErrorCode","McpError","google","z","getFileReadStream","guessMimeType","inputSchema","object","sourceUri","string","trim","min","describe","name","optional","mimeType","parentId","description","successBranchSchema","type","literal","operationSummary","itemsProcessed","number","itemsChanged","completedAt","id","size","webViewLink","parentName","outputSchema","discriminatedUnion","config","title","result","handler","extra","logger","info","res","source","drive","version","auth","authContext","finalName","fileName","finalMimeType","contentType","response","files","create","requestBody","parents","media","body","stream","supportsAllDrives","fields","data","resultName","resultMimeType","String","actualParentId","length","parentResponse","get","fileId","e","error","locationSummary","Date","toISOString","content","text","JSON","stringify","structuredContent","message","Error","InternalError","stack","undefined","createTool"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAGrC,SAASE,SAAS,EAAEC,QAAQ,QAAQ,qCAAqC;AACzE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,iBAAiB,EAAEC,aAAa,QAAQ,8BAA8B;AAE/E,MAAMC,cAAcH,EAAEI,MAAM,CAAC;IAC3BC,WAAWL,EAAEM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MC,KAAKC,SAAS,CAAC1C;gBACvB;aACD;YACD2C,mBAAmB;gBAAE3C;YAAO;QAC9B;IACF,EAAE,OAAOmC,OAAO;QACd,MAAMS,UAAUT,iBAAiBU,QAAQV,MAAMS,OAAO,GAAGhB,OAAOO;QAChEhC,OAAOgC,KAAK,CAAC,2BAA2B;YAAEA,OAAOS;QAAQ;QAEzD,+CAA+C;QAC/C,MAAM,IAAI7E,SAASD,UAAUgF,aAAa,EAAE,CAAC,sBAAsB,EAAEF,SAAS,EAAE;YAC9EG,OAAOZ,iBAAiBU,QAAQV,MAAMY,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLtE,MAAM;QACNmB;QACAG;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/mcp/tools/file-upload.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 } from '@mcp-z/server';\nimport { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { google } from 'googleapis';\nimport { z } from 'zod';\nimport { getFileReadStream, guessMimeType } from '../../lib/file-streaming.ts';\n\nconst inputSchema = z.object({\n sourceUri: z.string().trim().min(1).describe('File URI to upload (file://, http://, https://)'),\n name: z.string().trim().min(1).optional().describe('File name in Drive, including extension (defaults to the source file name)'),\n mimeType: z.string().trim().min(1).optional().describe('MIME type, e.g. application/pdf (defaults to the Content-Type header or detection from the file extension)'),\n parentId: z.string().optional().describe('Parent folder ID (omit to upload to My Drive root)'),\n description: z.string().optional().describe('Description to store in the file metadata'),\n});\n\n// Success branch schema\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n operationSummary: z.string().describe('Summary of the file upload operation'),\n itemsProcessed: z.number().describe('Total items attempted (always 1 for single file)'),\n itemsChanged: z.number().describe('Successfully uploaded files (always 1 on success)'),\n completedAt: z.string().describe('ISO datetime when operation completed'),\n id: z.string().describe('ID of the uploaded file'),\n name: z.string().describe('Name of the uploaded file'),\n mimeType: z.string().describe('MIME type of the uploaded file'),\n size: z.string().describe('Size of the uploaded file in bytes'),\n webViewLink: z.string().describe('URL to view the file in Drive'),\n parentId: z.string().optional().describe('ID of the parent folder'),\n parentName: z.string().optional().describe('Name of the parent folder'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n title: 'Upload File',\n description: 'Upload a file to Google Drive from a file:// or http(s):// URI. Content is streamed from the source (no temp files) in a single multipart request. Returns file ID for use in other operations.',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\n// Export types for strong typing in tests\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ sourceUri, name, mimeType, parentId, description }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('drive.file.upload called', {\n sourceUri,\n name: name || 'auto',\n parentId: parentId || 'root',\n });\n\n try {\n const drive = google.drive({ version: 'v3', auth: extra.authContext.auth });\n\n // Stream source content directly from URI (no temp files)\n const source = await getFileReadStream(sourceUri);\n const finalName = name || source.fileName;\n const finalMimeType = mimeType || source.contentType || guessMimeType(finalName);\n\n // Create the file with streamed content (multipart upload; the client pipes the\n // stream body through without buffering it into memory)\n const response = await drive.files.create({\n requestBody: {\n name: finalName,\n mimeType: finalMimeType,\n parents: parentId ? [parentId] : null,\n ...(description && { description }),\n },\n media: { mimeType: finalMimeType, body: source.stream },\n supportsAllDrives: true,\n fields: 'id,name,mimeType,size,webViewLink,parents',\n });\n\n const res = response.data;\n const id = res.id ?? '';\n const resultName = res.name ?? finalName;\n const resultMimeType = res.mimeType ?? finalMimeType;\n const size = res.size ?? String(source.size ?? 0);\n const webViewLink = res.webViewLink ?? '';\n const parents = (res.parents as string[] | undefined) || [];\n\n // Fetch parent name if parentId was provided\n let parentName: string | undefined;\n let actualParentId: string | undefined;\n\n if (parents.length > 0) {\n actualParentId = parents[0];\n\n if (actualParentId === 'root') {\n parentName = 'My Drive';\n } else if (actualParentId) {\n try {\n const parentResponse = await drive.files.get({\n fileId: actualParentId,\n fields: 'name',\n });\n parentName = (parentResponse.data.name as string | undefined) || actualParentId;\n } catch (e) {\n logger.info('Failed to fetch parent name', {\n parentId: actualParentId,\n error: e,\n });\n parentName = actualParentId; // Fallback to ID\n }\n }\n }\n\n const locationSummary = parentName ? ` in \"${parentName}\"` : ' in My Drive';\n\n logger.info('drive.file.upload success', {\n id,\n name: resultName,\n size,\n parentId: actualParentId,\n });\n\n // Build result object with operation metadata\n const result: Output = {\n type: 'success' as const,\n operationSummary: `Uploaded \"${resultName}\"${locationSummary}`,\n itemsProcessed: 1,\n itemsChanged: 1,\n completedAt: new Date().toISOString(),\n id,\n name: resultName,\n mimeType: resultMimeType,\n size,\n webViewLink,\n ...(actualParentId && { parentId: actualParentId }),\n ...(parentName && { parentName }),\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.upload error', { error: message });\n\n // Throw ProtocolError for proper MCP error handling\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error uploading file: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'file-upload' as const,\n config,\n handler,\n };\n}\n"],"names":["schemas","AuthRequiredBranchSchema","ProtocolError","ProtocolErrorCode","google","z","getFileReadStream","guessMimeType","inputSchema","object","sourceUri","string","trim","min","describe","name","optional","mimeType","parentId","description","successBranchSchema","type","literal","operationSummary","itemsProcessed","number","itemsChanged","completedAt","id","size","webViewLink","parentName","outputSchema","discriminatedUnion","config","title","result","handler","extra","logger","info","res","source","drive","version","auth","authContext","finalName","fileName","finalMimeType","contentType","response","files","create","requestBody","parents","media","body","stream","supportsAllDrives","fields","data","resultName","resultMimeType","String","actualParentId","length","parentResponse","get","fileId","e","error","locationSummary","Date","toISOString","content","text","JSON","stringify","structuredContent","message","Error","InternalError","stack","undefined","createTool"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAGrC,SAASE,aAAa,EAAEC,iBAAiB,QAAQ,gBAAgB;AACjE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,iBAAiB,EAAEC,aAAa,QAAQ,8BAA8B;AAE/E,MAAMC,cAAcH,EAAEI,MAAM,CAAC;IAC3BC,WAAWL,EAAEM,MAAM,GAAGC,IAAI,GAAGC,GAAG,CAAC,GAAGC,QAAQ,CAAC;IAC7CC,MAAMV,EAAEM,MAAM,GAAGC,IAAI,GAAGC,GAAG,CAAC,GAAGG,QAAQ,GAAGF,QAAQ,CAAC;IACnDG,UAAUZ,EAAEM,MAAM,GAAGC,IAAI,GAAGC,GAAG,CAAC,GAAGG,QAAQ,GAAGF,QAAQ,CAAC;IACvDI,UAAUb,EAAEM,MAAM,GAAGK,QAAQ,GAAGF,QAAQ,CAAC;IACzCK,aAAad,EAAEM,MAAM,GAAGK,QAAQ,GAAGF,QAAQ,CAAC;AAC9C;AAEA,wBAAwB;AACxB,MAAMM,sBAAsBf,EAAEI,MAAM,CAAC;IACnCY,MAAMhB,EAAEiB,OAAO,CAAC;IAChBC,kBAAkBlB,EAAEM,MAAM,GAAGG,QAAQ,CAAC;IACtCU,gBAAgBnB,EAAEoB,MAAM,GAAGX,QAAQ,CAAC;IACpCY,cAAcrB,EAAEoB,MAAM,GAAGX,QAAQ,CAAC;IAClCa,aAAatB,EAAEM,MAAM,GAAGG,QAAQ,CAAC;IACjCc,IAAIvB,EAAEM,MAAM,GAAGG,QAAQ,CAAC;IACxBC,MAAMV,EAAEM,MAAM,GAAGG,QAAQ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AAOC,IAAI,CAAC,6BAA6B;YACvCZ;YACAb,MAAM+C;YACNjC;YACAX,UAAU+C;QACZ;QAEA,8CAA8C;QAC9C,MAAM7B,SAAiB;YACrBf,MAAM;YACNE,kBAAkB,CAAC,UAAU,EAAEuC,WAAW,CAAC,EAAEU,iBAAiB;YAC9DhD,gBAAgB;YAChBE,cAAc;YACdC,aAAa,IAAI8C,OAAOC,WAAW;YACnC9C;YACAb,MAAM+C;YACN7C,UAAU8C;YACVlC;YACAC;YACA,GAAImC,kBAAkB;gBAAE/C,UAAU+C;YAAe,CAAC;YAClD,GAAIlC,cAAc;gBAAEA;YAAW,CAAC;QAClC;QAEA,OAAO;YACL4C,SAAS;gBACP;oBACEtD,MAAM;oBACNuD,MAAMC,KAAKC,SAAS,CAAC1C;gBACvB;aACD;YACD2C,mBAAmB;gBAAE3C;YAAO;QAC9B;IACF,EAAE,OAAOmC,OAAO;QACd,MAAMS,UAAUT,iBAAiBU,QAAQV,MAAMS,OAAO,GAAGhB,OAAOO;QAChEhC,OAAOgC,KAAK,CAAC,2BAA2B;YAAEA,OAAOS;QAAQ;QAEzD,oDAAoD;QACpD,MAAM,IAAI9E,cAAcC,kBAAkB+E,aAAa,EAAE,CAAC,sBAAsB,EAAEF,SAAS,EAAE;YAC3FG,OAAOZ,iBAAiBU,QAAQV,MAAMY,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLtE,MAAM;QACNmB;QACAG;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
  shape: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
@@ -1,7 +1,6 @@
1
1
  import { schemas } from '@mcp-z/oauth-google';
2
2
  const { AuthRequiredBranchSchema } = schemas;
3
- import { createFieldsSchema, createPaginationSchema, createShapeSchema, filterFields, parseFields, toColumnarFormat } from '@mcp-z/server';
4
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
3
+ import { createFieldsSchema, createPaginationSchema, createShapeSchema, filterFields, ProtocolError, ProtocolErrorCode, parseFields, toColumnarFormat } from '@mcp-z/server';
5
4
  import { google } from 'googleapis';
6
5
  import { z } from 'zod';
7
6
  import { toDriveQuery } from '../../lib/query-builder.js';
@@ -212,8 +211,8 @@ async function handler({ query, pageSize = 50, pageToken, fields, shape = 'array
212
211
  logger.error('drive.files-search error', {
213
212
  error: message
214
213
  });
215
- // Throw McpError for all errors so callers can see Drive validation details
216
- throw new McpError(ErrorCode.InternalError, `Error searching files: ${message}`, {
214
+ // Throw ProtocolError for all errors so callers can see Drive validation details
215
+ throw new ProtocolError(ProtocolErrorCode.InternalError, `Error searching files: ${message}`, {
217
216
  stack: error instanceof Error ? error.stack : undefined
218
217
  });
219
218
  }