gcs-google-mcp-server 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/README.md +241 -0
- package/build/index.integration-with-mock.js +42 -0
- package/build/index.js +152 -0
- package/package.json +50 -0
- package/shared/gcs-client/gcs-client.d.ts +74 -0
- package/shared/gcs-client/gcs-client.integration-mock.d.ts +15 -0
- package/shared/gcs-client/gcs-client.integration-mock.js +131 -0
- package/shared/gcs-client/gcs-client.js +120 -0
- package/shared/index.d.ts +8 -0
- package/shared/index.js +9 -0
- package/shared/logging.d.ts +24 -0
- package/shared/logging.js +40 -0
- package/shared/resources.d.ts +3 -0
- package/shared/resources.js +65 -0
- package/shared/server.d.ts +46 -0
- package/shared/server.js +37 -0
- package/shared/state.d.ts +43 -0
- package/shared/state.js +67 -0
- package/shared/tools/copy-object.d.ts +59 -0
- package/shared/tools/copy-object.js +71 -0
- package/shared/tools/create-bucket.d.ts +45 -0
- package/shared/tools/create-bucket.js +82 -0
- package/shared/tools/delete-bucket.d.ts +38 -0
- package/shared/tools/delete-bucket.js +60 -0
- package/shared/tools/delete-object.d.ts +45 -0
- package/shared/tools/delete-object.js +64 -0
- package/shared/tools/get-object.d.ts +45 -0
- package/shared/tools/get-object.js +65 -0
- package/shared/tools/head-bucket.d.ts +38 -0
- package/shared/tools/head-bucket.js +58 -0
- package/shared/tools/list-buckets.d.ts +27 -0
- package/shared/tools/list-buckets.js +49 -0
- package/shared/tools/list-objects.d.ts +68 -0
- package/shared/tools/list-objects.js +80 -0
- package/shared/tools/put-object.d.ts +69 -0
- package/shared/tools/put-object.js +81 -0
- package/shared/tools.d.ts +30 -0
- package/shared/tools.js +154 -0
- package/shared/types.d.ts +1 -0
- package/shared/types.js +6 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const PARAM_DESCRIPTIONS = {
|
|
3
|
+
sourceBucket: 'The source bucket name (e.g., "source-bucket")',
|
|
4
|
+
sourceKey: 'The source object key (e.g., "path/to/source-file.txt")',
|
|
5
|
+
destBucket: 'The destination bucket name (e.g., "dest-bucket")',
|
|
6
|
+
destKey: 'The destination object key (e.g., "path/to/dest-file.txt")',
|
|
7
|
+
};
|
|
8
|
+
export const CopyObjectSchema = z.object({
|
|
9
|
+
sourceBucket: z.string().min(1).describe(PARAM_DESCRIPTIONS.sourceBucket),
|
|
10
|
+
sourceKey: z.string().min(1).describe(PARAM_DESCRIPTIONS.sourceKey),
|
|
11
|
+
destBucket: z.string().min(1).describe(PARAM_DESCRIPTIONS.destBucket),
|
|
12
|
+
destKey: z.string().min(1).describe(PARAM_DESCRIPTIONS.destKey),
|
|
13
|
+
});
|
|
14
|
+
export function copyObjectTool(_server, clientFactory) {
|
|
15
|
+
return {
|
|
16
|
+
name: 'copy_object',
|
|
17
|
+
description: `Copy an object within GCS (same bucket or across buckets).
|
|
18
|
+
|
|
19
|
+
Copies an object from one location to another. Can be used to rename objects or move them between buckets.
|
|
20
|
+
|
|
21
|
+
Example response:
|
|
22
|
+
{
|
|
23
|
+
"success": true,
|
|
24
|
+
"message": "Object copied from gs://source-bucket/file.txt to gs://dest-bucket/file.txt",
|
|
25
|
+
"etag": "\\"abc123\\"",
|
|
26
|
+
"generation": "1234567890"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
Use cases:
|
|
30
|
+
- Create backups of files
|
|
31
|
+
- Move files between buckets
|
|
32
|
+
- Rename objects (copy then delete original)
|
|
33
|
+
- Organize files into different paths`,
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
sourceBucket: { type: 'string', description: PARAM_DESCRIPTIONS.sourceBucket },
|
|
38
|
+
sourceKey: { type: 'string', description: PARAM_DESCRIPTIONS.sourceKey },
|
|
39
|
+
destBucket: { type: 'string', description: PARAM_DESCRIPTIONS.destBucket },
|
|
40
|
+
destKey: { type: 'string', description: PARAM_DESCRIPTIONS.destKey },
|
|
41
|
+
},
|
|
42
|
+
required: ['sourceBucket', 'sourceKey', 'destBucket', 'destKey'],
|
|
43
|
+
},
|
|
44
|
+
handler: async (args) => {
|
|
45
|
+
try {
|
|
46
|
+
const validated = CopyObjectSchema.parse(args);
|
|
47
|
+
const client = clientFactory();
|
|
48
|
+
const result = await client.copyObject(validated.sourceBucket, validated.sourceKey, validated.destBucket, validated.destKey);
|
|
49
|
+
return {
|
|
50
|
+
content: [
|
|
51
|
+
{
|
|
52
|
+
type: 'text',
|
|
53
|
+
text: JSON.stringify({
|
|
54
|
+
success: true,
|
|
55
|
+
message: `Object copied from gs://${validated.sourceBucket}/${validated.sourceKey} to gs://${validated.destBucket}/${validated.destKey}`,
|
|
56
|
+
...result,
|
|
57
|
+
}, null, 2),
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
64
|
+
return {
|
|
65
|
+
content: [{ type: 'text', text: `Error copying object: ${message}` }],
|
|
66
|
+
isError: true,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import type { GCSClientFactory } from '../server.js';
|
|
4
|
+
export declare const CreateBucketSchema: z.ZodObject<{
|
|
5
|
+
bucket: z.ZodEffects<z.ZodString, string, string>;
|
|
6
|
+
location: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
bucket: string;
|
|
9
|
+
location?: string | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
bucket: string;
|
|
12
|
+
location?: string | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function createBucketTool(_server: Server, clientFactory: GCSClientFactory): {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: "object";
|
|
19
|
+
properties: {
|
|
20
|
+
bucket: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: "The name of the bucket to create. Must be globally unique, 3-63 characters, lowercase letters, numbers, and hyphens only.";
|
|
23
|
+
};
|
|
24
|
+
location: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: "GCS location for the bucket (e.g., \"US\", \"EU\", \"us-central1\", \"europe-west1\"). Defaults to \"US\".";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
required: string[];
|
|
30
|
+
};
|
|
31
|
+
handler: (args: unknown) => Promise<{
|
|
32
|
+
content: {
|
|
33
|
+
type: string;
|
|
34
|
+
text: string;
|
|
35
|
+
}[];
|
|
36
|
+
isError?: undefined;
|
|
37
|
+
} | {
|
|
38
|
+
content: {
|
|
39
|
+
type: string;
|
|
40
|
+
text: string;
|
|
41
|
+
}[];
|
|
42
|
+
isError: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=create-bucket.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const PARAM_DESCRIPTIONS = {
|
|
3
|
+
bucket: 'The name of the bucket to create. Must be globally unique, 3-63 characters, lowercase letters, numbers, and hyphens only.',
|
|
4
|
+
location: 'GCS location for the bucket (e.g., "US", "EU", "us-central1", "europe-west1"). Defaults to "US".',
|
|
5
|
+
};
|
|
6
|
+
export const CreateBucketSchema = z.object({
|
|
7
|
+
bucket: z
|
|
8
|
+
.string()
|
|
9
|
+
.min(3)
|
|
10
|
+
.max(63)
|
|
11
|
+
// GCS bucket naming rules:
|
|
12
|
+
// - Start and end with lowercase letter or number
|
|
13
|
+
// - Can contain lowercase letters, numbers, hyphens, underscores, and dots
|
|
14
|
+
// - No consecutive dots or periods next to hyphens
|
|
15
|
+
.regex(/^[a-z0-9]([a-z0-9._-]*[a-z0-9])?$/)
|
|
16
|
+
.refine((val) => !/^\d+\.\d+\.\d+\.\d+$/.test(val), {
|
|
17
|
+
message: 'Bucket name cannot be formatted as an IP address',
|
|
18
|
+
})
|
|
19
|
+
.describe(PARAM_DESCRIPTIONS.bucket),
|
|
20
|
+
location: z.string().optional().describe(PARAM_DESCRIPTIONS.location),
|
|
21
|
+
});
|
|
22
|
+
export function createBucketTool(_server, clientFactory) {
|
|
23
|
+
return {
|
|
24
|
+
name: 'create_bucket',
|
|
25
|
+
description: `Create a new GCS bucket.
|
|
26
|
+
|
|
27
|
+
Creates an empty bucket with the specified name in the given location.
|
|
28
|
+
|
|
29
|
+
Example response:
|
|
30
|
+
{
|
|
31
|
+
"success": true,
|
|
32
|
+
"message": "Bucket created: my-new-bucket",
|
|
33
|
+
"bucket": "my-new-bucket"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Bucket naming rules:
|
|
37
|
+
- Must be globally unique across all Google Cloud projects
|
|
38
|
+
- 3-63 characters long
|
|
39
|
+
- Only lowercase letters, numbers, hyphens, underscores, and dots
|
|
40
|
+
- Must start and end with a letter or number
|
|
41
|
+
- Cannot be formatted as an IP address
|
|
42
|
+
|
|
43
|
+
Use cases:
|
|
44
|
+
- Set up storage for a new project
|
|
45
|
+
- Create buckets for different environments
|
|
46
|
+
- Provision storage infrastructure`,
|
|
47
|
+
inputSchema: {
|
|
48
|
+
type: 'object',
|
|
49
|
+
properties: {
|
|
50
|
+
bucket: { type: 'string', description: PARAM_DESCRIPTIONS.bucket },
|
|
51
|
+
location: { type: 'string', description: PARAM_DESCRIPTIONS.location },
|
|
52
|
+
},
|
|
53
|
+
required: ['bucket'],
|
|
54
|
+
},
|
|
55
|
+
handler: async (args) => {
|
|
56
|
+
try {
|
|
57
|
+
const validated = CreateBucketSchema.parse(args);
|
|
58
|
+
const client = clientFactory();
|
|
59
|
+
await client.createBucket(validated.bucket, validated.location);
|
|
60
|
+
return {
|
|
61
|
+
content: [
|
|
62
|
+
{
|
|
63
|
+
type: 'text',
|
|
64
|
+
text: JSON.stringify({
|
|
65
|
+
success: true,
|
|
66
|
+
message: `Bucket created: ${validated.bucket}`,
|
|
67
|
+
bucket: validated.bucket,
|
|
68
|
+
}, null, 2),
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
75
|
+
return {
|
|
76
|
+
content: [{ type: 'text', text: `Error creating bucket: ${message}` }],
|
|
77
|
+
isError: true,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import type { GCSClientFactory } from '../server.js';
|
|
4
|
+
export declare const DeleteBucketSchema: z.ZodObject<{
|
|
5
|
+
bucket: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
bucket: string;
|
|
8
|
+
}, {
|
|
9
|
+
bucket: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function deleteBucketTool(_server: Server, clientFactory: GCSClientFactory): {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: "object";
|
|
16
|
+
properties: {
|
|
17
|
+
bucket: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: "The name of the bucket to delete (e.g., \"my-old-bucket\")";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
required: string[];
|
|
23
|
+
};
|
|
24
|
+
handler: (args: unknown) => Promise<{
|
|
25
|
+
content: {
|
|
26
|
+
type: string;
|
|
27
|
+
text: string;
|
|
28
|
+
}[];
|
|
29
|
+
isError?: undefined;
|
|
30
|
+
} | {
|
|
31
|
+
content: {
|
|
32
|
+
type: string;
|
|
33
|
+
text: string;
|
|
34
|
+
}[];
|
|
35
|
+
isError: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=delete-bucket.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const PARAM_DESCRIPTIONS = {
|
|
3
|
+
bucket: 'The name of the bucket to delete (e.g., "my-old-bucket")',
|
|
4
|
+
};
|
|
5
|
+
export const DeleteBucketSchema = z.object({
|
|
6
|
+
bucket: z.string().min(1).describe(PARAM_DESCRIPTIONS.bucket),
|
|
7
|
+
});
|
|
8
|
+
export function deleteBucketTool(_server, clientFactory) {
|
|
9
|
+
return {
|
|
10
|
+
name: 'delete_bucket',
|
|
11
|
+
description: `Delete a GCS bucket.
|
|
12
|
+
|
|
13
|
+
Permanently removes the specified bucket. The bucket must be empty before deletion.
|
|
14
|
+
|
|
15
|
+
Example response:
|
|
16
|
+
{
|
|
17
|
+
"success": true,
|
|
18
|
+
"message": "Bucket deleted: my-old-bucket"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Use cases:
|
|
22
|
+
- Clean up unused buckets
|
|
23
|
+
- Remove test/temporary buckets
|
|
24
|
+
- Decommission old storage
|
|
25
|
+
|
|
26
|
+
Note: The bucket must be completely empty (no objects) before it can be deleted.`,
|
|
27
|
+
inputSchema: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
bucket: { type: 'string', description: PARAM_DESCRIPTIONS.bucket },
|
|
31
|
+
},
|
|
32
|
+
required: ['bucket'],
|
|
33
|
+
},
|
|
34
|
+
handler: async (args) => {
|
|
35
|
+
try {
|
|
36
|
+
const validated = DeleteBucketSchema.parse(args);
|
|
37
|
+
const client = clientFactory();
|
|
38
|
+
await client.deleteBucket(validated.bucket);
|
|
39
|
+
return {
|
|
40
|
+
content: [
|
|
41
|
+
{
|
|
42
|
+
type: 'text',
|
|
43
|
+
text: JSON.stringify({
|
|
44
|
+
success: true,
|
|
45
|
+
message: `Bucket deleted: ${validated.bucket}`,
|
|
46
|
+
}, null, 2),
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
53
|
+
return {
|
|
54
|
+
content: [{ type: 'text', text: `Error deleting bucket: ${message}` }],
|
|
55
|
+
isError: true,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import type { GCSClientFactory } from '../server.js';
|
|
4
|
+
export declare const DeleteObjectSchema: z.ZodObject<{
|
|
5
|
+
bucket: z.ZodString;
|
|
6
|
+
key: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
bucket: string;
|
|
9
|
+
key: string;
|
|
10
|
+
}, {
|
|
11
|
+
bucket: string;
|
|
12
|
+
key: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function deleteObjectTool(_server: Server, clientFactory: GCSClientFactory): {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: "object";
|
|
19
|
+
properties: {
|
|
20
|
+
bucket: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: "The name of the GCS bucket (e.g., \"my-app-data\")";
|
|
23
|
+
};
|
|
24
|
+
key: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: "The object key (path) to delete (e.g., \"logs/2024/01/old-data.json\")";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
required: string[];
|
|
30
|
+
};
|
|
31
|
+
handler: (args: unknown) => Promise<{
|
|
32
|
+
content: {
|
|
33
|
+
type: string;
|
|
34
|
+
text: string;
|
|
35
|
+
}[];
|
|
36
|
+
isError?: undefined;
|
|
37
|
+
} | {
|
|
38
|
+
content: {
|
|
39
|
+
type: string;
|
|
40
|
+
text: string;
|
|
41
|
+
}[];
|
|
42
|
+
isError: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=delete-object.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const PARAM_DESCRIPTIONS = {
|
|
3
|
+
bucket: 'The name of the GCS bucket (e.g., "my-app-data")',
|
|
4
|
+
key: 'The object key (path) to delete (e.g., "logs/2024/01/old-data.json")',
|
|
5
|
+
};
|
|
6
|
+
export const DeleteObjectSchema = z.object({
|
|
7
|
+
bucket: z.string().min(1).describe(PARAM_DESCRIPTIONS.bucket),
|
|
8
|
+
key: z.string().min(1).describe(PARAM_DESCRIPTIONS.key),
|
|
9
|
+
});
|
|
10
|
+
export function deleteObjectTool(_server, clientFactory) {
|
|
11
|
+
return {
|
|
12
|
+
name: 'delete_object',
|
|
13
|
+
description: `Delete an object from GCS.
|
|
14
|
+
|
|
15
|
+
Permanently removes the specified object from the bucket.
|
|
16
|
+
|
|
17
|
+
Example response:
|
|
18
|
+
{
|
|
19
|
+
"success": true,
|
|
20
|
+
"message": "Object deleted: gs://my-bucket/path/to/file.txt"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Use cases:
|
|
24
|
+
- Remove outdated files
|
|
25
|
+
- Clean up temporary data
|
|
26
|
+
- Delete processed files
|
|
27
|
+
- Remove incorrect uploads
|
|
28
|
+
|
|
29
|
+
Note: This operation is irreversible. For versioned buckets, this creates a delete marker.`,
|
|
30
|
+
inputSchema: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
bucket: { type: 'string', description: PARAM_DESCRIPTIONS.bucket },
|
|
34
|
+
key: { type: 'string', description: PARAM_DESCRIPTIONS.key },
|
|
35
|
+
},
|
|
36
|
+
required: ['bucket', 'key'],
|
|
37
|
+
},
|
|
38
|
+
handler: async (args) => {
|
|
39
|
+
try {
|
|
40
|
+
const validated = DeleteObjectSchema.parse(args);
|
|
41
|
+
const client = clientFactory();
|
|
42
|
+
await client.deleteObject(validated.bucket, validated.key);
|
|
43
|
+
return {
|
|
44
|
+
content: [
|
|
45
|
+
{
|
|
46
|
+
type: 'text',
|
|
47
|
+
text: JSON.stringify({
|
|
48
|
+
success: true,
|
|
49
|
+
message: `Object deleted: gs://${validated.bucket}/${validated.key}`,
|
|
50
|
+
}, null, 2),
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
+
return {
|
|
58
|
+
content: [{ type: 'text', text: `Error deleting object: ${message}` }],
|
|
59
|
+
isError: true,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import type { GCSClientFactory } from '../server.js';
|
|
4
|
+
export declare const GetObjectSchema: z.ZodObject<{
|
|
5
|
+
bucket: z.ZodString;
|
|
6
|
+
key: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
bucket: string;
|
|
9
|
+
key: string;
|
|
10
|
+
}, {
|
|
11
|
+
bucket: string;
|
|
12
|
+
key: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function getObjectTool(_server: Server, clientFactory: GCSClientFactory): {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: "object";
|
|
19
|
+
properties: {
|
|
20
|
+
bucket: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: "The name of the GCS bucket (e.g., \"my-app-data\")";
|
|
23
|
+
};
|
|
24
|
+
key: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: "The object key (path) within the bucket (e.g., \"logs/2024/01/data.json\")";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
required: string[];
|
|
30
|
+
};
|
|
31
|
+
handler: (args: unknown) => Promise<{
|
|
32
|
+
content: {
|
|
33
|
+
type: string;
|
|
34
|
+
text: string;
|
|
35
|
+
}[];
|
|
36
|
+
isError?: undefined;
|
|
37
|
+
} | {
|
|
38
|
+
content: {
|
|
39
|
+
type: string;
|
|
40
|
+
text: string;
|
|
41
|
+
}[];
|
|
42
|
+
isError: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=get-object.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const PARAM_DESCRIPTIONS = {
|
|
3
|
+
bucket: 'The name of the GCS bucket (e.g., "my-app-data")',
|
|
4
|
+
key: 'The object key (path) within the bucket (e.g., "logs/2024/01/data.json")',
|
|
5
|
+
};
|
|
6
|
+
export const GetObjectSchema = z.object({
|
|
7
|
+
bucket: z.string().min(1).describe(PARAM_DESCRIPTIONS.bucket),
|
|
8
|
+
key: z.string().min(1).describe(PARAM_DESCRIPTIONS.key),
|
|
9
|
+
});
|
|
10
|
+
export function getObjectTool(_server, clientFactory) {
|
|
11
|
+
return {
|
|
12
|
+
name: 'get_object',
|
|
13
|
+
description: `Get the contents of an object from GCS.
|
|
14
|
+
|
|
15
|
+
Returns the object content as text along with metadata.
|
|
16
|
+
|
|
17
|
+
Example response:
|
|
18
|
+
{
|
|
19
|
+
"content": "{\\"name\\": \\"example\\", \\"value\\": 123}",
|
|
20
|
+
"contentType": "application/json",
|
|
21
|
+
"contentLength": 35,
|
|
22
|
+
"lastModified": "2024-03-01T10:00:00Z",
|
|
23
|
+
"etag": "\\"abc123\\"",
|
|
24
|
+
"metadata": {"custom-key": "custom-value"}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Use cases:
|
|
28
|
+
- Read configuration files
|
|
29
|
+
- Retrieve JSON data
|
|
30
|
+
- Download text files
|
|
31
|
+
- Access log files
|
|
32
|
+
|
|
33
|
+
Note: This tool reads objects as UTF-8 text. Binary files may not display correctly.`,
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
bucket: { type: 'string', description: PARAM_DESCRIPTIONS.bucket },
|
|
38
|
+
key: { type: 'string', description: PARAM_DESCRIPTIONS.key },
|
|
39
|
+
},
|
|
40
|
+
required: ['bucket', 'key'],
|
|
41
|
+
},
|
|
42
|
+
handler: async (args) => {
|
|
43
|
+
try {
|
|
44
|
+
const validated = GetObjectSchema.parse(args);
|
|
45
|
+
const client = clientFactory();
|
|
46
|
+
const result = await client.getObject(validated.bucket, validated.key);
|
|
47
|
+
return {
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: 'text',
|
|
51
|
+
text: JSON.stringify(result, null, 2),
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
58
|
+
return {
|
|
59
|
+
content: [{ type: 'text', text: `Error getting object: ${message}` }],
|
|
60
|
+
isError: true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import type { GCSClientFactory } from '../server.js';
|
|
4
|
+
export declare const HeadBucketSchema: z.ZodObject<{
|
|
5
|
+
bucket: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
bucket: string;
|
|
8
|
+
}, {
|
|
9
|
+
bucket: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function headBucketTool(_server: Server, clientFactory: GCSClientFactory): {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: "object";
|
|
16
|
+
properties: {
|
|
17
|
+
bucket: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: "The name of the bucket to check (e.g., \"my-bucket\")";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
required: string[];
|
|
23
|
+
};
|
|
24
|
+
handler: (args: unknown) => Promise<{
|
|
25
|
+
content: {
|
|
26
|
+
type: string;
|
|
27
|
+
text: string;
|
|
28
|
+
}[];
|
|
29
|
+
isError?: undefined;
|
|
30
|
+
} | {
|
|
31
|
+
content: {
|
|
32
|
+
type: string;
|
|
33
|
+
text: string;
|
|
34
|
+
}[];
|
|
35
|
+
isError: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=head-bucket.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const PARAM_DESCRIPTIONS = {
|
|
3
|
+
bucket: 'The name of the bucket to check (e.g., "my-bucket")',
|
|
4
|
+
};
|
|
5
|
+
export const HeadBucketSchema = z.object({
|
|
6
|
+
bucket: z.string().min(1).describe(PARAM_DESCRIPTIONS.bucket),
|
|
7
|
+
});
|
|
8
|
+
export function headBucketTool(_server, clientFactory) {
|
|
9
|
+
return {
|
|
10
|
+
name: 'head_bucket',
|
|
11
|
+
description: `Check if a GCS bucket exists and is accessible.
|
|
12
|
+
|
|
13
|
+
Returns whether the bucket exists and the caller has permission to access it.
|
|
14
|
+
|
|
15
|
+
Example response:
|
|
16
|
+
{
|
|
17
|
+
"exists": true,
|
|
18
|
+
"bucket": "my-bucket"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Use cases:
|
|
22
|
+
- Verify bucket exists before operations
|
|
23
|
+
- Check bucket accessibility
|
|
24
|
+
- Validate bucket names`,
|
|
25
|
+
inputSchema: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
bucket: { type: 'string', description: PARAM_DESCRIPTIONS.bucket },
|
|
29
|
+
},
|
|
30
|
+
required: ['bucket'],
|
|
31
|
+
},
|
|
32
|
+
handler: async (args) => {
|
|
33
|
+
try {
|
|
34
|
+
const validated = HeadBucketSchema.parse(args);
|
|
35
|
+
const client = clientFactory();
|
|
36
|
+
const exists = await client.headBucket(validated.bucket);
|
|
37
|
+
return {
|
|
38
|
+
content: [
|
|
39
|
+
{
|
|
40
|
+
type: 'text',
|
|
41
|
+
text: JSON.stringify({
|
|
42
|
+
exists,
|
|
43
|
+
bucket: validated.bucket,
|
|
44
|
+
}, null, 2),
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
51
|
+
return {
|
|
52
|
+
content: [{ type: 'text', text: `Error checking bucket: ${message}` }],
|
|
53
|
+
isError: true,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import type { GCSClientFactory } from '../server.js';
|
|
4
|
+
export declare const ListBucketsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
5
|
+
export declare function listBucketsTool(_server: Server, clientFactory: GCSClientFactory): {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: "object";
|
|
10
|
+
properties: {};
|
|
11
|
+
required: string[];
|
|
12
|
+
};
|
|
13
|
+
handler: (_args: unknown) => Promise<{
|
|
14
|
+
content: {
|
|
15
|
+
type: string;
|
|
16
|
+
text: string;
|
|
17
|
+
}[];
|
|
18
|
+
isError?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
content: {
|
|
21
|
+
type: string;
|
|
22
|
+
text: string;
|
|
23
|
+
}[];
|
|
24
|
+
isError: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=list-buckets.d.ts.map
|