@gemstack/connector-google-drive 0.1.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 +48 -0
- package/dist/client.d.ts +15 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +52 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +217 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Suleiman Shahbari
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @gemstack/connector-google-drive
|
|
2
|
+
|
|
3
|
+
A Google Drive connector for GemStack AI orchestration. Browse, read, and share Drive files over the Drive REST API (v3). Built with [`@gemstack/connectors`](../connectors); the result is a standard `@gemstack/mcp` server.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @gemstack/connector-google-drive @gemstack/connectors @gemstack/mcp
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Use
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { mountConnectors } from '@gemstack/connectors'
|
|
15
|
+
import { Mcp } from '@gemstack/mcp'
|
|
16
|
+
import drive from '@gemstack/connector-google-drive'
|
|
17
|
+
|
|
18
|
+
const Server = mountConnectors([drive], {
|
|
19
|
+
// A Google OAuth 2.0 access token with a Drive scope.
|
|
20
|
+
credentials: () => ({ token: process.env.GOOGLE_ACCESS_TOKEN }),
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
Mcp.web('/mcp/drive', Server)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Tools are exposed namespaced by connector id, e.g. `google-drive_list-files`.
|
|
27
|
+
|
|
28
|
+
## Auth
|
|
29
|
+
|
|
30
|
+
Drive has no static API key — it is OAuth 2.0 only. The connector declares `auth: { type: 'oauth', scopes: ['https://www.googleapis.com/auth/drive'] }` and consumes a bearer token from `ctx.auth.token`; it does no OAuth handshake itself. Use `drive.readonly` if you only need the read tools. To protect a web endpoint and obtain the token, wrap it with `@gemstack/mcp`'s `oauth2McpMiddleware` + `registerOAuth2Metadata` and feed the verified token through the mount `credentials` option.
|
|
31
|
+
|
|
32
|
+
## Tools
|
|
33
|
+
|
|
34
|
+
| Tool | Kind | Description |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| `get-about` | read | Authenticated user + storage usage |
|
|
37
|
+
| `list-files` | read | List files (folder / raw query scoped) |
|
|
38
|
+
| `search-files` | read | Search by name and full-text content |
|
|
39
|
+
| `get-file` | read | Metadata for one file or folder |
|
|
40
|
+
| `get-file-content` | read | File as text (Docs exported, others downloaded) |
|
|
41
|
+
| `list-permissions` | read | Who has access to a file |
|
|
42
|
+
| `create-folder` | write | Create a folder |
|
|
43
|
+
| `share-file` | write | Grant access (create a permission) |
|
|
44
|
+
| `trash-file` | write (destructive) | Move a file to the trash (reversible) |
|
|
45
|
+
|
|
46
|
+
Read tools are annotated `readOnly` so an agent can auto-approve them; write tools are not, and `trash-file` is marked `destructive`.
|
|
47
|
+
|
|
48
|
+
Responses are slimmed to the fields an agent needs (no raw API envelopes) to keep token usage down.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ConnectorContext } from '@gemstack/connectors';
|
|
2
|
+
/** Thrown when the Google Drive API returns a non-2xx response. */
|
|
3
|
+
export declare class GoogleDriveError extends Error {
|
|
4
|
+
status: number;
|
|
5
|
+
constructor(status: number, message: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Minimal Google Drive REST (v3) client over global `fetch`. The bearer comes
|
|
9
|
+
* from the connector context (`ctx.auth.token`) — a Google OAuth 2.0 access
|
|
10
|
+
* token. No SDK dependency, so the connector stays light.
|
|
11
|
+
*/
|
|
12
|
+
export declare function gd<T = unknown>(ctx: ConnectorContext, method: string, path: string, body?: unknown): Promise<T>;
|
|
13
|
+
/** GET a file's raw bytes as text (for `alt=media` downloads and Docs exports). */
|
|
14
|
+
export declare function gdText(ctx: ConnectorContext, path: string): Promise<string>;
|
|
15
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAI5D,mEAAmE;AACnE,qBAAa,gBAAiB,SAAQ,KAAK;IAEhC,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AAaD;;;;GAIG;AACH,wBAAsB,EAAE,CAAC,CAAC,GAAG,OAAO,EAClC,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,GACb,OAAO,CAAC,CAAC,CAAC,CAoBZ;AAED,mFAAmF;AACnF,wBAAsB,MAAM,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQjF"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const API = 'https://www.googleapis.com/drive/v3';
|
|
2
|
+
/** Thrown when the Google Drive API returns a non-2xx response. */
|
|
3
|
+
export class GoogleDriveError extends Error {
|
|
4
|
+
status;
|
|
5
|
+
constructor(status, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.name = 'GoogleDriveError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function bearer(ctx) {
|
|
12
|
+
const token = ctx.auth.token;
|
|
13
|
+
if (!token) {
|
|
14
|
+
throw new GoogleDriveError(401, 'no Google access token available — provide an OAuth bearer via the mount `credentials` option');
|
|
15
|
+
}
|
|
16
|
+
return token;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Minimal Google Drive REST (v3) client over global `fetch`. The bearer comes
|
|
20
|
+
* from the connector context (`ctx.auth.token`) — a Google OAuth 2.0 access
|
|
21
|
+
* token. No SDK dependency, so the connector stays light.
|
|
22
|
+
*/
|
|
23
|
+
export async function gd(ctx, method, path, body) {
|
|
24
|
+
const token = bearer(ctx);
|
|
25
|
+
const res = await fetch(`${API}${path}`, {
|
|
26
|
+
method,
|
|
27
|
+
headers: {
|
|
28
|
+
Authorization: `Bearer ${token}`,
|
|
29
|
+
Accept: 'application/json',
|
|
30
|
+
...(body !== undefined ? { 'Content-Type': 'application/json' } : {}),
|
|
31
|
+
},
|
|
32
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
33
|
+
});
|
|
34
|
+
if (!res.ok) {
|
|
35
|
+
const detail = await res.text().catch(() => '');
|
|
36
|
+
throw new GoogleDriveError(res.status, `${method} ${path} -> ${res.status} ${res.statusText}${detail ? `: ${detail}` : ''}`);
|
|
37
|
+
}
|
|
38
|
+
if (res.status === 204)
|
|
39
|
+
return undefined;
|
|
40
|
+
return (await res.json());
|
|
41
|
+
}
|
|
42
|
+
/** GET a file's raw bytes as text (for `alt=media` downloads and Docs exports). */
|
|
43
|
+
export async function gdText(ctx, path) {
|
|
44
|
+
const token = bearer(ctx);
|
|
45
|
+
const res = await fetch(`${API}${path}`, { method: 'GET', headers: { Authorization: `Bearer ${token}` } });
|
|
46
|
+
if (!res.ok) {
|
|
47
|
+
const detail = await res.text().catch(() => '');
|
|
48
|
+
throw new GoogleDriveError(res.status, `GET ${path} -> ${res.status} ${res.statusText}${detail ? `: ${detail}` : ''}`);
|
|
49
|
+
}
|
|
50
|
+
return await res.text();
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,MAAM,GAAG,GAAG,qCAAqC,CAAA;AAEjD,mEAAmE;AACnE,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAEhC;IADT,YACS,MAAc,EACrB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAA;QAHP,WAAM,GAAN,MAAM,CAAQ;QAIrB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAA;IAChC,CAAC;CACF;AAED,SAAS,MAAM,CAAC,GAAqB;IACnC,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAA;IAC5B,IAAI,CAAC,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AAM,CAAA;AAChC,CAAC;AAED,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,GAAqB,EAAE,IAAY;IAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;IACzB,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,GAAG,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA;IAC1G,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;QAC/C,MAAM,IAAI,gBAAgB,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,IAAI,OAAO,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACxH,CAAC;IACD,OAAO,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;AACzB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { GoogleDriveError } from './client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Google Drive connector: browse, read, and share Drive files.
|
|
4
|
+
*
|
|
5
|
+
* Auth is a Google OAuth 2.0 access token. Drive has no static API key, so the
|
|
6
|
+
* orchestrator supplies a bearer via the mount `credentials` option (the same
|
|
7
|
+
* seam every connector uses).
|
|
8
|
+
*/
|
|
9
|
+
declare const _default: import("@gemstack/connectors").Connector;
|
|
10
|
+
export default _default;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAuC9C;;;;;;GAMG;;AACH,wBAgME"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { defineConnector } from '@gemstack/connectors';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { gd, gdText } from './client.js';
|
|
4
|
+
export { GoogleDriveError } from './client.js';
|
|
5
|
+
const enc = encodeURIComponent;
|
|
6
|
+
const FOLDER_MIME = 'application/vnd.google-apps.folder';
|
|
7
|
+
/** Fields requested for a file listing/metadata, kept to what an agent needs. */
|
|
8
|
+
const FILE_FIELDS = 'id,name,mimeType,size,modifiedTime,owners(emailAddress),webViewLink';
|
|
9
|
+
/** Escape a string for use inside a single-quoted Drive query literal. */
|
|
10
|
+
const driveStr = (s) => s.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
|
|
11
|
+
/** Slim a Drive file resource down to the fields an agent needs. */
|
|
12
|
+
function slimFile(f) {
|
|
13
|
+
return {
|
|
14
|
+
id: f.id,
|
|
15
|
+
name: f.name,
|
|
16
|
+
mimeType: f.mimeType,
|
|
17
|
+
isFolder: f.mimeType === FOLDER_MIME,
|
|
18
|
+
size: f.size != null ? Number(f.size) : undefined,
|
|
19
|
+
modifiedTime: f.modifiedTime,
|
|
20
|
+
owners: Array.isArray(f.owners) ? f.owners.map((o) => o?.emailAddress).filter(Boolean) : undefined,
|
|
21
|
+
url: f.webViewLink,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Map a Google editor mime type to the text format it can be exported as. */
|
|
25
|
+
function exportMimeFor(mime) {
|
|
26
|
+
switch (mime) {
|
|
27
|
+
case 'application/vnd.google-apps.document':
|
|
28
|
+
return 'text/plain';
|
|
29
|
+
case 'application/vnd.google-apps.spreadsheet':
|
|
30
|
+
return 'text/csv';
|
|
31
|
+
case 'application/vnd.google-apps.presentation':
|
|
32
|
+
return 'text/plain';
|
|
33
|
+
default:
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Google Drive connector: browse, read, and share Drive files.
|
|
39
|
+
*
|
|
40
|
+
* Auth is a Google OAuth 2.0 access token. Drive has no static API key, so the
|
|
41
|
+
* orchestrator supplies a bearer via the mount `credentials` option (the same
|
|
42
|
+
* seam every connector uses).
|
|
43
|
+
*/
|
|
44
|
+
export default defineConnector({
|
|
45
|
+
id: 'google-drive',
|
|
46
|
+
name: 'Google Drive',
|
|
47
|
+
instructions: 'Browse, read, and share files in Google Drive.',
|
|
48
|
+
auth: {
|
|
49
|
+
type: 'oauth',
|
|
50
|
+
scopes: ['https://www.googleapis.com/auth/drive'],
|
|
51
|
+
description: 'Google OAuth 2.0 access token with a Drive scope (`drive` for full access, `drive.readonly` for read-only).',
|
|
52
|
+
},
|
|
53
|
+
tools: [
|
|
54
|
+
{
|
|
55
|
+
name: 'get-about',
|
|
56
|
+
description: "Get the authenticated user's identity and Drive storage usage.",
|
|
57
|
+
schema: z.object({}),
|
|
58
|
+
annotations: { readOnly: true, openWorld: true },
|
|
59
|
+
handle: async (_input, ctx) => {
|
|
60
|
+
const a = await gd(ctx, 'GET', '/about?fields=user(displayName,emailAddress),storageQuota(limit,usage)');
|
|
61
|
+
return {
|
|
62
|
+
user: a.user?.displayName,
|
|
63
|
+
email: a.user?.emailAddress,
|
|
64
|
+
storageUsage: a.storageQuota?.usage != null ? Number(a.storageQuota.usage) : undefined,
|
|
65
|
+
storageLimit: a.storageQuota?.limit != null ? Number(a.storageQuota.limit) : undefined,
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'list-files',
|
|
71
|
+
description: 'List files (newest first). Optionally scope to a folder, or pass a raw Drive `query` expression. Trashed files are excluded by default.',
|
|
72
|
+
schema: z.object({
|
|
73
|
+
folderId: z.string().min(1).optional(),
|
|
74
|
+
query: z.string().min(1).optional(),
|
|
75
|
+
includeTrashed: z.boolean().optional(),
|
|
76
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
77
|
+
}),
|
|
78
|
+
annotations: { readOnly: true, openWorld: true },
|
|
79
|
+
handle: async (input, ctx) => {
|
|
80
|
+
const clauses = [];
|
|
81
|
+
if (input.folderId)
|
|
82
|
+
clauses.push(`'${driveStr(input.folderId)}' in parents`);
|
|
83
|
+
if (!input.includeTrashed)
|
|
84
|
+
clauses.push('trashed = false');
|
|
85
|
+
if (input.query)
|
|
86
|
+
clauses.push(`(${input.query})`);
|
|
87
|
+
const params = new URLSearchParams({
|
|
88
|
+
pageSize: String(input.limit ?? 30),
|
|
89
|
+
orderBy: 'modifiedTime desc',
|
|
90
|
+
fields: `files(${FILE_FIELDS})`,
|
|
91
|
+
});
|
|
92
|
+
if (clauses.length)
|
|
93
|
+
params.set('q', clauses.join(' and '));
|
|
94
|
+
const res = await gd(ctx, 'GET', `/files?${params}`);
|
|
95
|
+
return (res.files ?? []).map(slimFile);
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'search-files',
|
|
100
|
+
description: 'Search Drive by file name and full-text content. Trashed files are excluded.',
|
|
101
|
+
schema: z.object({ text: z.string().min(1), limit: z.number().int().min(1).max(100).optional() }),
|
|
102
|
+
annotations: { readOnly: true, openWorld: true },
|
|
103
|
+
handle: async (input, ctx) => {
|
|
104
|
+
const t = driveStr(input.text);
|
|
105
|
+
const params = new URLSearchParams({
|
|
106
|
+
q: `(name contains '${t}' or fullText contains '${t}') and trashed = false`,
|
|
107
|
+
pageSize: String(input.limit ?? 20),
|
|
108
|
+
orderBy: 'modifiedTime desc',
|
|
109
|
+
fields: `files(${FILE_FIELDS})`,
|
|
110
|
+
});
|
|
111
|
+
const res = await gd(ctx, 'GET', `/files?${params}`);
|
|
112
|
+
return (res.files ?? []).map(slimFile);
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: 'get-file',
|
|
117
|
+
description: 'Get metadata for a single file or folder by id.',
|
|
118
|
+
schema: z.object({ fileId: z.string().min(1) }),
|
|
119
|
+
annotations: { readOnly: true, openWorld: true },
|
|
120
|
+
handle: async (input, ctx) => {
|
|
121
|
+
const f = await gd(ctx, 'GET', `/files/${enc(input.fileId)}?fields=${FILE_FIELDS},parents,description`);
|
|
122
|
+
return { ...slimFile(f), parents: f.parents, description: f.description };
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: 'get-file-content',
|
|
127
|
+
description: 'Read a file as text. Google Docs/Sheets/Slides are exported (to text/CSV); other files are downloaded directly.',
|
|
128
|
+
schema: z.object({ fileId: z.string().min(1) }),
|
|
129
|
+
annotations: { readOnly: true, openWorld: true },
|
|
130
|
+
handle: async (input, ctx) => {
|
|
131
|
+
const id = enc(input.fileId);
|
|
132
|
+
const meta = await gd(ctx, 'GET', `/files/${id}?fields=id,name,mimeType`);
|
|
133
|
+
const mime = meta.mimeType ?? '';
|
|
134
|
+
if (mime === FOLDER_MIME)
|
|
135
|
+
return { error: `"${meta.name}" is a folder, not a file` };
|
|
136
|
+
let content;
|
|
137
|
+
if (mime.startsWith('application/vnd.google-apps.')) {
|
|
138
|
+
const exportMime = exportMimeFor(mime);
|
|
139
|
+
if (!exportMime)
|
|
140
|
+
return { error: `cannot export ${mime} as text` };
|
|
141
|
+
content = await gdText(ctx, `/files/${id}/export?mimeType=${enc(exportMime)}`);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
content = await gdText(ctx, `/files/${id}?alt=media`);
|
|
145
|
+
}
|
|
146
|
+
return { id: meta.id, name: meta.name, mimeType: mime, content };
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'list-permissions',
|
|
151
|
+
description: 'List who has access to a file or folder.',
|
|
152
|
+
schema: z.object({ fileId: z.string().min(1) }),
|
|
153
|
+
annotations: { readOnly: true, openWorld: true },
|
|
154
|
+
handle: async (input, ctx) => {
|
|
155
|
+
const res = await gd(ctx, 'GET', `/files/${enc(input.fileId)}/permissions?fields=permissions(id,type,role,emailAddress,domain)`);
|
|
156
|
+
return (res.permissions ?? []).map((p) => ({
|
|
157
|
+
id: p.id,
|
|
158
|
+
type: p.type,
|
|
159
|
+
role: p.role,
|
|
160
|
+
emailAddress: p.emailAddress,
|
|
161
|
+
domain: p.domain,
|
|
162
|
+
}));
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: 'create-folder',
|
|
167
|
+
description: 'Create a new folder, optionally inside a parent folder.',
|
|
168
|
+
schema: z.object({ name: z.string().min(1), parentId: z.string().min(1).optional() }),
|
|
169
|
+
annotations: { openWorld: true },
|
|
170
|
+
handle: async (input, ctx) => {
|
|
171
|
+
const payload = { name: input.name, mimeType: FOLDER_MIME };
|
|
172
|
+
if (input.parentId)
|
|
173
|
+
payload.parents = [input.parentId];
|
|
174
|
+
const f = await gd(ctx, 'POST', `/files?fields=id,name,webViewLink`, payload);
|
|
175
|
+
return { id: f.id, name: f.name, url: f.webViewLink };
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: 'share-file',
|
|
180
|
+
description: 'Grant access to a file or folder by creating a permission.',
|
|
181
|
+
schema: z.object({
|
|
182
|
+
fileId: z.string().min(1),
|
|
183
|
+
role: z.enum(['reader', 'commenter', 'writer', 'owner']).optional(),
|
|
184
|
+
type: z.enum(['user', 'group', 'domain', 'anyone']).optional(),
|
|
185
|
+
emailAddress: z.string().min(1).optional(),
|
|
186
|
+
domain: z.string().min(1).optional(),
|
|
187
|
+
}),
|
|
188
|
+
annotations: { openWorld: true },
|
|
189
|
+
handle: async (input, ctx) => {
|
|
190
|
+
const type = input.type ?? 'user';
|
|
191
|
+
if ((type === 'user' || type === 'group') && !input.emailAddress) {
|
|
192
|
+
return { error: `type "${type}" requires an emailAddress` };
|
|
193
|
+
}
|
|
194
|
+
if (type === 'domain' && !input.domain)
|
|
195
|
+
return { error: 'type "domain" requires a domain' };
|
|
196
|
+
const payload = { role: input.role ?? 'reader', type };
|
|
197
|
+
if (input.emailAddress)
|
|
198
|
+
payload.emailAddress = input.emailAddress;
|
|
199
|
+
if (input.domain)
|
|
200
|
+
payload.domain = input.domain;
|
|
201
|
+
const p = await gd(ctx, 'POST', `/files/${enc(input.fileId)}/permissions?fields=id,role,type`, payload);
|
|
202
|
+
return { id: p.id, role: p.role, type: p.type };
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: 'trash-file',
|
|
207
|
+
description: 'Move a file or folder to the trash (reversible).',
|
|
208
|
+
schema: z.object({ fileId: z.string().min(1) }),
|
|
209
|
+
annotations: { destructive: true, openWorld: true },
|
|
210
|
+
handle: async (input, ctx) => {
|
|
211
|
+
const f = await gd(ctx, 'PATCH', `/files/${enc(input.fileId)}?fields=id,name,trashed`, { trashed: true });
|
|
212
|
+
return { id: f.id, name: f.name, trashed: f.trashed };
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
});
|
|
217
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,MAAM,GAAG,GAAG,kBAAkB,CAAA;AAC9B,MAAM,WAAW,GAAG,oCAAoC,CAAA;AAExD,iFAAiF;AACjF,MAAM,WAAW,GAAG,qEAAqE,CAAA;AAEzF,0EAA0E;AAC1E,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,C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AAE,CAAC;YAC/C,WAAW,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;YACnD,MAAM,EAAE,KAAK,EAAE,KAAyB,EAAE,GAAG,EAAE,EAAE;gBAC/C,MAAM,CAAC,GAAG,MAAM,EAAE,CAChB,GAAG,EACH,OAAO,EACP,UAAU,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,yBAAyB,EACpD,EAAE,OAAO,EAAE,IAAI,EAAE,CAClB,CAAA;gBACD,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAA;YACvD,CAAC;SACF;KACF;CACF,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gemstack/connector-google-drive",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Google Drive connector for GemStack AI orchestration: browse, read, and share Drive files over the Drive REST API. Built with @gemstack/connectors.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"connector",
|
|
8
|
+
"google-drive",
|
|
9
|
+
"ai",
|
|
10
|
+
"agents",
|
|
11
|
+
"orchestration",
|
|
12
|
+
"gemstack"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "https://github.com/gemstack-land/gemstack/tree/main/packages/connector-google-drive#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/gemstack-land/gemstack/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/gemstack-land/gemstack",
|
|
22
|
+
"directory": "packages/connector-google-drive"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=22.12.0"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"import": "./dist/index.js",
|
|
36
|
+
"types": "./dist/index.d.ts"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"zod": "^4.0.0",
|
|
41
|
+
"@gemstack/connectors": "^0.1.0",
|
|
42
|
+
"@gemstack/mcp": "^0.2.1"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^20.0.0",
|
|
46
|
+
"reflect-metadata": "^0.2.0",
|
|
47
|
+
"typescript": "^5.4.0"
|
|
48
|
+
},
|
|
49
|
+
"author": "Suleiman Shahbari",
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsc -p tsconfig.build.json",
|
|
52
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
54
|
+
"test": "tsc -p tsconfig.test.json && cd dist-test && node --test",
|
|
55
|
+
"clean": "rm -rf dist dist-test"
|
|
56
|
+
}
|
|
57
|
+
}
|