@mcp-z/mcp-drive 1.0.7 → 1.0.9

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 (95) hide show
  1. package/dist/cjs/constants.js.map +1 -1
  2. package/dist/cjs/index.js +10 -24
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/lib/create-store.js +2 -5
  5. package/dist/cjs/lib/create-store.js.map +1 -1
  6. package/dist/cjs/lib/query-builder.d.cts +2 -2
  7. package/dist/cjs/lib/query-builder.d.ts +2 -2
  8. package/dist/cjs/lib/query-builder.js.map +1 -1
  9. package/dist/cjs/mcp/index.js +8 -19
  10. package/dist/cjs/mcp/index.js.map +1 -1
  11. package/dist/cjs/mcp/prompts/index.js.map +1 -1
  12. package/dist/cjs/mcp/prompts/organize-files.js +3 -6
  13. package/dist/cjs/mcp/prompts/organize-files.js.map +1 -1
  14. package/dist/cjs/mcp/prompts/query-syntax.js +4 -7
  15. package/dist/cjs/mcp/prompts/query-syntax.js.map +1 -1
  16. package/dist/cjs/mcp/resources/file.js +3 -6
  17. package/dist/cjs/mcp/resources/file.js.map +1 -1
  18. package/dist/cjs/mcp/resources/index.js.map +1 -1
  19. package/dist/cjs/mcp/tools/file-move-to-trash.js +5 -11
  20. package/dist/cjs/mcp/tools/file-move-to-trash.js.map +1 -1
  21. package/dist/cjs/mcp/tools/file-move.js +11 -18
  22. package/dist/cjs/mcp/tools/file-move.js.map +1 -1
  23. package/dist/cjs/mcp/tools/files-search.d.cts +2 -2
  24. package/dist/cjs/mcp/tools/files-search.d.ts +2 -2
  25. package/dist/cjs/mcp/tools/files-search.js +31 -72
  26. package/dist/cjs/mcp/tools/files-search.js.map +1 -1
  27. package/dist/cjs/mcp/tools/folder-contents.js +7 -14
  28. package/dist/cjs/mcp/tools/folder-contents.js.map +1 -1
  29. package/dist/cjs/mcp/tools/folder-create.js +5 -11
  30. package/dist/cjs/mcp/tools/folder-create.js.map +1 -1
  31. package/dist/cjs/mcp/tools/folder-path.js +4 -8
  32. package/dist/cjs/mcp/tools/folder-path.js.map +1 -1
  33. package/dist/cjs/mcp/tools/folder-search.d.cts +2 -2
  34. package/dist/cjs/mcp/tools/folder-search.d.ts +2 -2
  35. package/dist/cjs/mcp/tools/folder-search.js +40 -83
  36. package/dist/cjs/mcp/tools/folder-search.js.map +1 -1
  37. package/dist/cjs/mcp/tools/index.js.map +1 -1
  38. package/dist/cjs/schemas/drive-query-schema.d.cts +32 -6
  39. package/dist/cjs/schemas/drive-query-schema.d.ts +32 -6
  40. package/dist/cjs/schemas/drive-query-schema.js +37 -30
  41. package/dist/cjs/schemas/drive-query-schema.js.map +1 -1
  42. package/dist/cjs/schemas/drive-validation.js.map +1 -1
  43. package/dist/cjs/schemas/index.js.map +1 -1
  44. package/dist/cjs/setup/config.js +11 -25
  45. package/dist/cjs/setup/config.js.map +1 -1
  46. package/dist/cjs/setup/http.js +15 -16
  47. package/dist/cjs/setup/http.js.map +1 -1
  48. package/dist/cjs/setup/index.js.map +1 -1
  49. package/dist/cjs/setup/oauth-google.js +9 -16
  50. package/dist/cjs/setup/oauth-google.js.map +1 -1
  51. package/dist/cjs/setup/runtime.d.cts +1 -1
  52. package/dist/cjs/setup/runtime.d.ts +1 -1
  53. package/dist/cjs/setup/runtime.js +11 -25
  54. package/dist/cjs/setup/runtime.js.map +1 -1
  55. package/dist/cjs/setup/stdio.js +15 -16
  56. package/dist/cjs/setup/stdio.js.map +1 -1
  57. package/dist/esm/constants.js.map +1 -1
  58. package/dist/esm/index.js.map +1 -1
  59. package/dist/esm/lib/create-store.js.map +1 -1
  60. package/dist/esm/lib/query-builder.d.ts +2 -2
  61. package/dist/esm/lib/query-builder.js +1 -1
  62. package/dist/esm/lib/query-builder.js.map +1 -1
  63. package/dist/esm/mcp/index.js.map +1 -1
  64. package/dist/esm/mcp/prompts/index.js.map +1 -1
  65. package/dist/esm/mcp/prompts/organize-files.js.map +1 -1
  66. package/dist/esm/mcp/prompts/query-syntax.js +1 -1
  67. package/dist/esm/mcp/prompts/query-syntax.js.map +1 -1
  68. package/dist/esm/mcp/resources/file.js.map +1 -1
  69. package/dist/esm/mcp/resources/index.js.map +1 -1
  70. package/dist/esm/mcp/tools/file-move-to-trash.js.map +1 -1
  71. package/dist/esm/mcp/tools/file-move.js.map +1 -1
  72. package/dist/esm/mcp/tools/files-search.d.ts +2 -2
  73. package/dist/esm/mcp/tools/files-search.js +24 -51
  74. package/dist/esm/mcp/tools/files-search.js.map +1 -1
  75. package/dist/esm/mcp/tools/folder-contents.js.map +1 -1
  76. package/dist/esm/mcp/tools/folder-create.js.map +1 -1
  77. package/dist/esm/mcp/tools/folder-path.js.map +1 -1
  78. package/dist/esm/mcp/tools/folder-search.d.ts +2 -2
  79. package/dist/esm/mcp/tools/folder-search.js +25 -56
  80. package/dist/esm/mcp/tools/folder-search.js.map +1 -1
  81. package/dist/esm/mcp/tools/index.js.map +1 -1
  82. package/dist/esm/schemas/drive-query-schema.d.ts +32 -6
  83. package/dist/esm/schemas/drive-query-schema.js +29 -12
  84. package/dist/esm/schemas/drive-query-schema.js.map +1 -1
  85. package/dist/esm/schemas/drive-validation.js.map +1 -1
  86. package/dist/esm/schemas/index.js.map +1 -1
  87. package/dist/esm/setup/config.js.map +1 -1
  88. package/dist/esm/setup/http.js.map +1 -1
  89. package/dist/esm/setup/index.js.map +1 -1
  90. package/dist/esm/setup/oauth-google.js.map +1 -1
  91. package/dist/esm/setup/runtime.d.ts +1 -1
  92. package/dist/esm/setup/runtime.js.map +1 -1
  93. package/dist/esm/setup/stdio.js.map +1 -1
  94. package/dist/esm/types.js.map +1 -1
  95. package/package.json +10 -6
@@ -9,6 +9,30 @@ export declare const FieldOperatorSchema: z.ZodObject<{
9
9
  $none: z.ZodOptional<z.ZodArray<z.ZodString>>;
10
10
  }, z.core.$strict>;
11
11
  export type FieldOperator = z.infer<typeof FieldOperatorSchema>;
12
+ /**
13
+ * Drive query object schema with recursive operators and Drive features.
14
+ *
15
+ * Includes Drive-specific features:
16
+ * - name: Search by file/folder name (supports string or field operators)
17
+ * - mimeType: Filter by MIME type (e.g., "application/pdf", "application/vnd.google-apps.folder")
18
+ * - fullText: Search file content and metadata
19
+ * - parentId: Search within specific folder (supports string or field operators)
20
+ * - starred: Filter by starred status
21
+ * - shared: Filter by shared status
22
+ * - modifiedTime: Date range filtering with $gte and $lt
23
+ * - owner: Filter by owner email (supports string or field operators)
24
+ * - rawDriveQuery: Escape hatch for advanced Drive query syntax
25
+ *
26
+ * Logical operators:
27
+ * - $and: Array of conditions that must ALL match (recursive)
28
+ * - $or: Array of conditions where ANY must match (recursive)
29
+ * - $not: Nested condition that must NOT match (recursive)
30
+ *
31
+ * Note: Cast through unknown to work around Zod's lazy schema type inference issue
32
+ * with exactOptionalPropertyTypes. The runtime schema is correct; this cast ensures
33
+ * TypeScript sees the strict DriveQueryObject type everywhere the schema is used.
34
+ */
35
+ export declare const DriveQuerySchema: z.ZodType<DriveQueryObject>;
12
36
  export type DriveQueryObject = {
13
37
  $and?: DriveQueryObject[];
14
38
  $or?: DriveQueryObject[];
@@ -27,13 +51,15 @@ export type DriveQueryObject = {
27
51
  owner?: string | FieldOperator;
28
52
  rawDriveQuery?: string;
29
53
  };
54
+ export type DriveQuery = DriveQueryObject;
30
55
  /**
31
- * Drive query schema that accepts either:
32
- * - A structured DriveQueryObject with typed fields
33
- * - A raw Drive query string for advanced use cases
56
+ * Drive query parameter schema that accepts either:
57
+ * - A structured DriveQuery object with typed fields
58
+ * - A JSON string representing that object
34
59
  *
35
60
  * This provides type safety for common queries while allowing
36
- * direct Google Drive query syntax when needed.
61
+ * JSON string input from MCP clients when needed.
37
62
  */
38
- export declare const DriveQuerySchema: z.ZodUnion<readonly [z.ZodString, z.ZodType<DriveQueryObject, unknown, z.core.$ZodTypeInternals<DriveQueryObject, unknown>>]>;
39
- export type DriveQuery = string | DriveQueryObject;
63
+ export declare const DriveQueryParameterSchema: z.ZodType<DriveQuery | string>;
64
+ export type DriveQueryParameter = z.infer<typeof DriveQueryParameterSchema>;
65
+ export declare function parseDriveQueryParameter(input: DriveQuery | string | undefined): DriveQuery | undefined;
@@ -9,47 +9,37 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
+ get DriveQueryParameterSchema () {
13
+ return DriveQueryParameterSchema;
14
+ },
12
15
  get DriveQuerySchema () {
13
16
  return DriveQuerySchema;
14
17
  },
15
18
  get FieldOperatorSchema () {
16
19
  return FieldOperatorSchema;
20
+ },
21
+ get parseDriveQueryParameter () {
22
+ return parseDriveQueryParameter;
17
23
  }
18
24
  });
19
25
  var _zod = require("zod");
26
+ function _instanceof(left, right) {
27
+ "@swc/helpers - instanceof";
28
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
29
+ return !!right[Symbol.hasInstance](left);
30
+ } else return left instanceof right;
31
+ }
20
32
  var FieldOperatorSchema = _zod.z.object({
21
33
  $any: _zod.z.array(_zod.z.string()).optional().describe('OR within field - matches if ANY value matches'),
22
34
  $all: _zod.z.array(_zod.z.string()).optional().describe('AND within field - matches if ALL values match'),
23
35
  $none: _zod.z.array(_zod.z.string()).optional().describe('NOT within field - matches if NONE match')
24
36
  }).strict();
