@mcp-z/mcp-drive 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +163 -0
- package/bin/server.js +5 -0
- package/dist/cjs/constants.d.cts +7 -0
- package/dist/cjs/constants.d.ts +7 -0
- package/dist/cjs/constants.js +18 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.d.cts +8 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.js +314 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/create-store.d.cts +2 -0
- package/dist/cjs/lib/create-store.d.ts +2 -0
- package/dist/cjs/lib/create-store.js +166 -0
- package/dist/cjs/lib/create-store.js.map +1 -0
- package/dist/cjs/lib/query-builder.d.cts +45 -0
- package/dist/cjs/lib/query-builder.d.ts +45 -0
- package/dist/cjs/lib/query-builder.js +219 -0
- package/dist/cjs/lib/query-builder.js.map +1 -0
- package/dist/cjs/mcp/index.d.cts +3 -0
- package/dist/cjs/mcp/index.d.ts +3 -0
- package/dist/cjs/mcp/index.js +66 -0
- package/dist/cjs/mcp/index.js.map +1 -0
- package/dist/cjs/mcp/prompts/index.d.cts +2 -0
- package/dist/cjs/mcp/prompts/index.d.ts +2 -0
- package/dist/cjs/mcp/prompts/index.js +26 -0
- package/dist/cjs/mcp/prompts/index.js.map +1 -0
- package/dist/cjs/mcp/prompts/organize-files.d.cts +16 -0
- package/dist/cjs/mcp/prompts/organize-files.d.ts +16 -0
- package/dist/cjs/mcp/prompts/organize-files.js +169 -0
- package/dist/cjs/mcp/prompts/organize-files.js.map +1 -0
- package/dist/cjs/mcp/prompts/query-syntax.d.cts +19 -0
- package/dist/cjs/mcp/prompts/query-syntax.d.ts +19 -0
- package/dist/cjs/mcp/prompts/query-syntax.js +169 -0
- package/dist/cjs/mcp/prompts/query-syntax.js.map +1 -0
- package/dist/cjs/mcp/resources/file.d.cts +9 -0
- package/dist/cjs/mcp/resources/file.d.ts +9 -0
- package/dist/cjs/mcp/resources/file.js +247 -0
- package/dist/cjs/mcp/resources/file.js.map +1 -0
- package/dist/cjs/mcp/resources/index.d.cts +1 -0
- package/dist/cjs/mcp/resources/index.d.ts +1 -0
- package/dist/cjs/mcp/resources/index.js +17 -0
- package/dist/cjs/mcp/resources/index.js.map +1 -0
- package/dist/cjs/mcp/tools/file-move-to-trash.d.cts +59 -0
- package/dist/cjs/mcp/tools/file-move-to-trash.d.ts +59 -0
- package/dist/cjs/mcp/tools/file-move-to-trash.js +334 -0
- package/dist/cjs/mcp/tools/file-move-to-trash.js.map +1 -0
- package/dist/cjs/mcp/tools/file-move.d.cts +73 -0
- package/dist/cjs/mcp/tools/file-move.d.ts +73 -0
- package/dist/cjs/mcp/tools/file-move.js +613 -0
- package/dist/cjs/mcp/tools/file-move.js.map +1 -0
- package/dist/cjs/mcp/tools/files-search.d.cts +135 -0
- package/dist/cjs/mcp/tools/files-search.d.ts +135 -0
- package/dist/cjs/mcp/tools/files-search.js +558 -0
- package/dist/cjs/mcp/tools/files-search.js.map +1 -0
- package/dist/cjs/mcp/tools/folder-contents.d.cts +139 -0
- package/dist/cjs/mcp/tools/folder-contents.d.ts +139 -0
- package/dist/cjs/mcp/tools/folder-contents.js +513 -0
- package/dist/cjs/mcp/tools/folder-contents.js.map +1 -0
- package/dist/cjs/mcp/tools/folder-create.d.cts +59 -0
- package/dist/cjs/mcp/tools/folder-create.d.ts +59 -0
- package/dist/cjs/mcp/tools/folder-create.js +368 -0
- package/dist/cjs/mcp/tools/folder-create.js.map +1 -0
- package/dist/cjs/mcp/tools/folder-path.d.cts +49 -0
- package/dist/cjs/mcp/tools/folder-path.d.ts +49 -0
- package/dist/cjs/mcp/tools/folder-path.js +367 -0
- package/dist/cjs/mcp/tools/folder-path.js.map +1 -0
- package/dist/cjs/mcp/tools/folder-search.d.cts +139 -0
- package/dist/cjs/mcp/tools/folder-search.d.ts +139 -0
- package/dist/cjs/mcp/tools/folder-search.js +760 -0
- package/dist/cjs/mcp/tools/folder-search.js.map +1 -0
- package/dist/cjs/mcp/tools/index.d.cts +7 -0
- package/dist/cjs/mcp/tools/index.d.ts +7 -0
- package/dist/cjs/mcp/tools/index.js +46 -0
- package/dist/cjs/mcp/tools/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/schemas/drive-query-schema.d.cts +40 -0
- package/dist/cjs/schemas/drive-query-schema.d.ts +40 -0
- package/dist/cjs/schemas/drive-query-schema.js +90 -0
- package/dist/cjs/schemas/drive-query-schema.js.map +1 -0
- package/dist/cjs/schemas/drive-validation.d.cts +48 -0
- package/dist/cjs/schemas/drive-validation.d.ts +48 -0
- package/dist/cjs/schemas/drive-validation.js +96 -0
- package/dist/cjs/schemas/drive-validation.js.map +1 -0
- package/dist/cjs/schemas/index.d.cts +2 -0
- package/dist/cjs/schemas/index.d.ts +2 -0
- package/dist/cjs/schemas/index.js +20 -0
- package/dist/cjs/schemas/index.js.map +1 -0
- package/dist/cjs/setup/config.d.cts +44 -0
- package/dist/cjs/setup/config.d.ts +44 -0
- package/dist/cjs/setup/config.js +201 -0
- package/dist/cjs/setup/config.js.map +1 -0
- package/dist/cjs/setup/http.d.cts +8 -0
- package/dist/cjs/setup/http.d.ts +8 -0
- package/dist/cjs/setup/http.js +260 -0
- package/dist/cjs/setup/http.js.map +1 -0
- package/dist/cjs/setup/index.d.cts +5 -0
- package/dist/cjs/setup/index.d.ts +5 -0
- package/dist/cjs/setup/index.js +46 -0
- package/dist/cjs/setup/index.js.map +1 -0
- package/dist/cjs/setup/oauth-google.d.cts +64 -0
- package/dist/cjs/setup/oauth-google.d.ts +64 -0
- package/dist/cjs/setup/oauth-google.js +347 -0
- package/dist/cjs/setup/oauth-google.js.map +1 -0
- package/dist/cjs/setup/runtime.d.cts +10 -0
- package/dist/cjs/setup/runtime.d.ts +10 -0
- package/dist/cjs/setup/runtime.js +353 -0
- package/dist/cjs/setup/runtime.js.map +1 -0
- package/dist/cjs/setup/stdio.d.cts +7 -0
- package/dist/cjs/setup/stdio.d.ts +7 -0
- package/dist/cjs/setup/stdio.js +239 -0
- package/dist/cjs/setup/stdio.js.map +1 -0
- package/dist/cjs/types.d.cts +45 -0
- package/dist/cjs/types.d.ts +45 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/constants.d.ts +7 -0
- package/dist/esm/constants.js +7 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +34 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/create-store.d.ts +2 -0
- package/dist/esm/lib/create-store.js +6 -0
- package/dist/esm/lib/create-store.js.map +1 -0
- package/dist/esm/lib/query-builder.d.ts +45 -0
- package/dist/esm/lib/query-builder.js +184 -0
- package/dist/esm/lib/query-builder.js.map +1 -0
- package/dist/esm/mcp/index.d.ts +3 -0
- package/dist/esm/mcp/index.js +6 -0
- package/dist/esm/mcp/index.js.map +1 -0
- package/dist/esm/mcp/prompts/index.d.ts +2 -0
- package/dist/esm/mcp/prompts/index.js +2 -0
- package/dist/esm/mcp/prompts/index.js.map +1 -0
- package/dist/esm/mcp/prompts/organize-files.d.ts +16 -0
- package/dist/esm/mcp/prompts/organize-files.js +21 -0
- package/dist/esm/mcp/prompts/organize-files.js.map +1 -0
- package/dist/esm/mcp/prompts/query-syntax.d.ts +19 -0
- package/dist/esm/mcp/prompts/query-syntax.js +82 -0
- package/dist/esm/mcp/prompts/query-syntax.js.map +1 -0
- package/dist/esm/mcp/resources/file.d.ts +9 -0
- package/dist/esm/mcp/resources/file.js +77 -0
- package/dist/esm/mcp/resources/file.js.map +1 -0
- package/dist/esm/mcp/resources/index.d.ts +1 -0
- package/dist/esm/mcp/resources/index.js +1 -0
- package/dist/esm/mcp/resources/index.js.map +1 -0
- package/dist/esm/mcp/tools/file-move-to-trash.d.ts +59 -0
- package/dist/esm/mcp/tools/file-move-to-trash.js +118 -0
- package/dist/esm/mcp/tools/file-move-to-trash.js.map +1 -0
- package/dist/esm/mcp/tools/file-move.d.ts +73 -0
- package/dist/esm/mcp/tools/file-move.js +274 -0
- package/dist/esm/mcp/tools/file-move.js.map +1 -0
- package/dist/esm/mcp/tools/files-search.d.ts +135 -0
- package/dist/esm/mcp/tools/files-search.js +254 -0
- package/dist/esm/mcp/tools/files-search.js.map +1 -0
- package/dist/esm/mcp/tools/folder-contents.d.ts +139 -0
- package/dist/esm/mcp/tools/folder-contents.js +214 -0
- package/dist/esm/mcp/tools/folder-contents.js.map +1 -0
- package/dist/esm/mcp/tools/folder-create.d.ts +59 -0
- package/dist/esm/mcp/tools/folder-create.js +140 -0
- package/dist/esm/mcp/tools/folder-create.js.map +1 -0
- package/dist/esm/mcp/tools/folder-path.d.ts +49 -0
- package/dist/esm/mcp/tools/folder-path.js +147 -0
- package/dist/esm/mcp/tools/folder-path.js.map +1 -0
- package/dist/esm/mcp/tools/folder-search.d.ts +139 -0
- package/dist/esm/mcp/tools/folder-search.js +343 -0
- package/dist/esm/mcp/tools/folder-search.js.map +1 -0
- package/dist/esm/mcp/tools/index.d.ts +7 -0
- package/dist/esm/mcp/tools/index.js +7 -0
- package/dist/esm/mcp/tools/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/schemas/drive-query-schema.d.ts +40 -0
- package/dist/esm/schemas/drive-query-schema.js +84 -0
- package/dist/esm/schemas/drive-query-schema.js.map +1 -0
- package/dist/esm/schemas/drive-validation.d.ts +48 -0
- package/dist/esm/schemas/drive-validation.js +73 -0
- package/dist/esm/schemas/drive-validation.js.map +1 -0
- package/dist/esm/schemas/index.d.ts +2 -0
- package/dist/esm/schemas/index.js +2 -0
- package/dist/esm/schemas/index.js.map +1 -0
- package/dist/esm/setup/config.d.ts +44 -0
- package/dist/esm/setup/config.js +151 -0
- package/dist/esm/setup/config.js.map +1 -0
- package/dist/esm/setup/http.d.ts +8 -0
- package/dist/esm/setup/http.js +54 -0
- package/dist/esm/setup/http.js.map +1 -0
- package/dist/esm/setup/index.d.ts +5 -0
- package/dist/esm/setup/index.js +5 -0
- package/dist/esm/setup/index.js.map +1 -0
- package/dist/esm/setup/oauth-google.d.ts +64 -0
- package/dist/esm/setup/oauth-google.js +168 -0
- package/dist/esm/setup/oauth-google.js.map +1 -0
- package/dist/esm/setup/runtime.d.ts +10 -0
- package/dist/esm/setup/runtime.js +84 -0
- package/dist/esm/setup/runtime.js.map +1 -0
- package/dist/esm/setup/stdio.d.ts +7 -0
- package/dist/esm/setup/stdio.js +38 -0
- package/dist/esm/setup/stdio.js.map +1 -0
- package/dist/esm/types.d.ts +45 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +108 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return createTool;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _oauthgoogle = require("@mcp-z/oauth-google");
|
|
12
|
+
var _types = require("@modelcontextprotocol/sdk/types.js");
|
|
13
|
+
var _googleapis = require("googleapis");
|
|
14
|
+
var _zod = require("zod");
|
|
15
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
16
|
+
try {
|
|
17
|
+
var info = gen[key](arg);
|
|
18
|
+
var value = info.value;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
reject(error);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (info.done) {
|
|
24
|
+
resolve(value);
|
|
25
|
+
} else {
|
|
26
|
+
Promise.resolve(value).then(_next, _throw);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function _async_to_generator(fn) {
|
|
30
|
+
return function() {
|
|
31
|
+
var self = this, args = arguments;
|
|
32
|
+
return new Promise(function(resolve, reject) {
|
|
33
|
+
var gen = fn.apply(self, args);
|
|
34
|
+
function _next(value) {
|
|
35
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
36
|
+
}
|
|
37
|
+
function _throw(err) {
|
|
38
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
39
|
+
}
|
|
40
|
+
_next(undefined);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function _instanceof(left, right) {
|
|
45
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
46
|
+
return !!right[Symbol.hasInstance](left);
|
|
47
|
+
} else {
|
|
48
|
+
return left instanceof right;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function _ts_generator(thisArg, body) {
|
|
52
|
+
var f, y, t, _ = {
|
|
53
|
+
label: 0,
|
|
54
|
+
sent: function() {
|
|
55
|
+
if (t[0] & 1) throw t[1];
|
|
56
|
+
return t[1];
|
|
57
|
+
},
|
|
58
|
+
trys: [],
|
|
59
|
+
ops: []
|
|
60
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
61
|
+
return d(g, "next", {
|
|
62
|
+
value: verb(0)
|
|
63
|
+
}), d(g, "throw", {
|
|
64
|
+
value: verb(1)
|
|
65
|
+
}), d(g, "return", {
|
|
66
|
+
value: verb(2)
|
|
67
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
68
|
+
value: function() {
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
}), g;
|
|
72
|
+
function verb(n) {
|
|
73
|
+
return function(v) {
|
|
74
|
+
return step([
|
|
75
|
+
n,
|
|
76
|
+
v
|
|
77
|
+
]);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function step(op) {
|
|
81
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
82
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
83
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
84
|
+
if (y = 0, t) op = [
|
|
85
|
+
op[0] & 2,
|
|
86
|
+
t.value
|
|
87
|
+
];
|
|
88
|
+
switch(op[0]){
|
|
89
|
+
case 0:
|
|
90
|
+
case 1:
|
|
91
|
+
t = op;
|
|
92
|
+
break;
|
|
93
|
+
case 4:
|
|
94
|
+
_.label++;
|
|
95
|
+
return {
|
|
96
|
+
value: op[1],
|
|
97
|
+
done: false
|
|
98
|
+
};
|
|
99
|
+
case 5:
|
|
100
|
+
_.label++;
|
|
101
|
+
y = op[1];
|
|
102
|
+
op = [
|
|
103
|
+
0
|
|
104
|
+
];
|
|
105
|
+
continue;
|
|
106
|
+
case 7:
|
|
107
|
+
op = _.ops.pop();
|
|
108
|
+
_.trys.pop();
|
|
109
|
+
continue;
|
|
110
|
+
default:
|
|
111
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
112
|
+
_ = 0;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
116
|
+
_.label = op[1];
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
120
|
+
_.label = t[1];
|
|
121
|
+
t = op;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
if (t && _.label < t[2]) {
|
|
125
|
+
_.label = t[2];
|
|
126
|
+
_.ops.push(op);
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
if (t[2]) _.ops.pop();
|
|
130
|
+
_.trys.pop();
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
op = body.call(thisArg, _);
|
|
134
|
+
} catch (e) {
|
|
135
|
+
op = [
|
|
136
|
+
6,
|
|
137
|
+
e
|
|
138
|
+
];
|
|
139
|
+
y = 0;
|
|
140
|
+
} finally{
|
|
141
|
+
f = t = 0;
|
|
142
|
+
}
|
|
143
|
+
if (op[0] & 5) throw op[1];
|
|
144
|
+
return {
|
|
145
|
+
value: op[0] ? op[1] : void 0,
|
|
146
|
+
done: true
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
var AuthRequiredBranchSchema = _oauthgoogle.schemas.AuthRequiredBranchSchema;
|
|
151
|
+
var inputSchema = _zod.z.object({
|
|
152
|
+
folderId: _zod.z.string().min(1).describe('Folder ID to get path for (or "root")')
|
|
153
|
+
});
|
|
154
|
+
// Success branch schema - uses items: for consistency with standard vocabulary
|
|
155
|
+
var successBranchSchema = _zod.z.object({
|
|
156
|
+
type: _zod.z.literal('success'),
|
|
157
|
+
path: _zod.z.string().describe('Full path from root (e.g., /Work/Projects/2024)'),
|
|
158
|
+
items: _zod.z.array(_zod.z.object({
|
|
159
|
+
id: _zod.z.string().describe('Folder ID'),
|
|
160
|
+
name: _zod.z.string().describe('Folder name')
|
|
161
|
+
})).describe('Path items from root to target folder')
|
|
162
|
+
});
|
|
163
|
+
// Output schema with auth_required support
|
|
164
|
+
var outputSchema = _zod.z.discriminatedUnion('type', [
|
|
165
|
+
successBranchSchema,
|
|
166
|
+
AuthRequiredBranchSchema
|
|
167
|
+
]);
|
|
168
|
+
var config = {
|
|
169
|
+
title: 'Get Folder Path',
|
|
170
|
+
description: 'Get full path from folder to root. Returns human-readable path and items with IDs.',
|
|
171
|
+
inputSchema: inputSchema,
|
|
172
|
+
outputSchema: _zod.z.object({
|
|
173
|
+
result: outputSchema
|
|
174
|
+
})
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Resolves the full path for a folder by walking up the parent chain.
|
|
178
|
+
* Returns both the path string and structured segments with IDs and names.
|
|
179
|
+
*/ function resolveFolderPath(drive, folderId, logger) {
|
|
180
|
+
return _async_to_generator(function() {
|
|
181
|
+
var segments, currentId, visited, response, id, name, parents, e, pathParts, path;
|
|
182
|
+
return _ts_generator(this, function(_state) {
|
|
183
|
+
switch(_state.label){
|
|
184
|
+
case 0:
|
|
185
|
+
// Handle root specially
|
|
186
|
+
if (folderId === 'root') {
|
|
187
|
+
return [
|
|
188
|
+
2,
|
|
189
|
+
{
|
|
190
|
+
path: '/',
|
|
191
|
+
segments: [
|
|
192
|
+
{
|
|
193
|
+
id: 'root',
|
|
194
|
+
name: 'My Drive'
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
segments = [];
|
|
201
|
+
currentId = folderId;
|
|
202
|
+
visited = new Set();
|
|
203
|
+
_state.label = 1;
|
|
204
|
+
case 1:
|
|
205
|
+
if (!(currentId && currentId !== 'root')) return [
|
|
206
|
+
3,
|
|
207
|
+
6
|
|
208
|
+
];
|
|
209
|
+
// Prevent infinite loops
|
|
210
|
+
if (visited.has(currentId)) {
|
|
211
|
+
logger.info('Circular folder reference detected', {
|
|
212
|
+
folderId: currentId
|
|
213
|
+
});
|
|
214
|
+
return [
|
|
215
|
+
3,
|
|
216
|
+
6
|
|
217
|
+
];
|
|
218
|
+
}
|
|
219
|
+
visited.add(currentId);
|
|
220
|
+
_state.label = 2;
|
|
221
|
+
case 2:
|
|
222
|
+
_state.trys.push([
|
|
223
|
+
2,
|
|
224
|
+
4,
|
|
225
|
+
,
|
|
226
|
+
5
|
|
227
|
+
]);
|
|
228
|
+
return [
|
|
229
|
+
4,
|
|
230
|
+
drive.files.get({
|
|
231
|
+
fileId: currentId,
|
|
232
|
+
fields: 'id,name,parents'
|
|
233
|
+
})
|
|
234
|
+
];
|
|
235
|
+
case 3:
|
|
236
|
+
response = _state.sent();
|
|
237
|
+
id = response.data.id;
|
|
238
|
+
name = response.data.name || id;
|
|
239
|
+
parents = response.data.parents;
|
|
240
|
+
// Add to segments at beginning (we're walking from child to root)
|
|
241
|
+
segments.unshift({
|
|
242
|
+
id: id,
|
|
243
|
+
name: name
|
|
244
|
+
});
|
|
245
|
+
// Move to parent
|
|
246
|
+
currentId = (parents && parents.length > 0 ? parents[0] : '') || '';
|
|
247
|
+
return [
|
|
248
|
+
3,
|
|
249
|
+
5
|
|
250
|
+
];
|
|
251
|
+
case 4:
|
|
252
|
+
e = _state.sent();
|
|
253
|
+
logger.info('Failed to resolve folder path', {
|
|
254
|
+
folderId: currentId,
|
|
255
|
+
error: e
|
|
256
|
+
});
|
|
257
|
+
return [
|
|
258
|
+
3,
|
|
259
|
+
6
|
|
260
|
+
];
|
|
261
|
+
case 5:
|
|
262
|
+
return [
|
|
263
|
+
3,
|
|
264
|
+
1
|
|
265
|
+
];
|
|
266
|
+
case 6:
|
|
267
|
+
// Add root if we reached it
|
|
268
|
+
if (currentId === 'root') {
|
|
269
|
+
segments.unshift({
|
|
270
|
+
id: 'root',
|
|
271
|
+
name: 'My Drive'
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
// Build path string
|
|
275
|
+
pathParts = segments.slice(1).map(function(seg) {
|
|
276
|
+
return seg.name;
|
|
277
|
+
}); // Skip root
|
|
278
|
+
path = pathParts.length > 0 ? "/".concat(pathParts.join('/')) : '/';
|
|
279
|
+
return [
|
|
280
|
+
2,
|
|
281
|
+
{
|
|
282
|
+
path: path,
|
|
283
|
+
segments: segments
|
|
284
|
+
}
|
|
285
|
+
];
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
})();
|
|
289
|
+
}
|
|
290
|
+
function handler(_0, _1) {
|
|
291
|
+
return _async_to_generator(function(param, extra) {
|
|
292
|
+
var folderId, logger, drive, pathResult, result, error, message;
|
|
293
|
+
return _ts_generator(this, function(_state) {
|
|
294
|
+
switch(_state.label){
|
|
295
|
+
case 0:
|
|
296
|
+
folderId = param.folderId;
|
|
297
|
+
logger = extra.logger;
|
|
298
|
+
logger.info('drive.folder.path called', {
|
|
299
|
+
folderId: folderId
|
|
300
|
+
});
|
|
301
|
+
_state.label = 1;
|
|
302
|
+
case 1:
|
|
303
|
+
_state.trys.push([
|
|
304
|
+
1,
|
|
305
|
+
3,
|
|
306
|
+
,
|
|
307
|
+
4
|
|
308
|
+
]);
|
|
309
|
+
drive = _googleapis.google.drive({
|
|
310
|
+
version: 'v3',
|
|
311
|
+
auth: extra.authContext.auth
|
|
312
|
+
});
|
|
313
|
+
return [
|
|
314
|
+
4,
|
|
315
|
+
resolveFolderPath(drive, folderId, logger)
|
|
316
|
+
];
|
|
317
|
+
case 2:
|
|
318
|
+
pathResult = _state.sent();
|
|
319
|
+
logger.info('drive.folder.path returning', {
|
|
320
|
+
path: pathResult.path,
|
|
321
|
+
segmentCount: pathResult.segments.length
|
|
322
|
+
});
|
|
323
|
+
result = {
|
|
324
|
+
type: 'success',
|
|
325
|
+
path: pathResult.path,
|
|
326
|
+
items: pathResult.segments
|
|
327
|
+
};
|
|
328
|
+
return [
|
|
329
|
+
2,
|
|
330
|
+
{
|
|
331
|
+
content: [
|
|
332
|
+
{
|
|
333
|
+
type: 'text',
|
|
334
|
+
text: JSON.stringify(result)
|
|
335
|
+
}
|
|
336
|
+
],
|
|
337
|
+
structuredContent: {
|
|
338
|
+
result: result
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
];
|
|
342
|
+
case 3:
|
|
343
|
+
error = _state.sent();
|
|
344
|
+
message = _instanceof(error, Error) ? error.message : String(error);
|
|
345
|
+
logger.error('drive.folder.path error', {
|
|
346
|
+
error: message
|
|
347
|
+
});
|
|
348
|
+
// Throw McpError
|
|
349
|
+
throw new _types.McpError(_types.ErrorCode.InternalError, "Error getting folder path: ".concat(message), {
|
|
350
|
+
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
351
|
+
});
|
|
352
|
+
case 4:
|
|
353
|
+
return [
|
|
354
|
+
2
|
|
355
|
+
];
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}).apply(this, arguments);
|
|
359
|
+
}
|
|
360
|
+
function createTool() {
|
|
361
|
+
return {
|
|
362
|
+
name: 'folder-path',
|
|
363
|
+
config: config,
|
|
364
|
+
handler: handler
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/servers/mcp-drive/src/mcp/tools/folder-path.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport { type CallToolResult, ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\nimport type { drive_v3 } from 'googleapis';\nimport { google } from 'googleapis';\nimport { z } from 'zod';\nimport type { Logger } from '../../types.js';\n\nconst inputSchema = z.object({\n folderId: z.string().min(1).describe('Folder ID to get path for (or \"root\")'),\n});\n\n// Success branch schema - uses items: for consistency with standard vocabulary\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n path: z.string().describe('Full path from root (e.g., /Work/Projects/2024)'),\n items: z\n .array(\n z.object({\n id: z.string().describe('Folder ID'),\n name: z.string().describe('Folder name'),\n })\n )\n .describe('Path items from root to target folder'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n title: 'Get Folder Path',\n description: 'Get full path from folder to root. Returns human-readable path and items with IDs.',\n inputSchema: inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\n/**\n * Resolves the full path for a folder by walking up the parent chain.\n * Returns both the path string and structured segments with IDs and names.\n */\nasync function resolveFolderPath(drive: drive_v3.Drive, folderId: string, logger: Logger): Promise<{ path: string; segments: Array<{ id: string; name: string }> }> {\n // Handle root specially\n if (folderId === 'root') {\n return {\n path: '/',\n segments: [{ id: 'root', name: 'My Drive' }],\n };\n }\n\n const segments: Array<{ id: string; name: string }> = [];\n let currentId = folderId;\n const visited = new Set<string>();\n\n // Walk up the parent chain\n while (currentId && currentId !== 'root') {\n // Prevent infinite loops\n if (visited.has(currentId)) {\n logger.info('Circular folder reference detected', {\n folderId: currentId,\n });\n break;\n }\n visited.add(currentId);\n\n // Fetch folder metadata\n try {\n const response = await drive.files.get({\n fileId: currentId,\n fields: 'id,name,parents',\n });\n\n const id = response.data.id as string;\n const name = (response.data.name as string) || id;\n const parents = response.data.parents as string[] | undefined;\n\n // Add to segments at beginning (we're walking from child to root)\n segments.unshift({ id, name });\n\n // Move to parent\n currentId = (parents && parents.length > 0 ? parents[0] : '') || '';\n } catch (e) {\n logger.info('Failed to resolve folder path', {\n folderId: currentId,\n error: e,\n });\n break;\n }\n }\n\n // Add root if we reached it\n if (currentId === 'root') {\n segments.unshift({ id: 'root', name: 'My Drive' });\n }\n\n // Build path string\n const pathParts = segments.slice(1).map((seg) => seg.name); // Skip root\n const path = pathParts.length > 0 ? `/${pathParts.join('/')}` : '/';\n\n return { path, segments };\n}\n\nasync function handler({ folderId }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('drive.folder.path called', { folderId });\n\n try {\n const drive = google.drive({ version: 'v3', auth: extra.authContext.auth });\n\n const pathResult = await resolveFolderPath(drive, folderId, logger);\n\n logger.info('drive.folder.path returning', {\n path: pathResult.path,\n segmentCount: pathResult.segments.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n path: pathResult.path,\n items: pathResult.segments,\n };\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result),\n },\n ],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('drive.folder.path error', { error: message });\n\n // Throw McpError\n throw new McpError(ErrorCode.InternalError, `Error getting folder path: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'folder-path' as const,\n config,\n handler,\n };\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","inputSchema","z","object","folderId","string","min","describe","successBranchSchema","type","literal","path","items","array","id","name","outputSchema","discriminatedUnion","config","title","description","result","resolveFolderPath","drive","logger","segments","currentId","visited","response","parents","e","pathParts","Set","has","info","add","files","get","fileId","fields","data","unshift","length","error","slice","map","seg","join","handler","extra","pathResult","message","google","version","auth","authContext","segmentCount","content","text","JSON","stringify","structuredContent","Error","String","McpError","ErrorCode","InternalError","stack","undefined"],"mappings":"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"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
2
|
+
import { type CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
declare const inputSchema: z.ZodObject<{
|
|
5
|
+
shape: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
6
|
+
objects: "objects";
|
|
7
|
+
arrays: "arrays";
|
|
8
|
+
}>>>;
|
|
9
|
+
pageSize: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
10
|
+
pageToken: z.ZodOptional<z.ZodString>;
|
|
11
|
+
query: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodType<import("../../types.js").DriveQueryObject, unknown, z.core.$ZodTypeInternals<import("../../types.js").DriveQueryObject, unknown>>]>>;
|
|
12
|
+
fields: z.ZodOptional<z.ZodString>;
|
|
13
|
+
resolvePaths: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
declare const outputSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
16
|
+
type: z.ZodLiteral<"success">;
|
|
17
|
+
shape: z.ZodLiteral<"objects">;
|
|
18
|
+
items: z.ZodArray<z.ZodObject<{
|
|
19
|
+
id: z.ZodOptional<z.ZodString>;
|
|
20
|
+
name: z.ZodOptional<z.ZodString>;
|
|
21
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
22
|
+
webViewLink: z.ZodOptional<z.ZodString>;
|
|
23
|
+
webContentLink: z.ZodOptional<z.ZodString>;
|
|
24
|
+
modifiedTime: z.ZodOptional<z.ZodString>;
|
|
25
|
+
createdTime: z.ZodOptional<z.ZodString>;
|
|
26
|
+
size: z.ZodOptional<z.ZodString>;
|
|
27
|
+
version: z.ZodOptional<z.ZodString>;
|
|
28
|
+
shared: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
starred: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
trashed: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
parents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
32
|
+
id: z.ZodString;
|
|
33
|
+
name: z.ZodString;
|
|
34
|
+
}, z.core.$strip>>>;
|
|
35
|
+
owners: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
36
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
37
|
+
emailAddress: z.ZodOptional<z.ZodString>;
|
|
38
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
39
|
+
me: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
permissionId: z.ZodOptional<z.ZodString>;
|
|
41
|
+
photoLink: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, z.core.$strip>>>;
|
|
43
|
+
permissions: z.ZodOptional<z.ZodObject<{
|
|
44
|
+
canEdit: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
canComment: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
canShare: z.ZodOptional<z.ZodBoolean>;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
path: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>>;
|
|
50
|
+
count: z.ZodNumber;
|
|
51
|
+
nextPageToken: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
type: z.ZodLiteral<"success">;
|
|
54
|
+
shape: z.ZodLiteral<"arrays">;
|
|
55
|
+
columns: z.ZodArray<z.ZodString>;
|
|
56
|
+
rows: z.ZodArray<z.ZodArray<z.ZodUnknown>>;
|
|
57
|
+
count: z.ZodNumber;
|
|
58
|
+
nextPageToken: z.ZodOptional<z.ZodString>;
|
|
59
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
60
|
+
type: z.ZodLiteral<"auth_required">;
|
|
61
|
+
provider: z.ZodString;
|
|
62
|
+
message: z.ZodString;
|
|
63
|
+
url: z.ZodOptional<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>]>;
|
|
65
|
+
export type Input = z.infer<typeof inputSchema>;
|
|
66
|
+
export type Output = z.infer<typeof outputSchema>;
|
|
67
|
+
declare function handler({ query, resolvePaths, pageSize, pageToken, fields, shape }: Input, extra: EnrichedExtra): Promise<CallToolResult>;
|
|
68
|
+
export default function createTool(): {
|
|
69
|
+
name: "folder-search";
|
|
70
|
+
config: {
|
|
71
|
+
readonly title: "Search Folders";
|
|
72
|
+
readonly description: "Search Google Drive folders with flexible field selection and optional path resolution.";
|
|
73
|
+
readonly inputSchema: z.ZodObject<{
|
|
74
|
+
shape: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
75
|
+
objects: "objects";
|
|
76
|
+
arrays: "arrays";
|
|
77
|
+
}>>>;
|
|
78
|
+
pageSize: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
79
|
+
pageToken: z.ZodOptional<z.ZodString>;
|
|
80
|
+
query: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodType<import("../../types.js").DriveQueryObject, unknown, z.core.$ZodTypeInternals<import("../../types.js").DriveQueryObject, unknown>>]>>;
|
|
81
|
+
fields: z.ZodOptional<z.ZodString>;
|
|
82
|
+
resolvePaths: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
readonly outputSchema: z.ZodObject<{
|
|
85
|
+
result: z.ZodUnion<readonly [z.ZodObject<{
|
|
86
|
+
type: z.ZodLiteral<"success">;
|
|
87
|
+
shape: z.ZodLiteral<"objects">;
|
|
88
|
+
items: z.ZodArray<z.ZodObject<{
|
|
89
|
+
id: z.ZodOptional<z.ZodString>;
|
|
90
|
+
name: z.ZodOptional<z.ZodString>;
|
|
91
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
92
|
+
webViewLink: z.ZodOptional<z.ZodString>;
|
|
93
|
+
webContentLink: z.ZodOptional<z.ZodString>;
|
|
94
|
+
modifiedTime: z.ZodOptional<z.ZodString>;
|
|
95
|
+
createdTime: z.ZodOptional<z.ZodString>;
|
|
96
|
+
size: z.ZodOptional<z.ZodString>;
|
|
97
|
+
version: z.ZodOptional<z.ZodString>;
|
|
98
|
+
shared: z.ZodOptional<z.ZodBoolean>;
|
|
99
|
+
starred: z.ZodOptional<z.ZodBoolean>;
|
|
100
|
+
trashed: z.ZodOptional<z.ZodBoolean>;
|
|
101
|
+
parents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
102
|
+
id: z.ZodString;
|
|
103
|
+
name: z.ZodString;
|
|
104
|
+
}, z.core.$strip>>>;
|
|
105
|
+
owners: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
106
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
107
|
+
emailAddress: z.ZodOptional<z.ZodString>;
|
|
108
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
109
|
+
me: z.ZodOptional<z.ZodBoolean>;
|
|
110
|
+
permissionId: z.ZodOptional<z.ZodString>;
|
|
111
|
+
photoLink: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, z.core.$strip>>>;
|
|
113
|
+
permissions: z.ZodOptional<z.ZodObject<{
|
|
114
|
+
canEdit: z.ZodOptional<z.ZodBoolean>;
|
|
115
|
+
canComment: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
canShare: z.ZodOptional<z.ZodBoolean>;
|
|
117
|
+
}, z.core.$strip>>;
|
|
118
|
+
path: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, z.core.$strip>>;
|
|
120
|
+
count: z.ZodNumber;
|
|
121
|
+
nextPageToken: z.ZodOptional<z.ZodString>;
|
|
122
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
123
|
+
type: z.ZodLiteral<"success">;
|
|
124
|
+
shape: z.ZodLiteral<"arrays">;
|
|
125
|
+
columns: z.ZodArray<z.ZodString>;
|
|
126
|
+
rows: z.ZodArray<z.ZodArray<z.ZodUnknown>>;
|
|
127
|
+
count: z.ZodNumber;
|
|
128
|
+
nextPageToken: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
130
|
+
type: z.ZodLiteral<"auth_required">;
|
|
131
|
+
provider: z.ZodString;
|
|
132
|
+
message: z.ZodString;
|
|
133
|
+
url: z.ZodOptional<z.ZodString>;
|
|
134
|
+
}, z.core.$strip>]>;
|
|
135
|
+
}, z.core.$strip>;
|
|
136
|
+
};
|
|
137
|
+
handler: typeof handler;
|
|
138
|
+
};
|
|
139
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
2
|
+
import { type CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
declare const inputSchema: z.ZodObject<{
|
|
5
|
+
shape: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
6
|
+
objects: "objects";
|
|
7
|
+
arrays: "arrays";
|
|
8
|
+
}>>>;
|
|
9
|
+
pageSize: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
10
|
+
pageToken: z.ZodOptional<z.ZodString>;
|
|
11
|
+
query: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodType<import("../../types.js").DriveQueryObject, unknown, z.core.$ZodTypeInternals<import("../../types.js").DriveQueryObject, unknown>>]>>;
|
|
12
|
+
fields: z.ZodOptional<z.ZodString>;
|
|
13
|
+
resolvePaths: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
declare const outputSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
16
|
+
type: z.ZodLiteral<"success">;
|
|
17
|
+
shape: z.ZodLiteral<"objects">;
|
|
18
|
+
items: z.ZodArray<z.ZodObject<{
|
|
19
|
+
id: z.ZodOptional<z.ZodString>;
|
|
20
|
+
name: z.ZodOptional<z.ZodString>;
|
|
21
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
22
|
+
webViewLink: z.ZodOptional<z.ZodString>;
|
|
23
|
+
webContentLink: z.ZodOptional<z.ZodString>;
|
|
24
|
+
modifiedTime: z.ZodOptional<z.ZodString>;
|
|
25
|
+
createdTime: z.ZodOptional<z.ZodString>;
|
|
26
|
+
size: z.ZodOptional<z.ZodString>;
|
|
27
|
+
version: z.ZodOptional<z.ZodString>;
|
|
28
|
+
shared: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
starred: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
trashed: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
parents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
32
|
+
id: z.ZodString;
|
|
33
|
+
name: z.ZodString;
|
|
34
|
+
}, z.core.$strip>>>;
|
|
35
|
+
owners: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
36
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
37
|
+
emailAddress: z.ZodOptional<z.ZodString>;
|
|
38
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
39
|
+
me: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
permissionId: z.ZodOptional<z.ZodString>;
|
|
41
|
+
photoLink: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, z.core.$strip>>>;
|
|
43
|
+
permissions: z.ZodOptional<z.ZodObject<{
|
|
44
|
+
canEdit: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
canComment: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
canShare: z.ZodOptional<z.ZodBoolean>;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
path: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>>;
|
|
50
|
+
count: z.ZodNumber;
|
|
51
|
+
nextPageToken: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
type: z.ZodLiteral<"success">;
|
|
54
|
+
shape: z.ZodLiteral<"arrays">;
|
|
55
|
+
columns: z.ZodArray<z.ZodString>;
|
|
56
|
+
rows: z.ZodArray<z.ZodArray<z.ZodUnknown>>;
|
|
57
|
+
count: z.ZodNumber;
|
|
58
|
+
nextPageToken: z.ZodOptional<z.ZodString>;
|
|
59
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
60
|
+
type: z.ZodLiteral<"auth_required">;
|
|
61
|
+
provider: z.ZodString;
|
|
62
|
+
message: z.ZodString;
|
|
63
|
+
url: z.ZodOptional<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>]>;
|
|
65
|
+
export type Input = z.infer<typeof inputSchema>;
|
|
66
|
+
export type Output = z.infer<typeof outputSchema>;
|
|
67
|
+
declare function handler({ query, resolvePaths, pageSize, pageToken, fields, shape }: Input, extra: EnrichedExtra): Promise<CallToolResult>;
|
|
68
|
+
export default function createTool(): {
|
|
69
|
+
name: "folder-search";
|
|
70
|
+
config: {
|
|
71
|
+
readonly title: "Search Folders";
|
|
72
|
+
readonly description: "Search Google Drive folders with flexible field selection and optional path resolution.";
|
|
73
|
+
readonly inputSchema: z.ZodObject<{
|
|
74
|
+
shape: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
75
|
+
objects: "objects";
|
|
76
|
+
arrays: "arrays";
|
|
77
|
+
}>>>;
|
|
78
|
+
pageSize: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
79
|
+
pageToken: z.ZodOptional<z.ZodString>;
|
|
80
|
+
query: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodType<import("../../types.js").DriveQueryObject, unknown, z.core.$ZodTypeInternals<import("../../types.js").DriveQueryObject, unknown>>]>>;
|
|
81
|
+
fields: z.ZodOptional<z.ZodString>;
|
|
82
|
+
resolvePaths: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
readonly outputSchema: z.ZodObject<{
|
|
85
|
+
result: z.ZodUnion<readonly [z.ZodObject<{
|
|
86
|
+
type: z.ZodLiteral<"success">;
|
|
87
|
+
shape: z.ZodLiteral<"objects">;
|
|
88
|
+
items: z.ZodArray<z.ZodObject<{
|
|
89
|
+
id: z.ZodOptional<z.ZodString>;
|
|
90
|
+
name: z.ZodOptional<z.ZodString>;
|
|
91
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
92
|
+
webViewLink: z.ZodOptional<z.ZodString>;
|
|
93
|
+
webContentLink: z.ZodOptional<z.ZodString>;
|
|
94
|
+
modifiedTime: z.ZodOptional<z.ZodString>;
|
|
95
|
+
createdTime: z.ZodOptional<z.ZodString>;
|
|
96
|
+
size: z.ZodOptional<z.ZodString>;
|
|
97
|
+
version: z.ZodOptional<z.ZodString>;
|
|
98
|
+
shared: z.ZodOptional<z.ZodBoolean>;
|
|
99
|
+
starred: z.ZodOptional<z.ZodBoolean>;
|
|
100
|
+
trashed: z.ZodOptional<z.ZodBoolean>;
|
|
101
|
+
parents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
102
|
+
id: z.ZodString;
|
|
103
|
+
name: z.ZodString;
|
|
104
|
+
}, z.core.$strip>>>;
|
|
105
|
+
owners: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
106
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
107
|
+
emailAddress: z.ZodOptional<z.ZodString>;
|
|
108
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
109
|
+
me: z.ZodOptional<z.ZodBoolean>;
|
|
110
|
+
permissionId: z.ZodOptional<z.ZodString>;
|
|
111
|
+
photoLink: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, z.core.$strip>>>;
|
|
113
|
+
permissions: z.ZodOptional<z.ZodObject<{
|
|
114
|
+
canEdit: z.ZodOptional<z.ZodBoolean>;
|
|
115
|
+
canComment: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
canShare: z.ZodOptional<z.ZodBoolean>;
|
|
117
|
+
}, z.core.$strip>>;
|
|
118
|
+
path: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, z.core.$strip>>;
|
|
120
|
+
count: z.ZodNumber;
|
|
121
|
+
nextPageToken: z.ZodOptional<z.ZodString>;
|
|
122
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
123
|
+
type: z.ZodLiteral<"success">;
|
|
124
|
+
shape: z.ZodLiteral<"arrays">;
|
|
125
|
+
columns: z.ZodArray<z.ZodString>;
|
|
126
|
+
rows: z.ZodArray<z.ZodArray<z.ZodUnknown>>;
|
|
127
|
+
count: z.ZodNumber;
|
|
128
|
+
nextPageToken: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
130
|
+
type: z.ZodLiteral<"auth_required">;
|
|
131
|
+
provider: z.ZodString;
|
|
132
|
+
message: z.ZodString;
|
|
133
|
+
url: z.ZodOptional<z.ZodString>;
|
|
134
|
+
}, z.core.$strip>]>;
|
|
135
|
+
}, z.core.$strip>;
|
|
136
|
+
};
|
|
137
|
+
handler: typeof handler;
|
|
138
|
+
};
|
|
139
|
+
export {};
|