25
- /**
26
- * Drive query object schema with recursive operators and Drive features.
27
- *
28
- * Includes Drive-specific features:
29
- * - name: Search by file/folder name (supports string or field operators)
30
- * - mimeType: Filter by MIME type (e.g., "application/pdf", "application/vnd.google-apps.folder")
31
- * - fullText: Search file content and metadata
32
- * - parentId: Search within specific folder (supports string or field operators)
33
- * - starred: Filter by starred status
34
- * - shared: Filter by shared status
35
- * - modifiedTime: Date range filtering with $gte and $lt
36
- * - owner: Filter by owner email (supports string or field operators)
37
- * - rawDriveQuery: Escape hatch for advanced Drive query syntax
38
- *
39
- * Logical operators:
40
- * - $and: Array of conditions that must ALL match (recursive)
41
- * - $or: Array of conditions where ANY must match (recursive)
42
- * - $not: Nested condition that must NOT match (recursive)
43
- *
44
- * Note: Cast through unknown to work around Zod's lazy schema type inference issue
45
- * with exactOptionalPropertyTypes. The runtime schema is correct; this cast ensures
46
- * TypeScript sees the strict DriveQueryObject type everywhere the schema is used.
47
- */ var DriveQueryObjectSchema = _zod.z.lazy(function() {
37
+ var DriveQuerySchema = _zod.z.lazy(function() {
48
38
  return _zod.z.object({
49
39
  // Logical operators for combining conditions (recursive)
50
- $and: _zod.z.array(DriveQueryObjectSchema).optional().describe('Array of conditions that must ALL match'),
51
- $or: _zod.z.array(DriveQueryObjectSchema).optional().describe('Array of conditions where ANY must match'),
52
- $not: DriveQueryObjectSchema.optional().describe('Nested condition that must NOT match'),
40
+ $and: _zod.z.array(DriveQuerySchema).optional().describe('Array of conditions that must ALL match'),
41
+ $or: _zod.z.array(DriveQuerySchema).optional().describe('Array of conditions where ANY must match'),
42
+ $not: DriveQuerySchema.optional().describe('Nested condition that must NOT match'),
53
43
  // File/folder name search
54
44
  name: _zod.z.union([
55
45
  _zod.z.string().min(1),
@@ -73,7 +63,7 @@ var FieldOperatorSchema = _zod.z.object({
73
63
  // Boolean flags
74
64
  starred: _zod.z.boolean().optional().describe('Filter by starred status (true = starred, false = not starred)'),
75
65
  sharedWithMe: _zod.z.boolean().optional().describe('Filter by "shared with me" collection (true = in shared collection, false = not shared)'),
76
- trashed: _zod.z.boolean().optional().describe('Filter by trash status (true = in trash, false = not in trash). Note: Drive tools automatically filter out trashed files unless explicitly requested.'),
66
+ trashed: _zod.z.boolean().optional().describe('Filter by trash status (true = in trash, false = not in trash).'),
77
67
  // Date range filtering
78
68
  modifiedTime: _zod.z.object({
79
69
  $gte: _zod.z.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?Z)?$/).optional().describe('Files modified on or after this date (ISO 8601: YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ)'),
@@ -88,8 +78,25 @@ var FieldOperatorSchema = _zod.z.object({
88
78
  rawDriveQuery: _zod.z.string().min(1).optional().describe("Raw Google Drive query syntax for advanced use cases. Bypasses schema validation - use sparingly. Example: \"name contains 'budget' and mimeType = 'application/pdf'\"")
89
79
  }).strict();
90
80
  });
91
- var DriveQuerySchema = _zod.z.union([
92
- _zod.z.string().min(1),
93
- DriveQueryObjectSchema
81
+ var DriveQueryParameterSchema = _zod.z.union([
82
+ DriveQuerySchema,
83
+ _zod.z.string().min(1)
94
84
  ]);
85
+ function parseDriveQueryParameter(input) {
86
+ if (input === undefined) return undefined;
87
+ var raw = typeof input === 'string' ? safeJsonParse(input, 'rawDriveQuery') : input;
88
+ var validated = DriveQuerySchema.safeParse(raw);
89
+ if (!validated.success) {
90
+ throw new Error("Invalid query JSON: ".concat(validated.error.message, '. Use {"rawDriveQuery":"<query>"} for Drive syntax.'));
91
+ }
92
+ return validated.data;
93
+ }
94
+ function safeJsonParse(value, rawField) {
95
+ try {
96
+ return JSON.parse(value);
97
+ } catch (error) {
98
+ var message = _instanceof(error, Error) ? error.message : 'Invalid JSON';
99
+ throw new Error("Query must be valid JSON. ".concat(message, '. Wrap Drive syntax in {"').concat(rawField, '":"<query>"} if needed.'));
100
+ }
101
+ }
95
102
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/Projects/mcp-z/mcp-drive/src/schemas/drive-query-schema.ts"],"sourcesContent":["import { z } from 'zod';\n\n/**\n * Field operator schema for Drive query fields that support multiple values\n * Supports OR ($any), AND ($all), and NOT ($none) operations\n */\nexport const FieldOperatorSchema = z\n .object({\n $any: z.array(z.string()).optional().describe('OR within field - matches if ANY value matches'),\n $all: z.array(z.string()).optional().describe('AND within field - matches if ALL values match'),\n $none: z.array(z.string()).optional().describe('NOT within field - matches if NONE match'),\n })\n .strict();\n\nexport type FieldOperator = z.infer<typeof FieldOperatorSchema>;\n\n/**\n * Drive query object schema with recursive operators and Drive features.\n *\n * Includes Drive-specific features:\n * - name: Search by file/folder name (supports string or field operators)\n * - mimeType: Filter by MIME type (e.g., \"application/pdf\", \"application/vnd.google-apps.folder\")\n * - fullText: Search file content and metadata\n * - parentId: Search within specific folder (supports string or field operators)\n * - starred: Filter by starred status\n * - shared: Filter by shared status\n * - modifiedTime: Date range filtering with $gte and $lt\n * - owner: Filter by owner email (supports string or field operators)\n * - rawDriveQuery: Escape hatch for advanced Drive query syntax\n *\n * Logical operators:\n * - $and: Array of conditions that must ALL match (recursive)\n * - $or: Array of conditions where ANY must match (recursive)\n * - $not: Nested condition that must NOT match (recursive)\n *\n * Note: Cast through unknown to work around Zod's lazy schema type inference issue\n * with exactOptionalPropertyTypes. The runtime schema is correct; this cast ensures\n * TypeScript sees the strict DriveQueryObject type everywhere the schema is used.\n */\nconst DriveQueryObjectSchema = z.lazy(() =>\n z\n .object({\n // Logical operators for combining conditions (recursive)\n $and: z.array(DriveQueryObjectSchema).optional().describe('Array of conditions that must ALL match'),\n $or: z.array(DriveQueryObjectSchema).optional().describe('Array of conditions where ANY must match'),\n $not: DriveQueryObjectSchema.optional().describe('Nested condition that must NOT match'),\n\n // File/folder name search\n name: z\n .union([z.string().min(1), FieldOperatorSchema])\n .optional()\n .describe('Search by file or folder name (partial match, case-insensitive)'),\n\n // MIME type filtering\n mimeType: z\n .union([z.string().min(1), FieldOperatorSchema])\n .optional()\n .describe('Filter by MIME type (e.g., \"application/pdf\", \"application/vnd.google-apps.folder\", \"image/jpeg\")'),\n\n // Full-text search across content and metadata\n fullText: z\n .union([z.string().min(1), FieldOperatorSchema])\n .optional()\n .describe('Search file content and metadata (full-text search)'),\n\n // Parent folder filtering\n parentId: z\n .union([z.string().min(1), FieldOperatorSchema])\n .optional()\n .describe('Search within specific folder by folder ID (use \"root\" for My Drive root)'),\n\n // Boolean flags\n starred: z.boolean().optional().describe('Filter by starred status (true = starred, false = not starred)'),\n sharedWithMe: z.boolean().optional().describe('Filter by \"shared with me\" collection (true = in shared collection, false = not shared)'),\n trashed: z.boolean().optional().describe('Filter by trash status (true = in trash, false = not in trash). Note: Drive tools automatically filter out trashed files unless explicitly requested.'),\n\n // Date range filtering\n modifiedTime: z\n .object({\n $gte: z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z)?$/)\n .optional()\n .describe('Files modified on or after this date (ISO 8601: YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ)'),\n $lt: z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z)?$/)\n .optional()\n .describe('Files modified before this date (ISO 8601: YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ)'),\n })\n .optional()\n .describe('Filter by modification date range'),\n\n // Owner filtering\n owner: z\n .union([z.string().min(1), FieldOperatorSchema])\n .optional()\n .describe('Filter by owner email address (partial match)'),\n\n // Raw Drive query string - escape hatch for advanced syntax\n rawDriveQuery: z.string().min(1).optional().describe(\"Raw Google Drive query syntax for advanced use cases. Bypasses schema validation - use sparingly. Example: \\\"name contains 'budget' and mimeType = 'application/pdf'\\\"\"),\n })\n .strict()\n) as unknown as z.ZodType<DriveQueryObject>;\n\nexport type DriveQueryObject = {\n $and?: DriveQueryObject[];\n $or?: DriveQueryObject[];\n $not?: DriveQueryObject;\n name?: string | FieldOperator;\n mimeType?: string | FieldOperator;\n fullText?: string | FieldOperator;\n parentId?: string | FieldOperator;\n starred?: boolean;\n sharedWithMe?: boolean;\n trashed?: boolean;\n modifiedTime?: {\n $gte?: string;\n $lt?: string;\n };\n owner?: string | FieldOperator;\n rawDriveQuery?: string;\n};\n\n/**\n * Drive query schema that accepts either:\n * - A structured DriveQueryObject with typed fields\n * - A raw Drive query string for advanced use cases\n *\n * This provides type safety for common queries while allowing\n * direct Google Drive query syntax when needed.\n */\nexport const DriveQuerySchema = z.union([z.string().min(1), DriveQueryObjectSchema]);\n\nexport type DriveQuery = string | DriveQueryObject;\n"],"names":["DriveQuerySchema","FieldOperatorSchema","z","object","$any","array","string","optional","describe","$all","$none","strict","DriveQueryObjectSchema","lazy","$and","$or","$not","name","union","min","mimeType","fullText","parentId","starred","boolean","sharedWithMe","trashed","modifiedTime","$gte","regex","$lt","owner","rawDriveQuery"],"mappings":";;;;;;;;;;;QAoIaA;eAAAA;;QA9HAC;eAAAA;;;mBANK;AAMX,IAAMA,sBAAsBC,MAAC,CACjCC,MAAM,CAAC;IACNC,MAAMF,MAAC,CAACG,KAAK,CAACH,MAAC,CAACI,MAAM,IAAIC,QAAQ,GAAGC,QAAQ,CAAC;IAC9CC,MAAMP,MAAC,CAACG,KAAK,CAACH,MAAC,CAACI,MAAM,IAAIC,QAAQ,GAAGC,QAAQ,CAAC;IAC9CE,OAAOR,MAAC,CAACG,KAAK,CAACH,MAAC,CAACI,MAAM,IAAIC,QAAQ,GAAGC,QAAQ,CAAC;AACjD,GACCG,MAAM;AAIT;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,IAAMC,yBAAyBV,MAAC,CAACW,IAAI,CAAC;WACpCX,MAAC,CACEC,MAAM,CAAC;QACN,yDAAyD;QACzDW,MAAMZ,MAAC,CAACG,KAAK,CAACO,wBAAwBL,QAAQ,GAAGC,QAAQ,CAAC;QAC1DO,KAAKb,MAAC,CAACG,KAAK,CAACO,wBAAwBL,QAAQ,GAAGC,QAAQ,CAAC;QACzDQ,MAAMJ,uBAAuBL,QAAQ,GAAGC,QAAQ,CAAC;QAEjD,0BAA0B;QAC1BS,MAAMf,MAAC,CACJgB,KAAK,CAAC;YAAChB,MAAC,CAACI,MAAM,GAAGa,GAAG,CAAC;YAAIlB;SAAoB,EAC9CM,QAAQ,GACRC,QAAQ,CAAC;QAEZ,sBAAsB;QACtBY,UAAUlB,MAAC,CACRgB,KAAK,CAAC;YAAChB,MAAC,CAACI,MAAM,GAAGa,GAAG,CAAC;YAAIlB;SAAoB,EAC9CM,QAAQ,G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["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/schemas/drive-query-schema.ts"],"sourcesContent":["import { z } from 'zod';\n\n/**\n * Field operator schema for Drive query fields that support multiple values\n * Supports OR ($any), AND ($all), and NOT ($none) operations\n */\nexport const FieldOperatorSchema = z\n .object({\n $any: z.array(z.string()).optional().describe('OR within field - matches if ANY value matches'),\n $all: z.array(z.string()).optional().describe('AND within field - matches if ALL values match'),\n $none: z.array(z.string()).optional().describe('NOT within field - matches if NONE match'),\n })\n .strict();\n\nexport type FieldOperator = z.infer<typeof FieldOperatorSchema>;\n\n/**\n * Drive query object schema with recursive operators and Drive features.\n *\n * Includes Drive-specific features:\n * - name: Search by file/folder name (supports string or field operators)\n * - mimeType: Filter by MIME type (e.g., \"application/pdf\", \"application/vnd.google-apps.folder\")\n * - fullText: Search file content and metadata\n * - parentId: Search within specific folder (supports string or field operators)\n * - starred: Filter by starred status\n * - shared: Filter by shared status\n * - modifiedTime: Date range filtering with $gte and $lt\n * - owner: Filter by owner email (supports string or field operators)\n * - rawDriveQuery: Escape hatch for advanced Drive query syntax\n *\n * Logical operators:\n * - $and: Array of conditions that must ALL match (recursive)\n * - $or: Array of conditions where ANY must match (recursive)\n * - $not: Nested condition that must NOT match (recursive)\n *\n * Note: Cast through unknown to work around Zod's lazy schema type inference issue\n * with exactOptionalPropertyTypes. The runtime schema is correct; this cast ensures\n * TypeScript sees the strict DriveQueryObject type everywhere the schema is used.\n */\nexport const DriveQuerySchema = z.lazy(() =>\n z\n .object({\n // Logical operators for combining conditions (recursive)\n $and: z.array(DriveQuerySchema).optional().describe('Array of conditions that must ALL match'),\n $or: z.array(DriveQuerySchema).optional().describe('Array of conditions where ANY must match'),\n $not: DriveQuerySchema.optional().describe('Nested condition that must NOT match'),\n\n // File/folder name search\n name: z\n .union([z.string().min(1), FieldOperatorSchema])\n .optional()\n .describe('Search by file or folder name (partial match, case-insensitive)'),\n\n // MIME type filtering\n mimeType: z\n .union([z.string().min(1), FieldOperatorSchema])\n .optional()\n .describe('Filter by MIME type (e.g., \"application/pdf\", \"application/vnd.google-apps.folder\", \"image/jpeg\")'),\n\n // Full-text search across content and metadata\n fullText: z\n .union([z.string().min(1), FieldOperatorSchema])\n .optional()\n .describe('Search file content and metadata (full-text search)'),\n\n // Parent folder filtering\n parentId: z\n .union([z.string().min(1), FieldOperatorSchema])\n .optional()\n .describe('Search within specific folder by folder ID (use \"root\" for My Drive root)'),\n\n // Boolean flags\n starred: z.boolean().optional().describe('Filter by starred status (true = starred, false = not starred)'),\n sharedWithMe: z.boolean().optional().describe('Filter by \"shared with me\" collection (true = in shared collection, false = not shared)'),\n trashed: z.boolean().optional().describe('Filter by trash status (true = in trash, false = not in trash).'),\n\n // Date range filtering\n modifiedTime: z\n .object({\n $gte: z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z)?$/)\n .optional()\n .describe('Files modified on or after this date (ISO 8601: YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ)'),\n $lt: z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z)?$/)\n .optional()\n .describe('Files modified before this date (ISO 8601: YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ)'),\n })\n .optional()\n .describe('Filter by modification date range'),\n\n // Owner filtering\n owner: z\n .union([z.string().min(1), FieldOperatorSchema])\n .optional()\n .describe('Filter by owner email address (partial match)'),\n\n // Raw Drive query string - escape hatch for advanced syntax\n rawDriveQuery: z.string().min(1).optional().describe(\"Raw Google Drive query syntax for advanced use cases. Bypasses schema validation - use sparingly. Example: \\\"name contains 'budget' and mimeType = 'application/pdf'\\\"\"),\n })\n .strict()\n) as unknown as z.ZodType<DriveQueryObject>;\n\nexport type DriveQueryObject = {\n $and?: DriveQueryObject[];\n $or?: DriveQueryObject[];\n $not?: DriveQueryObject;\n name?: string | FieldOperator;\n mimeType?: string | FieldOperator;\n fullText?: string | FieldOperator;\n parentId?: string | FieldOperator;\n starred?: boolean;\n sharedWithMe?: boolean;\n trashed?: boolean;\n modifiedTime?: {\n $gte?: string;\n $lt?: string;\n };\n owner?: string | FieldOperator;\n rawDriveQuery?: string;\n};\n\nexport type DriveQuery = DriveQueryObject;\n\n/**\n * Drive query parameter schema that accepts either:\n * - A structured DriveQuery object with typed fields\n * - A JSON string representing that object\n *\n * This provides type safety for common queries while allowing\n * JSON string input from MCP clients when needed.\n */\nexport const DriveQueryParameterSchema = z.union([DriveQuerySchema, z.string().min(1)]) as z.ZodType<DriveQuery | string>;\nexport type DriveQueryParameter = z.infer<typeof DriveQueryParameterSchema>;\n\nexport function parseDriveQueryParameter(input: DriveQuery | string | undefined): DriveQuery | undefined {\n if (input === undefined) return undefined;\n const raw = typeof input === 'string' ? safeJsonParse(input, 'rawDriveQuery') : input;\n const validated = DriveQuerySchema.safeParse(raw);\n if (!validated.success) {\n throw new Error(`Invalid query JSON: ${validated.error.message}. Use {\"rawDriveQuery\":\"<query>\"} for Drive syntax.`);\n }\n return validated.data;\n}\n\nfunction safeJsonParse(value: string, rawField: 'rawDriveQuery'): unknown {\n try {\n return JSON.parse(value);\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Invalid JSON';\n throw new Error(`Query must be valid JSON. ${message}. Wrap Drive syntax in {\"${rawField}\":\"<query>\"} if needed.`);\n }\n}\n"],"names":["DriveQueryParameterSchema","DriveQuerySchema","FieldOperatorSchema","parseDriveQueryParameter","z","object","$any","array","string","optional","describe","$all","$none","strict","lazy","$and","$or","$not","name","union","min","mimeType","fullText","parentId","starred","boolean","sharedWithMe","trashed","modifiedTime","$gte","regex","$lt","owner","rawDriveQuery","input","undefined","raw","safeJsonParse","validated","safeParse","success","Error","error","message","data","value","rawField","JSON","parse"],"mappings":";;;;;;;;;;;QAsIaA;eAAAA;;QA/FAC;eAAAA;;QAjCAC;eAAAA;;QAmIGC;eAAAA;;;mBAzIE;;;;;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,SAASP,cAAcQ,KAAa,EAAEC,QAAyB;IAC7D,IAAI;QACF,OAAOC,KAAKC,KAAK,CAACH;IACpB,EAAE,OAAOH,OAAO;QACd,IAAMC,UAAUD,AAAK,YAALA,OAAiBD,SAAQC,MAAMC,OAAO,GAAG;QACzD,MAAM,IAAIF,MAAM,AAAC,6BAA+DK,OAAnCH,SAAQ,6BAAoC,OAATG,UAAS;IAC3F;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/Projects/mcp-z/mcp-drive/src/schemas/drive-validation.ts"],"sourcesContent":["import { z } from 'zod';\n\n// Drive file schema\nexport const DriveFileSchema = z.object({\n id: z.string().optional(),\n name: z.string().optional(),\n mimeType: z.string().optional().describe('MIME type of the file (e.g., application/pdf, image/png)'),\n webViewLink: z.string().optional().describe('URL to view the file in Google Drive'),\n webContentLink: z.string().optional().describe('Direct download link for the file'),\n modifiedTime: z.string().optional().describe('ISO datetime when file was last modified'),\n createdTime: z.string().optional().describe('ISO datetime when file was created'),\n size: z.string().optional().describe('File size in bytes as string'),\n version: z.string().optional().describe('Version number of the file'),\n shared: z.boolean().optional().describe('Whether the file is shared with others'),\n starred: z.boolean().optional().describe('Whether the file is starred by the user'),\n trashed: z.boolean().optional().describe('Whether the file is in trash'),\n parents: z\n .array(\n z.object({\n id: z.string().describe('Parent folder ID'),\n name: z.string().describe('Parent folder name'),\n })\n )\n .optional()\n .describe('Parent folders with ID and name'),\n owners: z\n .array(\n z.object({\n displayName: z.string().optional(),\n emailAddress: z.string().optional(),\n kind: z.string().optional().describe('Resource type identifier (e.g., \"drive#user\")'),\n me: z.boolean().optional().describe('Whether this owner is the current user'),\n permissionId: z.string().optional().describe('Permission ID for this user'),\n photoLink: z.string().optional().describe('URL to user profile photo'),\n })\n )\n .optional(),\n permissions: z\n .object({\n canEdit: z.boolean().optional(),\n canComment: z.boolean().optional(),\n canShare: z.boolean().optional(),\n })\n .optional()\n .describe(\"Current user's permissions on this file\"),\n});\n\nexport type DriveFile = z.infer<typeof DriveFileSchema>;\n\n// Drive file field definitions for field selection\nexport const DRIVE_FILE_FIELDS = ['id', 'name', 'mimeType', 'webViewLink', 'modifiedTime', 'parents', 'shared', 'starred', 'owners'] as const;\n\nexport const DRIVE_FILE_FIELD_DESCRIPTIONS: Record<(typeof DRIVE_FILE_FIELDS)[number], string> = {\n id: 'Unique file/folder identifier',\n name: 'File or folder name',\n mimeType: 'MIME type (e.g., application/pdf, application/vnd.google-apps.folder)',\n webViewLink: 'URL to view the file in Google Drive',\n modifiedTime: 'Last modification timestamp',\n parents: 'Parent folder IDs',\n shared: 'Whether the file is shared',\n starred: 'Whether the file is starred',\n owners: 'File owner information (displayName, emailAddress, etc.)',\n};\n\nexport const DRIVE_FILE_COMMON_PATTERNS = [\n {\n name: 'Bulk operations (delete/move)',\n fields: 'id,name',\n tokens: '~20 tokens/file',\n },\n {\n name: 'Browsing/filtering',\n fields: 'id,name,mimeType,modifiedTime',\n tokens: '~40 tokens/file',\n },\n {\n name: 'Full metadata',\n fields: 'id,name,mimeType,webViewLink,modifiedTime,owners',\n tokens: '~80 tokens/file',\n },\n] as const;\n"],"names":["DRIVE_FILE_COMMON_PATTERNS","DRIVE_FILE_FIELDS","DRIVE_FILE_FIELD_DESCRIPTIONS","DriveFileSchema","z","object","id","string","optional","name","mimeType","describe","webViewLink","webContentLink","modifiedTime","createdTime","size","version","shared","boolean","starred","trashed","parents","array","owners","displayName","emailAddress","kind","me","permissionId","photoLink","permissions","canEdit","canComment","canShare","fields","tokens"],"mappings":";;;;;;;;;;;QAgEaA;eAAAA;;QAdAC;eAAAA;;QAEAC;eAAAA;;QAjDAC;eAAAA;;;mBAHK;AAGX,IAAMA,kBAAkBC,MAAC,CAACC,MAAM,CAAC;IACtCC,IAAIF,MAAC,CAACG,MAAM,GAAGC,QAAQ;IACvBC,MAAML,MAAC,CAACG,MAAM,GAAGC,QAAQ;IACzBE,UAAUN,MAAC,CAACG,MAAM,GAAGC,QAAQ,GAAGG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G,MAAM,GAAGC,QAAQ,GAAGG,QAAQ,CAAC;IAC5C,IAEDH,QAAQ;IACXuB,aAAa3B,MAAC,CACXC,MAAM,CAAC;QACN2B,SAAS5B,MAAC,CAACe,OAAO,GAAGX,QAAQ;QAC7ByB,YAAY7B,MAAC,CAACe,OAAO,GAAGX,QAAQ;QAChC0B,UAAU9B,MAAC,CAACe,OAAO,GAAGX,QAAQ;IAChC,GACCA,QAAQ,GACRG,QAAQ,CAAC;AACd;AAKO,IAAMV,oBAAoB;IAAC;IAAM;IAAQ;IAAY;IAAe;IAAgB;IAAW;IAAU;IAAW;CAAS;AAE7H,IAAMC,gCAAoF;IAC/FI,IAAI;IACJG,MAAM;IACNC,UAAU;IACVE,aAAa;IACbE,cAAc;IACdQ,SAAS;IACTJ,QAAQ;IACRE,SAAS;IACTI,QAAQ;AACV;AAEO,IAAMxB,6BAA6B;IACxC;QACES,MAAM;QACN0B,QAAQ;QACRC,QAAQ;IACV;IACA;QACE3B,MAAM;QACN0B,QAAQ;QACRC,QAAQ;IACV;IACA;QACE3B,MAAM;QACN0B,QAAQ;QACRC,QAAQ;IACV;CACD"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/schemas/drive-validation.ts"],"sourcesContent":["import { z } from 'zod';\n\n// Drive file schema\nexport const DriveFileSchema = z.object({\n id: z.string().optional(),\n name: z.string().optional(),\n mimeType: z.string().optional().describe('MIME type of the file (e.g., application/pdf, image/png)'),\n webViewLink: z.string().optional().describe('URL to view the file in Google Drive'),\n webContentLink: z.string().optional().describe('Direct download link for the file'),\n modifiedTime: z.string().optional().describe('ISO datetime when file was last modified'),\n createdTime: z.string().optional().describe('ISO datetime when file was created'),\n size: z.string().optional().describe('File size in bytes as string'),\n version: z.string().optional().describe('Version number of the file'),\n shared: z.boolean().optional().describe('Whether the file is shared with others'),\n starred: z.boolean().optional().describe('Whether the file is starred by the user'),\n trashed: z.boolean().optional().describe('Whether the file is in trash'),\n parents: z\n .array(\n z.object({\n id: z.string().describe('Parent folder ID'),\n name: z.string().describe('Parent folder name'),\n })\n )\n .optional()\n .describe('Parent folders with ID and name'),\n owners: z\n .array(\n z.object({\n displayName: z.string().optional(),\n emailAddress: z.string().optional(),\n kind: z.string().optional().describe('Resource type identifier (e.g., \"drive#user\")'),\n me: z.boolean().optional().describe('Whether this owner is the current user'),\n permissionId: z.string().optional().describe('Permission ID for this user'),\n photoLink: z.string().optional().describe('URL to user profile photo'),\n })\n )\n .optional(),\n permissions: z\n .object({\n canEdit: z.boolean().optional(),\n canComment: z.boolean().optional(),\n canShare: z.boolean().optional(),\n })\n .optional()\n .describe(\"Current user's permissions on this file\"),\n});\n\nexport type DriveFile = z.infer<typeof DriveFileSchema>;\n\n// Drive file field definitions for field selection\nexport const DRIVE_FILE_FIELDS = ['id', 'name', 'mimeType', 'webViewLink', 'modifiedTime', 'parents', 'shared', 'starred', 'owners'] as const;\n\nexport const DRIVE_FILE_FIELD_DESCRIPTIONS: Record<(typeof DRIVE_FILE_FIELDS)[number], string> = {\n id: 'Unique file/folder identifier',\n name: 'File or folder name',\n mimeType: 'MIME type (e.g., application/pdf, application/vnd.google-apps.folder)',\n webViewLink: 'URL to view the file in Google Drive',\n modifiedTime: 'Last modification timestamp',\n parents: 'Parent folder IDs',\n shared: 'Whether the file is shared',\n starred: 'Whether the file is starred',\n owners: 'File owner information (displayName, emailAddress, etc.)',\n};\n\nexport const DRIVE_FILE_COMMON_PATTERNS = [\n {\n name: 'Bulk operations (delete/move)',\n fields: 'id,name',\n tokens: '~20 tokens/file',\n },\n {\n name: 'Browsing/filtering',\n fields: 'id,name,mimeType,modifiedTime',\n tokens: '~40 tokens/file',\n },\n {\n name: 'Full metadata',\n fields: 'id,name,mimeType,webViewLink,modifiedTime,owners',\n tokens: '~80 tokens/file',\n },\n] as const;\n"],"names":["DRIVE_FILE_COMMON_PATTERNS","DRIVE_FILE_FIELDS","DRIVE_FILE_FIELD_DESCRIPTIONS","DriveFileSchema","z","object","id","string","optional","name","mimeType","describe","webViewLink","webContentLink","modifiedTime","createdTime","size","version","shared","boolean","starred","trashed","parents","array","owners","displayName","emailAddress","kind","me","permissionId","photoLink","permissions","canEdit","canComment","canShare","fields","tokens"],"mappings":";;;;;;;;;;;QAgEaA;eAAAA;;QAdAC;eAAAA;;QAEAC;eAAAA;;QAjDAC;eAAAA;;;mBAHK;AAGX,IAAMA,kBAAkBC,MAAC,CAACC,MAAM,CAAC;IACtCC,IAAIF,MAAC,CAACG,MAAM,GAAGC,QAAQ;IACvBC,MAAML,MAAC,CAACG,MAAM,GAAGC,QAAQ;IACzBE,UAAUN,MAAC,CAACG,MAAM,GAAGC,QAAQ,GAAGG,QAAQ,CAAC;IACzCC,aAAaR,MAAC,CAACG,MAAM,GAAGC,QAAQ,GAAGG,QAAQ,CAAC;IAC5CE,gBAAgBT,MAAC,CAACG,MAAM,GAAGC,QAAQ,GAAGG,QAAQ,CAAC;IAC/CG,cAAcV,MAAC,CAACG,MAAM,GAAGC,QAAQ,GAAGG,QAAQ,CAAC;IAC7CI,aAAaX,MAAC,CAACG,MAAM,GAAGC,QAAQ,GAAGG,QAAQ,CAAC;IAC5CK,MAAMZ,MAAC,CAACG,MAAM,GAAGC,QAAQ,GAAGG,QAAQ,CAAC;IACrCM,SAASb,MAAC,CAACG,MAAM,GAAGC,QAAQ,GAAGG,QAAQ,CAAC;IACxCO,QAAQd,MAAC,CAACe,OAAO,GAAGX,QAAQ,GAAGG,QAAQ,CAAC;IACxCS,SAAShB,MAAC,CAACe,OAAO,GAAGX,QAAQ,GAAGG,QAAQ,CAAC;IACzCU,SAASjB,MAAC,CAACe,OAAO,GAAGX,QAAQ,GAAGG,QAAQ,CAAC;IACzCW,SAASlB,MAAC,CACPmB,KAAK,CACJnB,MAAC,CAACC,MAAM,CAAC;QACPC,IAAIF,MAAC,CAACG,MAAM,GAAGI,QAAQ,CAAC;QACxBF,MAAML,MAAC,CAACG,MAAM,GAAGI,QAAQ,CAAC;IA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'./drive-query-schema.ts';\nexport * from './drive-validation.ts';\n"],"names":[],"mappings":";;;;qBAAc;qBACA"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/schemas/index.ts"],"sourcesContent":["export * from './drive-query-schema.ts';\nexport * from './drive-validation.ts';\n"],"names":[],"mappings":";;;;qBAAc;qBACA"}
@@ -36,9 +36,7 @@ function _define_property(obj, key, value) {
36
36
  configurable: true,
37
37
  writable: true
38
38
  });
39
- } else {
40
- obj[key] = value;
41
- }
39
+ } else obj[key] = value;
42
40
  return obj;
43
41
  }
44
42
  function _interop_require_default(obj) {
@@ -55,18 +53,12 @@ function _getRequireWildcardCache(nodeInterop) {
55
53
  })(nodeInterop);
56
54
  }
57
55
  function _interop_require_wildcard(obj, nodeInterop) {
58
- if (!nodeInterop && obj && obj.__esModule) {
59
- return obj;
60
- }
61
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
62
- return {
63
- default: obj
64
- };
65
- }
56
+ if (!nodeInterop && obj && obj.__esModule) return obj;
57
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
58
+ default: obj
59
+ };
66
60
  var cache = _getRequireWildcardCache(nodeInterop);
67
- if (cache && cache.has(obj)) {
68
- return cache.get(obj);
69
- }
61
+ if (cache && cache.has(obj)) return cache.get(obj);
70
62
  var newObj = {
71
63
  __proto__: null
72
64
  };
@@ -74,17 +66,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
74
66
  for(var key in obj){
75
67
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
76
68
  var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
77
- if (desc && (desc.get || desc.set)) {
78
- Object.defineProperty(newObj, key, desc);
79
- } else {
80
- newObj[key] = obj[key];
81
- }
69
+ if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
70
+ else newObj[key] = obj[key];
82
71
  }
83
72
  }
84
73
  newObj.default = obj;
85
- if (cache) {
86
- cache.set(obj, newObj);
87
- }
74
+ if (cache) cache.set(obj, newObj);
88
75
  return newObj;
89
76
  }
90
77
  function _object_spread(target) {
@@ -117,9 +104,8 @@ function ownKeys(object, enumerableOnly) {
117
104
  }
118
105
  function _object_spread_props(target, source) {
119
106
  source = source != null ? source : {};
120
- if (Object.getOwnPropertyDescriptors) {
121
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
122
- } else {
107
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
108
+ else {
123
109
  ownKeys(Object(source)).forEach(function(key) {
124
110
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
125
111
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/Projects/mcp-z/mcp-drive/src/setup/config.ts"],"sourcesContent":["import { parseDcrConfig, parseConfig as parseOAuthConfig } from '@mcp-z/oauth-google';\nimport { findConfigPath, parseConfig as parseTransportConfig } from '@mcp-z/server';\nimport * as fs from 'fs';\nimport moduleRoot from 'module-root-sync';\nimport { homedir } from 'os';\nimport * as path from 'path';\nimport * as url from 'url';\nimport { parseArgs } from 'util';\nimport { GOOGLE_SCOPE } from '../constants.ts';\nimport type { ServerConfig } from '../types.ts';\n\nconst pkg = JSON.parse(fs.readFileSync(path.join(moduleRoot(url.fileURLToPath(import.meta.url)), 'package.json'), 'utf-8'));\n\nconst HELP_TEXT = `\nUsage: mcp-drive [options]\n\nMCP server for Google Drive file management with OAuth authentication.\n\nOptions:\n --version Show version number\n --help Show this help message\n --auth=<mode> Authentication mode (default: loopback-oauth)\n Modes: loopback-oauth, service-account, dcr\n --headless Disable browser auto-open, return auth URL instead\n --redirect-uri=<uri> OAuth redirect URI (default: ephemeral loopback)\n --dcr-mode=<mode> DCR mode (self-hosted or external, default: self-hosted)\n --dcr-verify-url=<url> External verification endpoint (required for external mode)\n --dcr-store-uri=<uri> DCR client storage URI (required for self-hosted mode)\n --port=<port> Enable HTTP transport on specified port\n --stdio Enable stdio transport (default if no port)\n --log-level=<level> Logging level (default: info)\n --resource-store-uri=<uri> Resource store URI for CSV file storage (default: file://~/.mcp-z/mcp-drive/files)\n --base-url=<url> Base URL for HTTP file serving (optional)\n\nEnvironment Variables:\n GOOGLE_CLIENT_ID OAuth client ID (REQUIRED)\n GOOGLE_CLIENT_SECRET OAuth client secret (optional)\n AUTH_MODE Default authentication mode (optional)\n HEADLESS Disable browser auto-open (optional)\n DCR_MODE DCR mode (optional, same format as --dcr-mode)\n DCR_VERIFY_URL External verification URL (optional, same as --dcr-verify-url)\n DCR_STORE_URI DCR storage URI (optional, same as --dcr-store-uri)\n TOKEN_STORE_URI Token storage URI (optional)\n PORT Default HTTP port (optional)\n LOG_LEVEL Default logging level (optional)\n RESOURCE_STORE_URI Resource store URI (optional, file://)\n BASE_URL Base URL for HTTP file serving (optional)\n\nOAuth Scopes:\n openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/drive\n\nExamples:\n mcp-drive # Use default settings\n mcp-drive --auth=service-account # Use service account auth\n mcp-drive --port=3000 # HTTP transport on port 3000\n mcp-drive --resource-store-uri=file:///tmp/drive # Custom resource store URI\n GOOGLE_CLIENT_ID=xxx mcp-drive # Set client ID via env var\n`.trim();\n\n/**\n * Handle --version and --help flags before config parsing.\n * These should work without requiring any configuration.\n */\nexport function handleVersionHelp(args: string[]): { handled: boolean; output?: string } {\n const { values } = parseArgs({\n args,\n options: {\n version: { type: 'boolean' },\n help: { type: 'boolean' },\n },\n strict: false,\n });\n\n if (values.version) return { handled: true, output: pkg.version };\n if (values.help) return { handled: true, output: HELP_TEXT };\n return { handled: false };\n}\n\n/**\n * Parse Drive server configuration from CLI arguments and environment.\n *\n * CLI Arguments (all optional):\n * - --auth=<mode> Authentication mode (default: loopback-oauth)\n * Modes: loopback-oauth, service-account, dcr\n * - --headless Disable browser auto-open, return auth URL instead\n * - --redirect-uri=<uri> OAuth redirect URI (default: ephemeral loopback)\n * - --dcr-mode=<mode> DCR mode (self-hosted or external, default: self-hosted)\n * - --dcr-verify-url=<url> External verification endpoint (required for external mode)\n * - --dcr-store-uri=<uri> DCR client storage URI (required for self-hosted mode)\n * - --port=<port> Enable HTTP transport on specified port\n * - --stdio Enable stdio transport (default if no port)\n * - --log-level=<level> Logging level (default: info)\n * - --resource-store-uri=<uri> Resource store URI for CSV file storage (default: file://~/.mcp-z/mcp-drive/files)\n * - --base-url=<url> Base URL for HTTP file serving (optional)\n *\n * Environment Variables:\n * - GOOGLE_CLIENT_ID OAuth client ID (REQUIRED)\n * - GOOGLE_CLIENT_SECRET OAuth client secret (optional)\n * - AUTH_MODE Default authentication mode (optional)\n * - HEADLESS Disable browser auto-open (optional)\n * - DCR_MODE DCR mode (optional, same format as --dcr-mode)\n * - DCR_VERIFY_URL External verification URL (optional, same as --dcr-verify-url)\n * - DCR_STORE_URI DCR storage URI (optional, same as --dcr-store-uri)\n * - TOKEN_STORE_URI Token storage URI (optional)\n * - PORT Default HTTP port (optional)\n * - LOG_LEVEL Default logging level (optional)\n * - RESOURCE_STORE_URI Resource store URI (optional, file://)\n * - BASE_URL Base URL for HTTP file serving (optional)\n *\n * OAuth Scopes (from constants.ts):\n * openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/drive\n */\nexport function parseConfig(args: string[], env: Record<string, string | undefined>): ServerConfig {\n const transportConfig = parseTransportConfig(args, env);\n const oauthConfig = parseOAuthConfig(args, env);\n\n // Parse DCR configuration if DCR mode is enabled\n const dcrConfig = oauthConfig.auth === 'dcr' ? parseDcrConfig(args, env, GOOGLE_SCOPE) : undefined;\n\n // Parse application-level config (LOG_LEVEL, RESOURCE_STORE_URI, BASE_URL)\n const { values } = parseArgs({\n args,\n options: {\n 'log-level': { type: 'string' },\n 'base-url': { type: 'string' },\n 'resource-store-uri': { type: 'string' },\n },\n strict: false, // Allow other arguments\n allowPositionals: true,\n });\n\n const name = pkg.name.replace(/^@[^/]+\\//, '');\n // Parse repository URL from package.json, stripping git+ prefix and .git suffix\n const rawRepoUrl = typeof pkg.repository === 'object' ? pkg.repository.url : pkg.repository;\n const repositoryUrl = rawRepoUrl?.replace(/^git\\+/, '').replace(/\\.git$/, '') ?? `https://github.com/mcp-z/${name}`;\n let rootDir = homedir();\n try {\n const configPath = findConfigPath({ config: '.mcp.json', cwd: process.cwd(), stopDir: homedir() });\n rootDir = path.dirname(configPath);\n } catch {\n rootDir = homedir();\n }\n const baseDir = path.join(rootDir, '.mcp-z');\n const cliLogLevel = typeof values['log-level'] === 'string' ? values['log-level'] : undefined;\n const envLogLevel = env.LOG_LEVEL;\n const logLevel = cliLogLevel ?? envLogLevel ?? 'info';\n\n // Parse storage configuration\n const cliResourceStoreUri = typeof values['resource-store-uri'] === 'string' ? values['resource-store-uri'] : undefined;\n const envResourceStoreUri = env.RESOURCE_STORE_URI;\n const defaultResourceStorePath = path.join(baseDir, name, 'files');\n const resourceStoreUri = normalizeResourceStoreUri(cliResourceStoreUri ?? envResourceStoreUri ?? defaultResourceStorePath);\n\n const cliBaseUrl = typeof values['base-url'] === 'string' ? values['base-url'] : undefined;\n const envBaseUrl = env.BASE_URL;\n const baseUrl = cliBaseUrl ?? envBaseUrl;\n\n // Combine configs\n return {\n ...oauthConfig, // Includes clientId, auth, headless, redirectUri\n transport: transportConfig.transport,\n logLevel,\n baseDir,\n name,\n version: pkg.version,\n repositoryUrl,\n resourceStoreUri,\n ...(baseUrl && { baseUrl }),\n ...(dcrConfig && { dcrConfig }),\n };\n}\n\nfunction normalizeResourceStoreUri(resourceStoreUri: string): string {\n const filePrefix = 'file://';\n if (resourceStoreUri.startsWith(filePrefix)) {\n const rawPath = resourceStoreUri.slice(filePrefix.length);\n const expandedPath = rawPath.startsWith('~') ? rawPath.replace(/^~/, homedir()) : rawPath;\n return `${filePrefix}${path.resolve(expandedPath)}`;\n }\n\n if (resourceStoreUri.includes('://')) return resourceStoreUri;\n\n const expandedPath = resourceStoreUri.startsWith('~') ? resourceStoreUri.replace(/^~/, homedir()) : resourceStoreUri;\n return `${filePrefix}${path.resolve(expandedPath)}`;\n}\n\n/**\n * Build production configuration from process globals.\n * Entry point for production server.\n */\nexport function createConfig(): ServerConfig {\n return parseConfig(process.argv, process.env);\n}\n"],"names":["createConfig","handleVersionHelp","parseConfig","pkg","JSON","parse","fs","readFileSync","path","join","moduleRoot","url","fileURLToPath","HELP_TEXT","trim","args","values","parseArgs","options","version","type","help","strict","handled","output","env","cliLogLevel","cliResourceStoreUri","transportConfig","parseTransportConfig","oauthConfig","parseOAuthConfig","dcrConfig","auth","parseDcrConfig","GOOGLE_SCOPE","undefined","allowPositionals","name","replace","rawRepoUrl","repository","repositoryUrl","rootDir","homedir","configPath","findConfigPath","config","cwd","process","stopDir","dirname","baseDir","envLogLevel","LOG_LEVEL","logLevel","envResourceStoreUri","RESOURCE_STORE_URI","defaultResourceStorePath","resourceStoreUri","normalizeResourceStoreUri","cliBaseUrl","envBaseUrl","BASE_URL","baseUrl","transport","filePrefix","startsWith","rawPath","slice","length","expandedPath","resolve","includes","argv"],"mappings":";;;;;;;;;;;QA8LgBA;eAAAA;;QA/HAC;eAAAA;;QAiDAC;eAAAA;;;2BAhHgD;sBACI;0DAChD;qEACG;kBACC;4DACF;2DACD;oBACK;2BACG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG7B,IAAMC,MAAMC,KAAKC,KAAK,CAACC,IAAGC,YAAY,CAACC,MAAKC,IAAI,CAACC,IAAAA,uBAAU,EAACC,KAAIC,aAAa,CAAC,uDAAmB,iBAAiB;AAElH,IAAMC,YAAY,o6EA4ChBC,IAAI;AAMC,SAASb,kBAAkBc,IAAc;IAC9C,IAAM,AAAEC,SAAWC,IAAAA,eAAS,EAAC;QAC3BF,MAAAA;QACAG,SAAS;YACPC,SA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,WAAWI,MAAM;QACxD,IAAMC,eAAeH,QAAQD,UAAU,CAAC,OAAOC,QAAQ7B,OAAO,CAAC,MAAMK,IAAAA,WAAO,OAAMwB;QAClF,OAAO,AAAC,GAAe5D,OAAb0D,YAAwC,OAA3B1D,MAAKgE,OAAO,CAACD;IACtC;IAEA,IAAIZ,iBAAiBc,QAAQ,CAAC,QAAQ,OAAOd;IAE7C,IAAMY,gBAAeZ,iBAAiBQ,UAAU,CAAC,OAAOR,iBAAiBpB,OAAO,CAAC,MAAMK,IAAAA,WAAO,OAAMe;IACpG,OAAO,AAAC,GAAenD,OAAb0D,YAAwC,OAA3B1D,MAAKgE,OAAO,CAACD;AACtC;AAMO,SAASvE;IACd,OAAOE,YAAY+C,QAAQyB,IAAI,EAAEzB,QAAQxB,GAAG;AAC9C"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/setup/config.ts"],"sourcesContent":["import { parseDcrConfig, parseConfig as parseOAuthConfig } from '@mcp-z/oauth-google';\nimport { findConfigPath, parseConfig as parseTransportConfig } from '@mcp-z/server';\nimport * as fs from 'fs';\nimport moduleRoot from 'module-root-sync';\nimport { homedir } from 'os';\nimport * as path from 'path';\nimport * as url from 'url';\nimport { parseArgs } from 'util';\nimport { GOOGLE_SCOPE } from '../constants.ts';\nimport type { ServerConfig } from '../types.ts';\n\nconst pkg = JSON.parse(fs.readFileSync(path.join(moduleRoot(url.fileURLToPath(import.meta.url)), 'package.json'), 'utf-8'));\n\nconst HELP_TEXT = `\nUsage: mcp-drive [options]\n\nMCP server for Google Drive file management with OAuth authentication.\n\nOptions:\n --version Show version number\n --help Show this help message\n --auth=<mode> Authentication mode (default: loopback-oauth)\n Modes: loopback-oauth, service-account, dcr\n --headless Disable browser auto-open, return auth URL instead\n --redirect-uri=<uri> OAuth redirect URI (default: ephemeral loopback)\n --dcr-mode=<mode> DCR mode (self-hosted or external, default: self-hosted)\n --dcr-verify-url=<url> External verification endpoint (required for external mode)\n --dcr-store-uri=<uri> DCR client storage URI (required for self-hosted mode)\n --port=<port> Enable HTTP transport on specified port\n --stdio Enable stdio transport (default if no port)\n --log-level=<level> Logging level (default: info)\n --resource-store-uri=<uri> Resource store URI for CSV file storage (default: file://~/.mcp-z/mcp-drive/files)\n --base-url=<url> Base URL for HTTP file serving (optional)\n\nEnvironment Variables:\n GOOGLE_CLIENT_ID OAuth client ID (REQUIRED)\n GOOGLE_CLIENT_SECRET OAuth client secret (optional)\n AUTH_MODE Default authentication mode (optional)\n HEADLESS Disable browser auto-open (optional)\n DCR_MODE DCR mode (optional, same format as --dcr-mode)\n DCR_VERIFY_URL External verification URL (optional, same as --dcr-verify-url)\n DCR_STORE_URI DCR storage URI (optional, same as --dcr-store-uri)\n TOKEN_STORE_URI Token storage URI (optional)\n PORT Default HTTP port (optional)\n LOG_LEVEL Default logging level (optional)\n RESOURCE_STORE_URI Resource store URI (optional, file://)\n BASE_URL Base URL for HTTP file serving (optional)\n\nOAuth Scopes:\n openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/drive\n\nExamples:\n mcp-drive # Use default settings\n mcp-drive --auth=service-account # Use service account auth\n mcp-drive --port=3000 # HTTP transport on port 3000\n mcp-drive --resource-store-uri=file:///tmp/drive # Custom resource store URI\n GOOGLE_CLIENT_ID=xxx mcp-drive # Set client ID via env var\n`.trim();\n\n/**\n * Handle --version and --help flags before config parsing.\n * These should work without requiring any configuration.\n */\nexport function handleVersionHelp(args: string[]): { handled: boolean; output?: string } {\n const { values } = parseArgs({\n args,\n options: {\n version: { type: 'boolean' },\n help: { type: 'boolean' },\n },\n strict: false,\n });\n\n if (values.version) return { handled: true, output: pkg.version };\n if (values.help) return { handled: true, output: HELP_TEXT };\n return { handled: false };\n}\n\n/**\n * Parse Drive server configuration from CLI arguments and environment.\n *\n * CLI Arguments (all optional):\n * - --auth=<mode> Authentication mode (default: loopback-oauth)\n * Modes: loopback-oauth, service-account, dcr\n * - --headless Disable browser auto-open, return auth URL instead\n * - --redirect-uri=<uri> OAuth redirect URI (default: ephemeral loopback)\n * - --dcr-mode=<mode> DCR mode (self-hosted or external, default: self-hosted)\n * - --dcr-verify-url=<url> External verification endpoint (required for external mode)\n * - --dcr-store-uri=<uri> DCR client storage URI (required for self-hosted mode)\n * - --port=<port> Enable HTTP transport on specified port\n * - --stdio Enable stdio transport (default if no port)\n * - --log-level=<level> Logging level (default: info)\n * - --resource-store-uri=<uri> Resource store URI for CSV file storage (default: file://~/.mcp-z/mcp-drive/files)\n * - --base-url=<url> Base URL for HTTP file serving (optional)\n *\n * Environment Variables:\n * - GOOGLE_CLIENT_ID OAuth client ID (REQUIRED)\n * - GOOGLE_CLIENT_SECRET OAuth client secret (optional)\n * - AUTH_MODE Default authentication mode (optional)\n * - HEADLESS Disable browser auto-open (optional)\n * - DCR_MODE DCR mode (optional, same format as --dcr-mode)\n * - DCR_VERIFY_URL External verification URL (optional, same as --dcr-verify-url)\n * - DCR_STORE_URI DCR storage URI (optional, same as --dcr-store-uri)\n * - TOKEN_STORE_URI Token storage URI (optional)\n * - PORT Default HTTP port (optional)\n * - LOG_LEVEL Default logging level (optional)\n * - RESOURCE_STORE_URI Resource store URI (optional, file://)\n * - BASE_URL Base URL for HTTP file serving (optional)\n *\n * OAuth Scopes (from constants.ts):\n * openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/drive\n */\nexport function parseConfig(args: string[], env: Record<string, string | undefined>): ServerConfig {\n const transportConfig = parseTransportConfig(args, env);\n const oauthConfig = parseOAuthConfig(args, env);\n\n // Parse DCR configuration if DCR mode is enabled\n const dcrConfig = oauthConfig.auth === 'dcr' ? parseDcrConfig(args, env, GOOGLE_SCOPE) : undefined;\n\n // Parse application-level config (LOG_LEVEL, RESOURCE_STORE_URI, BASE_URL)\n const { values } = parseArgs({\n args,\n options: {\n 'log-level': { type: 'string' },\n 'base-url': { type: 'string' },\n 'resource-store-uri': { type: 'string' },\n },\n strict: false, // Allow other arguments\n allowPositionals: true,\n });\n\n const name = pkg.name.replace(/^@[^/]+\\//, '');\n // Parse repository URL from package.json, stripping git+ prefix and .git suffix\n const rawRepoUrl = typeof pkg.repository === 'object' ? pkg.repository.url : pkg.repository;\n const repositoryUrl = rawRepoUrl?.replace(/^git\\+/, '').replace(/\\.git$/, '') ?? `https://github.com/mcp-z/${name}`;\n let rootDir = homedir();\n try {\n const configPath = findConfigPath({ config: '.mcp.json', cwd: process.cwd(), stopDir: homedir() });\n rootDir = path.dirname(configPath);\n } catch {\n rootDir = homedir();\n }\n const baseDir = path.join(rootDir, '.mcp-z');\n const cliLogLevel = typeof values['log-level'] === 'string' ? values['log-level'] : undefined;\n const envLogLevel = env.LOG_LEVEL;\n const logLevel = cliLogLevel ?? envLogLevel ?? 'info';\n\n // Parse storage configuration\n const cliResourceStoreUri = typeof values['resource-store-uri'] === 'string' ? values['resource-store-uri'] : undefined;\n const envResourceStoreUri = env.RESOURCE_STORE_URI;\n const defaultResourceStorePath = path.join(baseDir, name, 'files');\n const resourceStoreUri = normalizeResourceStoreUri(cliResourceStoreUri ?? envResourceStoreUri ?? defaultResourceStorePath);\n\n const cliBaseUrl = typeof values['base-url'] === 'string' ? values['base-url'] : undefined;\n const envBaseUrl = env.BASE_URL;\n const baseUrl = cliBaseUrl ?? envBaseUrl;\n\n // Combine configs\n return {\n ...oauthConfig, // Includes clientId, auth, headless, redirectUri\n transport: transportConfig.transport,\n logLevel,\n baseDir,\n name,\n version: pkg.version,\n repositoryUrl,\n resourceStoreUri,\n ...(baseUrl && { baseUrl }),\n ...(dcrConfig && { dcrConfig }),\n };\n}\n\nfunction normalizeResourceStoreUri(resourceStoreUri: string): string {\n const filePrefix = 'file://';\n if (resourceStoreUri.startsWith(filePrefix)) {\n const rawPath = resourceStoreUri.slice(filePrefix.length);\n const expandedPath = rawPath.startsWith('~') ? rawPath.replace(/^~/, homedir()) : rawPath;\n return `${filePrefix}${path.resolve(expandedPath)}`;\n }\n\n if (resourceStoreUri.includes('://')) return resourceStoreUri;\n\n const expandedPath = resourceStoreUri.startsWith('~') ? resourceStoreUri.replace(/^~/, homedir()) : resourceStoreUri;\n return `${filePrefix}${path.resolve(expandedPath)}`;\n}\n\n/**\n * Build production configuration from process globals.\n * Entry point for production server.\n */\nexport function createConfig(): ServerConfig {\n return parseConfig(process.argv, process.env);\n}\n"],"names":["createConfig","handleVersionHelp","parseConfig","pkg","JSON","parse","fs","readFileSync","path","join","moduleRoot","url","fileURLToPath","HELP_TEXT","trim","args","values","parseArgs","options","version","type","help","strict","handled","output","env","cliLogLevel","cliResourceStoreUri","transportConfig","parseTransportConfig","oauthConfig","parseOAuthConfig","dcrConfig","auth","parseDcrConfig","GOOGLE_SCOPE","undefined","allowPositionals","name","replace","rawRepoUrl","repository","repositoryUrl","rootDir","homedir","configPath","findConfigPath","config","cwd","process","stopDir","dirname","baseDir","envLogLevel","LOG_LEVEL","logLevel","envResourceStoreUri","RESOURCE_STORE_URI","defaultResourceStorePath","resourceStoreUri","normalizeResourceStoreUri","cliBaseUrl","envBaseUrl","BASE_URL","baseUrl","transport","filePrefix","startsWith","rawPath","slice","length","expandedPath","resolve","includes","argv"],"mappings":";;;;;;;;;;;QA8LgBA;eAAAA;;QA/HAC;eAAAA;;QAiDAC;eAAAA;;;2BAhHgD;sBACI;0DAChD;qEACG;kBACC;4DACF;2DACD;oBACK;2BACG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG7B,IAAMC,MAAMC,KAAKC,KAAK,CAACC,IAAGC,YAAY,CAACC,MAAKC,IAAI,CAACC,IAAAA,uBAAU,EAACC,KAAIC,aAAa,CAAC,uDAAmB,iBAAiB;AAElH,IAAMC,YAAY,o6EA4ChBC,IAAI;AAMC,SAASb,kBAAkBc,IAAc;IAC9C,IAAM,AAAEC,SAAWC,IAAAA,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,aAAa;QAC3C,IAAME,UAAUT,iBAAiBU,KAAK,CAACH,WAAWI,MAAM;QACxD,IAAMC,eAAeH,QAAQD,UAAU,CAAC,OAAOC,QAAQ7B,OAAO,CAAC,MAAMK,IAAAA,WAAO,OAAMwB;QAClF,OAAO,AAAC,GAAe5D,OAAb0D,YAAwC,OAA3B1D,MAAKgE,OAAO,CAACD;IACtC;IAEA,IAAIZ,iBAAiBc,QAAQ,CAAC,QAAQ,OAAOd;IAE7C,IAAMY,gBAAeZ,iBAAiBQ,UAAU,CAAC,OAAOR,iBAAiBpB,OAAO,CAAC,MAAMK,IAAAA,WAAO,OAAMe;IACpG,OAAO,AAAC,GAAenD,OAAb0D,YAAwC,OAA3B1D,MAAKgE,OAAO,CAACD;AACtC;AAMO,SAASvE;IACd,OAAOE,YAAY+C,QAAQyB,IAAI,EAAEzB,QAAQxB,GAAG;AAC9C"}
@@ -29,11 +29,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
29
29
  reject(error);
30
30
  return;
31
31
  }
32
- if (info.done) {
33
- resolve(value);
34
- } else {
35
- Promise.resolve(value).then(_next, _throw);
36
- }
32
+ if (info.done) resolve(value);
33
+ else Promise.resolve(value).then(_next, _throw);
37
34
  }
38
35
  function _async_to_generator(fn) {
39
36
  return function() {
@@ -56,22 +53,16 @@ function _interop_require_default(obj) {
56
53
  };
57
54
  }
58
55
  function _iterable_to_array(iter) {
59
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
56
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
57
+ return Array.from(iter);
58
+ }
60
59
  }
61
60
  function _non_iterable_spread() {
62
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
61
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
63
62
  }
64
63
  function _to_consumable_array(arr) {
65
64
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
66
65
  }
67
- function _unsupported_iterable_to_array(o, minLen) {
68
- if (!o) return;
69
- if (typeof o === "string") return _array_like_to_array(o, minLen);
70
- var n = Object.prototype.toString.call(o).slice(8, -1);
71
- if (n === "Object" && o.constructor) n = o.constructor.name;
72
- if (n === "Map" || n === "Set") return Array.from(n);
73
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
74
- }
75
66
  function _ts_generator(thisArg, body) {
76
67
  var f, y, t, _ = {
77
68
  label: 0,
@@ -171,6 +162,14 @@ function _ts_generator(thisArg, body) {
171
162
  };
172
163
  }
173
164
  }
165
+ function _unsupported_iterable_to_array(o, minLen) {
166
+ if (!o) return;
167
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
168
+ var n = Object.prototype.toString.call(o).slice(8, -1);
169
+ if (n === "Object" && o.constructor) n = o.constructor.name;
170
+ if (n === "Map" || n === "Set") return Array.from(n);
171
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
172
+ }
174
173
  function createHTTPServer(config, overrides) {
175
174
  return _async_to_generator(function() {
176
175
  var runtime, modules, layers, composed, logger, port, tools, prompts, mcpServer, app, _ref, close, httpServer;
@@ -231,7 +230,7 @@ function createHTTPServer(config, overrides) {
231
230
  httpServer: httpServer,
232
231
  mcpServer: mcpServer,
233
232
  logger: logger,
234
- close: function() {
233
+ close: function close1() {
235
234
  return _async_to_generator(function() {
236
235
  return _ts_generator(this, function(_state) {
237
236
  switch(_state.label){
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/Projects/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(cors());\n app.use(express.json({ limit: '10mb' }));\n\n if (runtime.deps.oauthAdapters.loopbackRouter) {\n app.use('/', runtime.deps.oauthAdapters.loopbackRouter);\n logger.info('Mounted loopback OAuth callback router');\n }\n\n if (runtime.deps.oauthAdapters.dcrRouter) {\n app.use('/', runtime.deps.oauthAdapters.dcrRouter);\n logger.info('Mounted DCR router with OAuth endpoints');\n }\n\n logger.info(`Starting ${config.name} MCP server (http)`);\n const { close, httpServer } = await connectHttp(mcpServer, { logger, app, port });\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","close","httpServer","createDefaultRuntime","createDomainModules","middlewareFactories","map","factory","deps","composeMiddleware","transport","Error","oauthAdapters","accountTools","accountPrompts","McpServer","name","version","registerTools","registerResources","resources","registerPrompts","express","use","cors","json","limit","loopbackRouter","info","dcrRouter","connectHttp"],"mappings":";;;;+BAOsBA;;;eAAAA;;;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,IAAIuB,GAAG,CAACD,gBAAO,CAACG,IAAI,CAAC;wBAAEC,OAAO;oBAAO;oBAErC,IAAInC,QAAQiB,IAAI,CAACI,aAAa,CAACe,cAAc,EAAE;wBAC7C3B,IAAIuB,GAAG,CAAC,KAAKhC,QAAQiB,IAAI,CAACI,aAAa,CAACe,cAAc;wBACtDhC,OAAOiC,IAAI,CAAC;oBACd;oBAEA,IAAIrC,QAAQiB,IAAI,CAACI,aAAa,CAACiB,SAAS,EAAE;wBACxC7B,IAAIuB,GAAG,CAAC,KAAKhC,QAAQiB,IAAI,CAACI,aAAa,CAACiB,SAAS;wBACjDlC,OAAOiC,IAAI,CAAC;oBACd;oBAEAjC,OAAOiC,IAAI,CAAC,AAAC,YAAuB,OAAZvC,OAAO2B,IAAI,EAAC;oBACN;;wBAAMc,IAAAA,mBAAW,EAAC/B,WAAW;4BAAEJ,QAAAA;4BAAQK,KAAAA;4BAAKJ,MAAAA;wBAAK;;;oBAAjD,OAAA,eAAtBK,QAAsB,KAAtBA,OAAOC,aAAe,KAAfA;oBACfP,OAAOiC,IAAI,CAAC;oBAEZ;;wBAAO;4BACL1B,YAAAA;4BACAH,WAAAA;4BACAJ,QAAAA;4BACAM,OAAO;;;;;gDACL;;oDAAMA;;;gDAAN;gDACA;;oDAAMV,QAAQU,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, 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(cors());\n app.use(express.json({ limit: '10mb' }));\n\n if (runtime.deps.oauthAdapters.loopbackRouter) {\n app.use('/', runtime.deps.oauthAdapters.loopbackRouter);\n logger.info('Mounted loopback OAuth callback router');\n }\n\n if (runtime.deps.oauthAdapters.dcrRouter) {\n app.use('/', runtime.deps.oauthAdapters.dcrRouter);\n logger.info('Mounted DCR router with OAuth endpoints');\n }\n\n logger.info(`Starting ${config.name} MCP server (http)`);\n const { close, httpServer } = await connectHttp(mcpServer, { logger, app, port });\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","close","httpServer","createDefaultRuntime","createDomainModules","middlewareFactories","map","factory","deps","composeMiddleware","transport","Error","oauthAdapters","accountTools","accountPrompts","McpServer","name","version","registerTools","registerResources","resources","registerPrompts","express","use","cors","json","limit","loopbackRouter","info","dcrRouter","connectHttp"],"mappings":";;;;+BAOsBA;;;eAAAA;;;sBAP4E;mBACxE;2DACT;8DACG;yBAEiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9B,SAAe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ACd;oBAEA,IAAIrC,QAAQiB,IAAI,CAACI,aAAa,CAACiB,SAAS,EAAE;wBACxC7B,IAAIuB,GAAG,CAAC,KAAKhC,QAAQiB,IAAI,CAACI,aAAa,CAACiB,SAAS;wBACjDlC,OAAOiC,IAAI,CAAC;oBACd;oBAEAjC,OAAOiC,IAAI,CAAC,AAAC,YAAuB,OAAZvC,OAAO2B,IAAI,EAAC;oBACN;;wBAAMc,IAAAA,mBAAW,EAAC/B,WAAW;4BAAEJ,QAAAA;4BAAQK,KAAAA;4BAAKJ,MAAAA;wBAAK;;;oBAAjD,OAAA,eAAtBK,QAAsB,KAAtBA,OAAOC,aAAe,KAAfA;oBACfP,OAAOiC,IAAI,CAAC;oBAEZ;;wBAAO;4BACL1B,YAAAA;4BACAH,WAAAA;4BACAJ,QAAAA;4BACAM,OAAO,SAAPA;;;;;gDACE;;oDAAMA;;;gDAAN;gDACA;;oDAAMV,QAAQU,KAAK;;;gDAAnB;;;;;;gCACF;;wBACF;;;;IACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/Projects/mcp-z/mcp-drive/src/setup/index.ts"],"sourcesContent":["export { createConfig, parseConfig } from './config.ts';\nexport { createHTTPServer } from './http.ts';\nexport type { AuthMiddleware, OAuthAdapters, OAuthRuntimeDeps } from './oauth-google.ts';\nexport { createOAuthAdapters } from './oauth-google.ts';\nexport * from './runtime.ts';\nexport { createStdioServer } from './stdio.ts';\n"],"names":["createConfig","createHTTPServer","createOAuthAdapters","createStdioServer","parseConfig"],"mappings":";;;;;;;;;;;QAASA;eAAAA,sBAAY;;QACZC;eAAAA,wBAAgB;;QAEhBC;eAAAA,kCAAmB;;QAEnBC;eAAAA,0BAAiB;;QALHC;eAAAA,qBAAW;;;wBAAQ;sBACT;6BAEG;qBACtB;uBACoB"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/setup/index.ts"],"sourcesContent":["export { createConfig, parseConfig } from './config.ts';\nexport { createHTTPServer } from './http.ts';\nexport type { AuthMiddleware, OAuthAdapters, OAuthRuntimeDeps } from './oauth-google.ts';\nexport { createOAuthAdapters } from './oauth-google.ts';\nexport * from './runtime.ts';\nexport { createStdioServer } from './stdio.ts';\n"],"names":["createConfig","createHTTPServer","createOAuthAdapters","createStdioServer","parseConfig"],"mappings":";;;;;;;;;;;QAASA;eAAAA,sBAAY;;QACZC;eAAAA,wBAAgB;;QAEhBC;eAAAA,kCAAmB;;QAEnBC;eAAAA,0BAAiB;;QALHC;eAAAA,qBAAW;;;wBAAQ;sBACT;6BAEG;qBACtB;uBACoB"}
@@ -19,11 +19,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
19
19
  reject(error);
20
20
  return;
21
21
  }
22
- if (info.done) {
23
- resolve(value);
24
- } else {
25
- Promise.resolve(value).then(_next, _throw);
26
- }
22
+ if (info.done) resolve(value);
23
+ else Promise.resolve(value).then(_next, _throw);
27
24
  }
28
25
  function _async_to_generator(fn) {
29
26
  return function() {
@@ -48,17 +45,14 @@ function _define_property(obj, key, value) {
48
45
  configurable: true,
49
46
  writable: true
50
47
  });
51
- } else {
52
- obj[key] = value;
53
- }
48
+ } else obj[key] = value;
54
49
  return obj;
55
50
  }
56
51
  function _instanceof(left, right) {
52
+ "@swc/helpers - instanceof";
57
53
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
58
54
  return !!right[Symbol.hasInstance](left);
59
- } else {
60
- return left instanceof right;
61
- }
55
+ } else return left instanceof right;
62
56
  }
63
57
  function _object_spread(target) {
64
58
  for(var i = 1; i < arguments.length; i++){
@@ -90,9 +84,8 @@ function ownKeys(object, enumerableOnly) {
90
84
  }
91
85
  function _object_spread_props(target, source) {
92
86
  source = source != null ? source : {};
93
- if (Object.getOwnPropertyDescriptors) {
94
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
95
- } else {
87
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
88
+ else {
96
89
  ownKeys(Object(source)).forEach(function(key) {
97
90
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
98
91
  });
@@ -255,10 +248,10 @@ function createOAuthAdapters(config, deps, baseUrl) {
255
248
  middleware = primary.authMiddleware();
256
249
  // Create auth email provider (stateless)
257
250
  authAdapter = {
258
- getAccessToken: function() {
251
+ getAccessToken: function getAccessToken() {
259
252
  throw new Error('DCR mode does not support getAccessToken - tokens are provided via bearer auth');
260
253
  },
261
- getUserEmail: function() {
254
+ getUserEmail: function getUserEmail() {
262
255
  throw new Error('DCR mode does not support getUserEmail - tokens are provided via bearer auth');
263
256
  }
264
257
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/Projects/mcp-z/mcp-drive/src/setup/oauth-google.ts"],"sourcesContent":["import { type AccountAuthProvider, AccountServer } from '@mcp-z/oauth';\nimport type { CachedToken } from '@mcp-z/oauth-google';\nimport { createDcrRouter, createLoopbackCallbackRouter, DcrOAuthProvider, LoopbackOAuthProvider, ServiceAccountProvider } from '@mcp-z/oauth-google';\nimport type { Logger, PromptModule, ToolModule } from '@mcp-z/server';\nimport type { Router } from 'express';\nimport type { Keyv } from 'keyv';\nimport { GOOGLE_SCOPE } from '../constants.ts';\nimport type { ServerConfig } from '../types.ts';\n\n/**\n * Drive OAuth runtime dependencies\n */\nexport interface OAuthRuntimeDeps {\n logger: Logger;\n tokenStore: Keyv<CachedToken>;\n dcrStore?: Keyv<unknown>;\n}\n\n/**\n * Auth middleware wrapper with withToolAuth/withResourceAuth/withPromptAuth methods\n * Uses structural constraints to avoid contravariance issues with handler types.\n */\nexport interface AuthMiddleware {\n withToolAuth<T extends { name: string; config: unknown; handler: unknown }>(module: T): T;\n withResourceAuth<T extends { name: string; template?: unknown; config?: unknown; handler: unknown }>(module: T): T;\n withPromptAuth<T extends { name: string; config: unknown; handler: unknown }>(module: T): T;\n}\n\n/**\n * Result of OAuth adapter creation\n */\nexport interface OAuthAdapters {\n primary: LoopbackOAuthProvider | ServiceAccountProvider | DcrOAuthProvider;\n middleware: AuthMiddleware;\n authAdapter: AccountAuthProvider;\n accountTools: ToolModule[];\n accountPrompts: PromptModule[];\n dcrRouter?: Router;\n loopbackRouter?: Router;\n}\n\n/**\n * Create Drive OAuth adapters based on transport configuration\n *\n * Returns primary adapter (loopback or service account), pre-configured middleware,\n * auth email provider, and pre-selected account tools based on auth mode.\n *\n * Primary adapter selection is based on auth mode:\n * - 'loopback-oauth': LoopbackOAuthProvider (interactive OAuth with token storage)\n * - 'service-account': ServiceAccountProvider (JWT-based authentication)\n *\n * @param config - Server configuration (transport + auth settings)\n * @param deps - Runtime dependencies (logger, tokenStore, etc.)\n * @returns OAuth adapters with pre-configured middleware and account tools\n * @throws Error if service account mode but no key file provided\n */\nexport async function createOAuthAdapters(config: ServerConfig, deps: OAuthRuntimeDeps, baseUrl?: string): Promise<OAuthAdapters> {\n const { logger, tokenStore, dcrStore } = deps;\n const resolvedBaseUrl = baseUrl ?? config.baseUrl;\n const oauthStaticConfig = {\n service: config.name,\n clientId: config.clientId,\n clientSecret: config.clientSecret,\n scope: GOOGLE_SCOPE,\n auth: config.auth,\n headless: config.headless,\n redirectUri: config.transport.type === 'stdio' ? undefined : config.redirectUri,\n ...(config.serviceAccountKeyFile && { serviceAccountKeyFile: config.serviceAccountKeyFile }),\n ...(resolvedBaseUrl && { baseUrl: resolvedBaseUrl }),\n };\n\n // Create primary adapter based on auth mode\n let primary: LoopbackOAuthProvider | ServiceAccountProvider | DcrOAuthProvider;\n\n // DCR mode - Dynamic Client Registration with HTTP-only support\n if (oauthStaticConfig.auth === 'dcr') {\n logger.debug('Creating DCR provider', { service: oauthStaticConfig.service });\n\n // DCR requires dcrStore and baseUrl\n if (!dcrStore) {\n throw new Error('DCR mode requires dcrStore to be configured');\n }\n if (!oauthStaticConfig.baseUrl) {\n throw new Error('DCR mode requires baseUrl to be configured');\n }\n\n // Create DcrOAuthProvider (stateless provider that receives tokens from verification context)\n primary = new DcrOAuthProvider({\n clientId: oauthStaticConfig.clientId,\n ...(oauthStaticConfig.clientSecret && { clientSecret: oauthStaticConfig.clientSecret }),\n scope: oauthStaticConfig.scope,\n verifyEndpoint: `${oauthStaticConfig.baseUrl}/oauth/verify`,\n logger,\n });\n\n // Create DCR OAuth router with authorization server endpoints\n const dcrRouter = createDcrRouter({\n store: dcrStore,\n issuerUrl: oauthStaticConfig.baseUrl,\n baseUrl: oauthStaticConfig.baseUrl,\n scopesSupported: oauthStaticConfig.scope.split(' '),\n clientConfig: {\n clientId: oauthStaticConfig.clientId,\n ...(oauthStaticConfig.clientSecret && { clientSecret: oauthStaticConfig.clientSecret }),\n },\n });\n\n // DCR uses bearer token authentication with middleware validation\n const middleware = primary.authMiddleware();\n\n // Create auth email provider (stateless)\n const authAdapter: AccountAuthProvider = {\n getAccessToken: () => {\n throw new Error('DCR mode does not support getAccessToken - tokens are provided via bearer auth');\n },\n getUserEmail: () => {\n throw new Error('DCR mode does not support getUserEmail - tokens are provided via bearer auth');\n },\n };\n\n // No account management tools for DCR\n const accountTools: ToolModule[] = [];\n const accountPrompts: PromptModule[] = [];\n\n return { primary, middleware: middleware as unknown as AuthMiddleware, authAdapter, accountTools, accountPrompts, dcrRouter };\n }\n\n if (config.auth === 'service-account') {\n // Service account mode - JWT-based authentication\n if (!oauthStaticConfig.serviceAccountKeyFile) {\n throw new Error('Service account key file is required when auth mode is \"service-account\". ' + 'Set GOOGLE_SERVICE_ACCOUNT_KEY_FILE environment variable or use --service-account-key-file flag.');\n }\n\n logger.debug('Creating service account provider', { service: oauthStaticConfig.service });\n primary = new ServiceAccountProvider({\n keyFilePath: oauthStaticConfig.serviceAccountKeyFile,\n scopes: oauthStaticConfig.scope.split(' '),\n logger,\n });\n } else {\n // Loopback mode - interactive OAuth with token storage\n logger.debug('Creating loopback OAuth provider', { service: oauthStaticConfig.service });\n primary = new LoopbackOAuthProvider({\n service: oauthStaticConfig.service,\n clientId: oauthStaticConfig.clientId,\n clientSecret: oauthStaticConfig.clientSecret,\n scope: oauthStaticConfig.scope,\n headless: oauthStaticConfig.headless,\n logger,\n tokenStore,\n ...(oauthStaticConfig.redirectUri !== undefined && {\n redirectUri: oauthStaticConfig.redirectUri,\n }),\n });\n }\n\n // Create auth email provider (used by account management tools)\n const authAdapter: AccountAuthProvider = primary;\n\n // Select middleware AND account tools based on auth mode\n let middleware: ReturnType<LoopbackOAuthProvider['authMiddleware']>;\n let accountTools: ToolModule[];\n let accountPrompts: PromptModule[];\n\n if (oauthStaticConfig.auth === 'service-account') {\n // Service account mode - no account management tools needed (single identity)\n middleware = primary.authMiddleware();\n accountTools = [];\n accountPrompts = [];\n logger.debug('Service account mode - no account tools', { service: oauthStaticConfig.service });\n } else {\n // Loopback OAuth - multi-account mode\n middleware = primary.authMiddleware();\n\n const result = AccountServer.createLoopback({\n service: oauthStaticConfig.service,\n store: tokenStore,\n logger,\n auth: authAdapter,\n });\n accountTools = result.tools as ToolModule[];\n accountPrompts = result.prompts as PromptModule[];\n logger.debug('Loopback OAuth (multi-account mode)', { service: oauthStaticConfig.service });\n }\n\n const loopbackRouter = primary instanceof LoopbackOAuthProvider && oauthStaticConfig.redirectUri ? createLoopbackCallbackRouter(primary) : undefined;\n\n return { primary, middleware: middleware as unknown as AuthMiddleware, authAdapter, accountTools, accountPrompts, loopbackRouter };\n}\n"],"names":["createOAuthAdapters","config","deps","baseUrl","logger","tokenStore","dcrStore","resolvedBaseUrl","oauthStaticConfig","primary","dcrRouter","middleware","authAdapter","accountTools","accountPrompts","result","loopbackRouter","service","name","clientId","clientSecret","scope","GOOGLE_SCOPE","auth","headless","redirectUri","transport","type","undefined","serviceAccountKeyFile","debug","Error","DcrOAuthProvider","verifyEndpoint","createDcrRouter","store","issuerUrl","scopesSupported","split","clientConfig","authMiddleware","getAccessToken","getUserEmail","ServiceAccountProvider","keyFilePath","scopes","LoopbackOAuthProvider","AccountServer","createLoopback","tools","prompts","createLoopbackCallbackRouter"],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oBAASE,YAAYA;oBAAyCC,aAAAA;oBAAaC,cAAAA;oBAAcC,gBAAAA;oBAAgBE,gBAAAA;gBAAe;;;IACnI"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-drive/src/setup/oauth-google.ts"],"sourcesContent":["import { type AccountAuthProvider, AccountServer } from '@mcp-z/oauth';\nimport type { CachedToken } from '@mcp-z/oauth-google';\nimport { createDcrRouter, createLoopbackCallbackRouter, DcrOAuthProvider, LoopbackOAuthProvider, ServiceAccountProvider } from '@mcp-z/oauth-google';\nimport type { Logger, PromptModule, ToolModule } from '@mcp-z/server';\nimport type { Router } from 'express';\nimport type { Keyv } from 'keyv';\nimport { GOOGLE_SCOPE } from '../constants.ts';\nimport type { ServerConfig } from '../types.ts';\n\n/**\n * Drive OAuth runtime dependencies\n */\nexport interface OAuthRuntimeDeps {\n logger: Logger;\n tokenStore: Keyv<CachedToken>;\n dcrStore?: Keyv<unknown>;\n}\n\n/**\n * Auth middleware wrapper with withToolAuth/withResourceAuth/withPromptAuth methods\n * Uses structural constraints to avoid contravariance issues with handler types.\n */\nexport interface AuthMiddleware {\n withToolAuth<T extends { name: string; config: unknown; handler: unknown }>(module: T): T;\n withResourceAuth<T extends { name: string; template?: unknown; config?: unknown; handler: unknown }>(module: T): T;\n withPromptAuth<T extends { name: string; config: unknown; handler: unknown }>(module: T): T;\n}\n\n/**\n * Result of OAuth adapter creation\n */\nexport interface OAuthAdapters {\n primary: LoopbackOAuthProvider | ServiceAccountProvider | DcrOAuthProvider;\n middleware: AuthMiddleware;\n authAdapter: AccountAuthProvider;\n accountTools: ToolModule[];\n accountPrompts: PromptModule[];\n dcrRouter?: Router;\n loopbackRouter?: Router;\n}\n\n/**\n * Create Drive OAuth adapters based on transport configuration\n *\n * Returns primary adapter (loopback or service account), pre-configured middleware,\n * auth email provider, and pre-selected account tools based on auth mode.\n *\n * Primary adapter selection is based on auth mode:\n * - 'loopback-oauth': LoopbackOAuthProvider (interactive OAuth with token storage)\n * - 'service-account': ServiceAccountProvider (JWT-based authentication)\n *\n * @param config - Server configuration (transport + auth settings)\n * @param deps - Runtime dependencies (logger, tokenStore, etc.)\n * @returns OAuth adapters with pre-configured middleware and account tools\n * @throws Error if service account mode but no key file provided\n */\nexport async function createOAuthAdapters(config: ServerConfig, deps: OAuthRuntimeDeps, baseUrl?: string): Promise<OAuthAdapters> {\n const { logger, tokenStore, dcrStore } = deps;\n const resolvedBaseUrl = baseUrl ?? config.baseUrl;\n const oauthStaticConfig = {\n service: config.name,\n clientId: config.clientId,\n clientSecret: config.clientSecret,\n scope: GOOGLE_SCOPE,\n auth: config.auth,\n headless: config.headless,\n redirectUri: config.transport.type === 'stdio' ? undefined : config.redirectUri,\n ...(config.serviceAccountKeyFile && { serviceAccountKeyFile: config.serviceAccountKeyFile }),\n ...(resolvedBaseUrl && { baseUrl: resolvedBaseUrl }),\n };\n\n // Create primary adapter based on auth mode\n let primary: LoopbackOAuthProvider | ServiceAccountProvider | DcrOAuthProvider;\n\n // DCR mode - Dynamic Client Registration with HTTP-only support\n if (oauthStaticConfig.auth === 'dcr') {\n logger.debug('Creating DCR provider', { service: oauthStaticConfig.service });\n\n // DCR requires dcrStore and baseUrl\n if (!dcrStore) {\n throw new Error('DCR mode requires dcrStore to be configured');\n }\n if (!oauthStaticConfig.baseUrl) {\n throw new Error('DCR mode requires baseUrl to be configured');\n }\n\n // Create DcrOAuthProvider (stateless provider that receives tokens from verification context)\n primary = new DcrOAuthProvider({\n clientId: oauthStaticConfig.clientId,\n ...(oauthStaticConfig.clientSecret && { clientSecret: oauthStaticConfig.clientSecret }),\n scope: oauthStaticConfig.scope,\n verifyEndpoint: `${oauthStaticConfig.baseUrl}/oauth/verify`,\n logger,\n });\n\n // Create DCR OAuth router with authorization server endpoints\n const dcrRouter = createDcrRouter({\n store: dcrStore,\n issuerUrl: oauthStaticConfig.baseUrl,\n baseUrl: oauthStaticConfig.baseUrl,\n scopesSupported: oauthStaticConfig.scope.split(' '),\n clientConfig: {\n clientId: oauthStaticConfig.clientId,\n ...(oauthStaticConfig.clientSecret && { clientSecret: oauthStaticConfig.clientSecret }),\n },\n });\n\n // DCR uses bearer token authentication with middleware validation\n const middleware = primary.authMiddleware();\n\n // Create auth email provider (stateless)\n const authAdapter: AccountAuthProvider = {\n getAccessToken: () => {\n throw new Error('DCR mode does not support getAccessToken - tokens are provided via bearer auth');\n },\n getUserEmail: () => {\n throw new Error('DCR mode does not support getUserEmail - tokens are provided via bearer auth');\n },\n };\n\n // No account management tools for DCR\n const accountTools: ToolModule[] = [];\n const accountPrompts: PromptModule[] = [];\n\n return { primary, middleware: middleware as unknown as AuthMiddleware, authAdapter, accountTools, accountPrompts, dcrRouter };\n }\n\n if (config.auth === 'service-account') {\n // Service account mode - JWT-based authentication\n if (!oauthStaticConfig.serviceAccountKeyFile) {\n throw new Error('Service account key file is required when auth mode is \"service-account\". ' + 'Set GOOGLE_SERVICE_ACCOUNT_KEY_FILE environment variable or use --service-account-key-file flag.');\n }\n\n logger.debug('Creating service account provider', { service: oauthStaticConfig.service });\n primary = new ServiceAccountProvider({\n keyFilePath: oauthStaticConfig.serviceAccountKeyFile,\n scopes: oauthStaticConfig.scope.split(' '),\n logger,\n });\n } else {\n // Loopback mode - interactive OAuth with token storage\n logger.debug('Creating loopback OAuth provider', { service: oauthStaticConfig.service });\n primary = new LoopbackOAuthProvider({\n service: oauthStaticConfig.service,\n clientId: oauthStaticConfig.clientId,\n clientSecret: oauthStaticConfig.clientSecret,\n scope: oauthStaticConfig.scope,\n headless: oauthStaticConfig.headless,\n logger,\n tokenStore,\n ...(oauthStaticConfig.redirectUri !== undefined && {\n redirectUri: oauthStaticConfig.redirectUri,\n }),\n });\n }\n\n // Create auth email provider (used by account management tools)\n const authAdapter: AccountAuthProvider = primary;\n\n // Select middleware AND account tools based on auth mode\n let middleware: ReturnType<LoopbackOAuthProvider['authMiddleware']>;\n let accountTools: ToolModule[];\n let accountPrompts: PromptModule[];\n\n if (oauthStaticConfig.auth === 'service-account') {\n // Service account mode - no account management tools needed (single identity)\n middleware = primary.authMiddleware();\n accountTools = [];\n accountPrompts = [];\n logger.debug('Service account mode - no account tools', { service: oauthStaticConfig.service });\n } else {\n // Loopback OAuth - multi-account mode\n middleware = primary.authMiddleware();\n\n const result = AccountServer.createLoopback({\n service: oauthStaticConfig.service,\n store: tokenStore,\n logger,\n auth: authAdapter,\n });\n accountTools = result.tools as ToolModule[];\n accountPrompts = result.prompts as PromptModule[];\n logger.debug('Loopback OAuth (multi-account mode)', { service: oauthStaticConfig.service });\n }\n\n const loopbackRouter = primary instanceof LoopbackOAuthProvider && oauthStaticConfig.redirectUri ? createLoopbackCallbackRouter(primary) : undefined;\n\n return { primary, middleware: middleware as unknown as AuthMiddleware, authAdapter, accountTools, accountPrompts, loopbackRouter };\n}\n"],"names":["createOAuthAdapters","config","deps","baseUrl","logger","tokenStore","dcrStore","resolvedBaseUrl","oauthStaticConfig","primary","dcrRouter","middleware","authAdapter","accountTools","accountPrompts","result","loopbackRouter","service","name","clientId","clientSecret","scope","GOOGLE_SCOPE","auth","headless","redirectUri","transport","type","undefined","serviceAccountKeyFile","debug","Error","DcrOAuthProvider","verifyEndpoint","createDcrRouter","store","issuerUrl","scopesSupported","split","clientConfig","authMiddleware","getAccessToken","getUserEmail","ServiceAccountProvider","keyFilePath","scopes","LoopbackOAuthProvider","AccountServer","createLoopback","tools","prompts","createLoopbackCallbackRouter"],"mappings":";;;;+BAwDsBA;;;eAAAA;;;qBAxDkC;2BAEuE;2BAIlG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDtB,SAAeA,oBAAoBC,MAAoB,EAAEC,IAAsB,EAAEC,OAA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cZ,kBAAkBY,YAAY;oBAC5CC,OAAOb,kBAAkBa,KAAK;oBAC9BG,UAAUhB,kBAAkBgB,QAAQ;oBACpCpB,QAAAA;oBACAC,YAAAA;mBACIG,kBAAkBiB,WAAW,KAAKG,aAAa;oBACjDH,aAAajB,kBAAkBiB,WAAW;gBAC5C;YAEJ;YAEA,gEAAgE;YAC1Db,eAAmCH;YAOzC,IAAID,kBAAkBe,IAAI,KAAK,mBAAmB;gBAChD,8EAA8E;gBAC9EZ,cAAaF,QAAQ+B,cAAc;gBACnC3B;gBACAC;gBACAV,OAAO0B,KAAK,CAAC,2CAA2C;oBAAEb,SAAST,kBAAkBS,OAAO;gBAAC;YAC/F,OAAO;gBACL,sCAAsC;gBACtCN,cAAaF,QAAQ+B,cAAc;gBAE7BzB,SAASgC,oBAAa,CAACC,cAAc,CAAC;oBAC1C/B,SAAST,kBAAkBS,OAAO;oBAClCkB,OAAO9B;oBACPD,QAAAA;oBACAmB,MAAMX;gBACR;gBACAC,gBAAeE,OAAOkC,KAAK;gBAC3BnC,kBAAiBC,OAAOmC,OAAO;gBAC/B9C,OAAO0B,KAAK,CAAC,uCAAuC;oBAAEb,SAAST,kBAAkBS,OAAO;gBAAC;YAC3F;YAEMD,iBAAiBP,AAAO,YAAPA,SAAmBqC,kCAAqB,KAAItC,kBAAkBiB,WAAW,GAAG0B,IAAAA,yCAA4B,EAAC1C,WAAWmB;YAE3I;;gBAAO;oBAAEnB,SAAAA;oBAASE,YAAYA;oBAAyCC,aAAAA;oBAAaC,cAAAA;oBAAcC,gBAAAA;oBAAgBE,gBAAAA;gBAAe;;;IACnI"}
@@ -4,7 +4,7 @@ import type { CommonRuntime, RuntimeOverrides, ServerConfig } from '../types.js'
4
4
  import { type AuthMiddleware } from './oauth-google.js';
5
5
  export declare function createLogger(config: ServerConfig): Logger;
6
6
  export declare function createTokenStore(baseDir: string): Promise<import("keyv").Keyv<CachedToken>>;
7
- export declare function createDcrStore(baseDir: string, required: boolean): Promise<import("keyv").Keyv<unknown>>;
7
+ export declare function createDcrStore(baseDir: string, required: boolean): Promise<import("keyv").Keyv<unknown> | undefined>;
8
8
  export declare function createAuthLayer(authMiddleware: AuthMiddleware): MiddlewareLayer;
9
9
  export declare function createLoggingLayer(logger: Logger): MiddlewareLayer;
10
10
  export declare function createDefaultRuntime(config: ServerConfig, overrides?: RuntimeOverrides): Promise<CommonRuntime>;