@google-cloud/storage-mcp 0.3.3 → 0.5.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 +2 -1
- package/dist/bundle.js +218 -131
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/bundle.js
CHANGED
|
@@ -4725,6 +4725,7 @@ var require_pattern = __commonJS({
|
|
|
4725
4725
|
"use strict";
|
|
4726
4726
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4727
4727
|
var code_1 = require_code2();
|
|
4728
|
+
var util_1 = require_util();
|
|
4728
4729
|
var codegen_1 = require_codegen();
|
|
4729
4730
|
var error2 = {
|
|
4730
4731
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
|
|
@@ -4737,10 +4738,18 @@ var require_pattern = __commonJS({
|
|
|
4737
4738
|
$data: true,
|
|
4738
4739
|
error: error2,
|
|
4739
4740
|
code(cxt) {
|
|
4740
|
-
const { data, $data, schema, schemaCode, it } = cxt;
|
|
4741
|
+
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
4741
4742
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
4742
|
-
|
|
4743
|
-
|
|
4743
|
+
if ($data) {
|
|
4744
|
+
const { regExp } = it.opts.code;
|
|
4745
|
+
const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
|
|
4746
|
+
const valid = gen.let("valid");
|
|
4747
|
+
gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
|
|
4748
|
+
cxt.fail$data((0, codegen_1._)`!${valid}`);
|
|
4749
|
+
} else {
|
|
4750
|
+
const regExp = (0, code_1.usePattern)(cxt, schema);
|
|
4751
|
+
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
|
|
4752
|
+
}
|
|
4744
4753
|
}
|
|
4745
4754
|
};
|
|
4746
4755
|
exports.default = def;
|
|
@@ -10614,6 +10623,7 @@ var require_pattern2 = __commonJS({
|
|
|
10614
10623
|
"use strict";
|
|
10615
10624
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10616
10625
|
var code_1 = require_code4();
|
|
10626
|
+
var util_1 = require_util2();
|
|
10617
10627
|
var codegen_1 = require_codegen2();
|
|
10618
10628
|
var error2 = {
|
|
10619
10629
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
|
|
@@ -10626,10 +10636,18 @@ var require_pattern2 = __commonJS({
|
|
|
10626
10636
|
$data: true,
|
|
10627
10637
|
error: error2,
|
|
10628
10638
|
code(cxt) {
|
|
10629
|
-
const { data, $data, schema, schemaCode, it } = cxt;
|
|
10639
|
+
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
10630
10640
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
10631
|
-
|
|
10632
|
-
|
|
10641
|
+
if ($data) {
|
|
10642
|
+
const { regExp } = it.opts.code;
|
|
10643
|
+
const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
|
|
10644
|
+
const valid = gen.let("valid");
|
|
10645
|
+
gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
|
|
10646
|
+
cxt.fail$data((0, codegen_1._)`!${valid}`);
|
|
10647
|
+
} else {
|
|
10648
|
+
const regExp = (0, code_1.usePattern)(cxt, schema);
|
|
10649
|
+
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
|
|
10650
|
+
}
|
|
10633
10651
|
}
|
|
10634
10652
|
};
|
|
10635
10653
|
exports.default = def;
|
|
@@ -12462,12 +12480,12 @@ var require_dist = __commonJS({
|
|
|
12462
12480
|
throw new Error(`Unknown format "${name}"`);
|
|
12463
12481
|
return f;
|
|
12464
12482
|
};
|
|
12465
|
-
function addFormats(ajv, list,
|
|
12483
|
+
function addFormats(ajv, list, fs4, exportName) {
|
|
12466
12484
|
var _a2;
|
|
12467
12485
|
var _b2;
|
|
12468
12486
|
(_a2 = (_b2 = ajv.opts.code).formats) !== null && _a2 !== void 0 ? _a2 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
12469
12487
|
for (const f of list)
|
|
12470
|
-
ajv.addFormat(f,
|
|
12488
|
+
ajv.addFormat(f, fs4[f]);
|
|
12471
12489
|
}
|
|
12472
12490
|
module.exports = exports = formatsPlugin;
|
|
12473
12491
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -26316,12 +26334,12 @@ var McpServer = class {
|
|
|
26316
26334
|
}
|
|
26317
26335
|
return registeredPrompt;
|
|
26318
26336
|
}
|
|
26319
|
-
_createRegisteredTool(name, title, description,
|
|
26337
|
+
_createRegisteredTool(name, title, description, inputSchema26, outputSchema, annotations, execution, _meta, handler) {
|
|
26320
26338
|
validateAndWarnToolName(name);
|
|
26321
26339
|
const registeredTool = {
|
|
26322
26340
|
title,
|
|
26323
26341
|
description,
|
|
26324
|
-
inputSchema: getZodSchemaObject(
|
|
26342
|
+
inputSchema: getZodSchemaObject(inputSchema26),
|
|
26325
26343
|
outputSchema: getZodSchemaObject(outputSchema),
|
|
26326
26344
|
annotations,
|
|
26327
26345
|
execution,
|
|
@@ -26372,7 +26390,7 @@ var McpServer = class {
|
|
|
26372
26390
|
throw new Error(`Tool ${name} is already registered`);
|
|
26373
26391
|
}
|
|
26374
26392
|
let description;
|
|
26375
|
-
let
|
|
26393
|
+
let inputSchema26;
|
|
26376
26394
|
let outputSchema;
|
|
26377
26395
|
let annotations;
|
|
26378
26396
|
if (typeof rest[0] === "string") {
|
|
@@ -26381,7 +26399,7 @@ var McpServer = class {
|
|
|
26381
26399
|
if (rest.length > 1) {
|
|
26382
26400
|
const firstArg = rest[0];
|
|
26383
26401
|
if (isZodRawShapeCompat(firstArg)) {
|
|
26384
|
-
|
|
26402
|
+
inputSchema26 = rest.shift();
|
|
26385
26403
|
if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShapeCompat(rest[0])) {
|
|
26386
26404
|
annotations = rest.shift();
|
|
26387
26405
|
}
|
|
@@ -26390,7 +26408,7 @@ var McpServer = class {
|
|
|
26390
26408
|
}
|
|
26391
26409
|
}
|
|
26392
26410
|
const callback = rest[0];
|
|
26393
|
-
return this._createRegisteredTool(name, void 0, description,
|
|
26411
|
+
return this._createRegisteredTool(name, void 0, description, inputSchema26, outputSchema, annotations, { taskSupport: "forbidden" }, void 0, callback);
|
|
26394
26412
|
}
|
|
26395
26413
|
/**
|
|
26396
26414
|
* Registers a tool with a config object and callback.
|
|
@@ -26399,8 +26417,8 @@ var McpServer = class {
|
|
|
26399
26417
|
if (this._registeredTools[name]) {
|
|
26400
26418
|
throw new Error(`Tool ${name} is already registered`);
|
|
26401
26419
|
}
|
|
26402
|
-
const { title, description, inputSchema:
|
|
26403
|
-
return this._createRegisteredTool(name, title, description,
|
|
26420
|
+
const { title, description, inputSchema: inputSchema26, outputSchema, annotations, _meta } = config2;
|
|
26421
|
+
return this._createRegisteredTool(name, title, description, inputSchema26, outputSchema, annotations, { taskSupport: "forbidden" }, _meta, cb);
|
|
26404
26422
|
}
|
|
26405
26423
|
prompt(name, ...rest) {
|
|
26406
26424
|
if (this._registeredPrompts[name]) {
|
|
@@ -26553,6 +26571,89 @@ import { BigQuery } from "@google-cloud/bigquery";
|
|
|
26553
26571
|
import { Storage } from "@google-cloud/storage";
|
|
26554
26572
|
import { ServiceUsageClient } from "@google-cloud/service-usage";
|
|
26555
26573
|
import { StorageInsightsClient } from "@google-cloud/storageinsights";
|
|
26574
|
+
|
|
26575
|
+
// package.json
|
|
26576
|
+
var package_default = {
|
|
26577
|
+
name: "@google-cloud/storage-mcp",
|
|
26578
|
+
version: "0.5.0",
|
|
26579
|
+
type: "module",
|
|
26580
|
+
main: "dist/bundle.js",
|
|
26581
|
+
bin: {
|
|
26582
|
+
"storage-mcp": "./dist/bundle.js"
|
|
26583
|
+
},
|
|
26584
|
+
files: [
|
|
26585
|
+
"dist/"
|
|
26586
|
+
],
|
|
26587
|
+
scripts: {
|
|
26588
|
+
build: "tsc --noemit && node build.js",
|
|
26589
|
+
test: "vitest run",
|
|
26590
|
+
"test:integration": "vitest run --config vitest.config.integration.ts",
|
|
26591
|
+
"test:e2e": "vitest run --config vitest.config.e2e.ts",
|
|
26592
|
+
start: "node dist/bundle.js",
|
|
26593
|
+
lint: "prettier --check . && eslint . --max-warnings 0",
|
|
26594
|
+
fix: "prettier --write . && eslint . --fix",
|
|
26595
|
+
prepare: "npm run build",
|
|
26596
|
+
pretest: "npm run build",
|
|
26597
|
+
posttest: "npm run lint"
|
|
26598
|
+
},
|
|
26599
|
+
repository: {
|
|
26600
|
+
type: "git",
|
|
26601
|
+
url: "https://github.com/googleapis/gcloud-mcp.git",
|
|
26602
|
+
directory: "packages/storage-mcp"
|
|
26603
|
+
},
|
|
26604
|
+
keywords: [
|
|
26605
|
+
"storage",
|
|
26606
|
+
"gcp",
|
|
26607
|
+
"google cloud",
|
|
26608
|
+
"mcp",
|
|
26609
|
+
"mcp server"
|
|
26610
|
+
],
|
|
26611
|
+
license: "Apache-2.0",
|
|
26612
|
+
bugs: {
|
|
26613
|
+
url: "https://github.com/googleapis/gcloud-mcp/issues"
|
|
26614
|
+
},
|
|
26615
|
+
homepage: "https://github.com/googleapis/gcloud-mcp#readme",
|
|
26616
|
+
description: "Model Context Protocol (MCP) Server for interacting with GCS APIs",
|
|
26617
|
+
devDependencies: {
|
|
26618
|
+
"@tsconfig/strictest": "^2.0.5",
|
|
26619
|
+
"@types/mime": "^3.0.4",
|
|
26620
|
+
"@types/mime-types": "^2.1.4",
|
|
26621
|
+
"@types/node": "^24.2.1",
|
|
26622
|
+
"@typescript-eslint/eslint-plugin": "^8.39.0",
|
|
26623
|
+
"@typescript-eslint/parser": "^8.39.0",
|
|
26624
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
26625
|
+
eslint: "^9.32.0",
|
|
26626
|
+
"eslint-config-prettier": "^10.1.8",
|
|
26627
|
+
"eslint-plugin-import": "^2.32.0",
|
|
26628
|
+
"eslint-plugin-license-header": "^0.9.0",
|
|
26629
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
26630
|
+
prettier: "^3.6.2",
|
|
26631
|
+
turbo: "latest",
|
|
26632
|
+
typescript: "^5.9.2",
|
|
26633
|
+
"typescript-eslint": "^8.39.0",
|
|
26634
|
+
vitest: "^3.2.4"
|
|
26635
|
+
},
|
|
26636
|
+
dependencies: {
|
|
26637
|
+
"@google-cloud/bigquery": "^8.0.0",
|
|
26638
|
+
"@google-cloud/service-usage": "^4.2.0",
|
|
26639
|
+
"@google-cloud/storage": "^7.19.0",
|
|
26640
|
+
"@google-cloud/storageinsights": "^2.2.0",
|
|
26641
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
26642
|
+
"@types/yargs": "^17.0.33",
|
|
26643
|
+
chardet: "^2.1.0",
|
|
26644
|
+
"google-auth-library": "^9.11.0",
|
|
26645
|
+
googleapis: "^171.0.0",
|
|
26646
|
+
"iconv-lite": "^0.7.0",
|
|
26647
|
+
"mime-types": "^2.1.35",
|
|
26648
|
+
yargs: "^18.0.0",
|
|
26649
|
+
zod: "^3.25.76"
|
|
26650
|
+
}
|
|
26651
|
+
};
|
|
26652
|
+
|
|
26653
|
+
// src/utility/user_agent.ts
|
|
26654
|
+
var USER_AGENT = `gcloud-storage-mcp/${package_default.version}`;
|
|
26655
|
+
|
|
26656
|
+
// src/utility/api_client_factory.ts
|
|
26556
26657
|
var ApiClientFactory = class _ApiClientFactory {
|
|
26557
26658
|
static instance;
|
|
26558
26659
|
storageClient;
|
|
@@ -26569,7 +26670,7 @@ var ApiClientFactory = class _ApiClientFactory {
|
|
|
26569
26670
|
}
|
|
26570
26671
|
getStorageClient() {
|
|
26571
26672
|
if (!this.storageClient) {
|
|
26572
|
-
this.storageClient = new Storage();
|
|
26673
|
+
this.storageClient = new Storage({ userAgent: USER_AGENT });
|
|
26573
26674
|
}
|
|
26574
26675
|
return this.storageClient;
|
|
26575
26676
|
}
|
|
@@ -26770,7 +26871,7 @@ var inputSchema2 = {
|
|
|
26770
26871
|
async function createBucket(params) {
|
|
26771
26872
|
try {
|
|
26772
26873
|
logger.info(`Creating bucket: ${params.bucket_name} in project: ${params.project_id}`);
|
|
26773
|
-
const storage = new Storage2({ projectId: params.project_id });
|
|
26874
|
+
const storage = new Storage2({ projectId: params.project_id, userAgent: USER_AGENT });
|
|
26774
26875
|
const options = {
|
|
26775
26876
|
location: params.location,
|
|
26776
26877
|
storageClass: params.storage_class || "STANDARD",
|
|
@@ -27051,7 +27152,7 @@ async function listBuckets(params) {
|
|
|
27051
27152
|
"Project ID not specified. Please specify via the project_id parameter or GOOGLE_CLOUD_PROJECT environment variable."
|
|
27052
27153
|
);
|
|
27053
27154
|
}
|
|
27054
|
-
const [buckets] = await storage.getBuckets({
|
|
27155
|
+
const [buckets] = await storage.getBuckets({ project: projectId });
|
|
27055
27156
|
if (!buckets || buckets.length === 0) {
|
|
27056
27157
|
return { content: [{ type: "text", text: "No buckets found." }] };
|
|
27057
27158
|
}
|
|
@@ -27427,8 +27528,71 @@ var registerDownloadObjectTool = (server) => {
|
|
|
27427
27528
|
);
|
|
27428
27529
|
};
|
|
27429
27530
|
|
|
27430
|
-
// src/tools/objects/
|
|
27531
|
+
// src/tools/objects/download_object_safe.ts
|
|
27532
|
+
import fs from "fs";
|
|
27431
27533
|
var inputSchema13 = {
|
|
27534
|
+
bucket_name: external_exports.string().describe("The name of the GCS bucket."),
|
|
27535
|
+
object_name: external_exports.string().describe("The name of the object to download."),
|
|
27536
|
+
file_path: external_exports.string().describe("The local path to save the downloaded file to.")
|
|
27537
|
+
};
|
|
27538
|
+
async function downloadObjectSafe(params) {
|
|
27539
|
+
try {
|
|
27540
|
+
if (fs.existsSync(params.file_path)) {
|
|
27541
|
+
return {
|
|
27542
|
+
content: [
|
|
27543
|
+
{
|
|
27544
|
+
type: "text",
|
|
27545
|
+
text: JSON.stringify({
|
|
27546
|
+
success: false,
|
|
27547
|
+
error: `File already exists at path: ${params.file_path}`,
|
|
27548
|
+
error_type: "AlreadyExists"
|
|
27549
|
+
})
|
|
27550
|
+
}
|
|
27551
|
+
]
|
|
27552
|
+
};
|
|
27553
|
+
}
|
|
27554
|
+
const storage = apiClientFactory.getStorageClient();
|
|
27555
|
+
await storage.bucket(params.bucket_name).file(params.object_name).download({ destination: params.file_path });
|
|
27556
|
+
return {
|
|
27557
|
+
content: [
|
|
27558
|
+
{
|
|
27559
|
+
type: "text",
|
|
27560
|
+
text: JSON.stringify({
|
|
27561
|
+
success: true,
|
|
27562
|
+
message: `Object ${params.object_name} from bucket ${params.bucket_name} downloaded to ${params.file_path}.`
|
|
27563
|
+
})
|
|
27564
|
+
}
|
|
27565
|
+
]
|
|
27566
|
+
};
|
|
27567
|
+
} catch (e) {
|
|
27568
|
+
const error2 = e;
|
|
27569
|
+
logger.error(error2.message);
|
|
27570
|
+
return {
|
|
27571
|
+
content: [
|
|
27572
|
+
{
|
|
27573
|
+
type: "text",
|
|
27574
|
+
text: JSON.stringify({
|
|
27575
|
+
success: false,
|
|
27576
|
+
error: error2.message
|
|
27577
|
+
})
|
|
27578
|
+
}
|
|
27579
|
+
]
|
|
27580
|
+
};
|
|
27581
|
+
}
|
|
27582
|
+
}
|
|
27583
|
+
var registerDownloadObjectSafeTool = (server) => {
|
|
27584
|
+
server.registerTool(
|
|
27585
|
+
"download_object_safe",
|
|
27586
|
+
{
|
|
27587
|
+
description: "Downloads an object from GCS to a local file. Fails if the destination file already exists.",
|
|
27588
|
+
inputSchema: inputSchema13
|
|
27589
|
+
},
|
|
27590
|
+
downloadObjectSafe
|
|
27591
|
+
);
|
|
27592
|
+
};
|
|
27593
|
+
|
|
27594
|
+
// src/tools/objects/list_objects.ts
|
|
27595
|
+
var inputSchema14 = {
|
|
27432
27596
|
bucket_name: external_exports.string().describe("The name of the GCS bucket."),
|
|
27433
27597
|
prefix: external_exports.string().optional().describe("Filters results to objects whose names begin with this prefix."),
|
|
27434
27598
|
delimiter: external_exports.string().optional().describe(
|
|
@@ -27505,14 +27669,14 @@ var registerListObjectsTool = (server) => {
|
|
|
27505
27669
|
"list_objects",
|
|
27506
27670
|
{
|
|
27507
27671
|
description: "Lists the names of objects in a Google Cloud Storage (GCS) bucket. Supports filtering by prefix, directory-like listing with a delimiter, pagination, and listing object versions.",
|
|
27508
|
-
inputSchema:
|
|
27672
|
+
inputSchema: inputSchema14
|
|
27509
27673
|
},
|
|
27510
27674
|
listObjects
|
|
27511
27675
|
);
|
|
27512
27676
|
};
|
|
27513
27677
|
|
|
27514
27678
|
// src/tools/objects/move_object.ts
|
|
27515
|
-
var
|
|
27679
|
+
var inputSchema15 = {
|
|
27516
27680
|
source_bucket_name: external_exports.string().describe("The name of the source GCS bucket."),
|
|
27517
27681
|
source_object_name: external_exports.string().describe("The name of the source object."),
|
|
27518
27682
|
destination_bucket_name: external_exports.string().describe("The name of the destination GCS bucket."),
|
|
@@ -27566,7 +27730,7 @@ var registerMoveObjectTool = (server) => {
|
|
|
27566
27730
|
"move_object",
|
|
27567
27731
|
{
|
|
27568
27732
|
description: "Moves an object from one bucket to another or renames it within the same bucket by copying and deleting the original.",
|
|
27569
|
-
inputSchema:
|
|
27733
|
+
inputSchema: inputSchema15
|
|
27570
27734
|
},
|
|
27571
27735
|
moveObject
|
|
27572
27736
|
);
|
|
@@ -27709,7 +27873,7 @@ function detectBufferType(buffer, contentType, fileName) {
|
|
|
27709
27873
|
|
|
27710
27874
|
// src/tools/objects/read_object_content.ts
|
|
27711
27875
|
var { decode } = iconv;
|
|
27712
|
-
var
|
|
27876
|
+
var inputSchema16 = {
|
|
27713
27877
|
bucket_name: external_exports.string().describe("The name of the GCS bucket."),
|
|
27714
27878
|
object_name: external_exports.string().describe("The name of the object.")
|
|
27715
27879
|
};
|
|
@@ -27844,14 +28008,14 @@ var registerReadObjectContentTool = (server) => {
|
|
|
27844
28008
|
"read_object_content",
|
|
27845
28009
|
{
|
|
27846
28010
|
description: "Reads the content of a specific object.",
|
|
27847
|
-
inputSchema:
|
|
28011
|
+
inputSchema: inputSchema16
|
|
27848
28012
|
},
|
|
27849
28013
|
readObjectContent
|
|
27850
28014
|
);
|
|
27851
28015
|
};
|
|
27852
28016
|
|
|
27853
28017
|
// src/tools/objects/read_object_metadata.ts
|
|
27854
|
-
var
|
|
28018
|
+
var inputSchema17 = {
|
|
27855
28019
|
bucket_name: external_exports.string().describe("The name of the GCS bucket."),
|
|
27856
28020
|
object_name: external_exports.string().describe("The name of the object.")
|
|
27857
28021
|
};
|
|
@@ -27908,14 +28072,14 @@ var registerReadObjectMetadataTool = (server) => {
|
|
|
27908
28072
|
"read_object_metadata",
|
|
27909
28073
|
{
|
|
27910
28074
|
description: "Reads metadata for a specific object.",
|
|
27911
|
-
inputSchema:
|
|
28075
|
+
inputSchema: inputSchema17
|
|
27912
28076
|
},
|
|
27913
28077
|
readObjectMetadata
|
|
27914
28078
|
);
|
|
27915
28079
|
};
|
|
27916
28080
|
|
|
27917
28081
|
// src/tools/objects/update_object_metadata.ts
|
|
27918
|
-
var
|
|
28082
|
+
var inputSchema18 = {
|
|
27919
28083
|
bucket_name: external_exports.string().describe("The name of the GCS bucket."),
|
|
27920
28084
|
object_name: external_exports.string().describe("The name of the object to update."),
|
|
27921
28085
|
metadata: external_exports.record(external_exports.string()).describe("A dictionary of metadata to set on the object.")
|
|
@@ -27969,16 +28133,16 @@ var registerUpdateObjectMetadataTool = (server) => {
|
|
|
27969
28133
|
"update_object_metadata",
|
|
27970
28134
|
{
|
|
27971
28135
|
description: "Updates the metadata of an existing object.",
|
|
27972
|
-
inputSchema:
|
|
28136
|
+
inputSchema: inputSchema18
|
|
27973
28137
|
},
|
|
27974
28138
|
updateObjectMetadata
|
|
27975
28139
|
);
|
|
27976
28140
|
};
|
|
27977
28141
|
|
|
27978
28142
|
// src/tools/objects/upload_object.ts
|
|
27979
|
-
import * as
|
|
28143
|
+
import * as fs2 from "fs";
|
|
27980
28144
|
import * as path2 from "path";
|
|
27981
|
-
var
|
|
28145
|
+
var inputSchema19 = {
|
|
27982
28146
|
bucket_name: external_exports.string().describe("The name of the GCS bucket."),
|
|
27983
28147
|
file_path: external_exports.string().describe("The local path of the file to upload."),
|
|
27984
28148
|
object_name: external_exports.string().optional().describe(
|
|
@@ -27989,7 +28153,7 @@ var inputSchema18 = {
|
|
|
27989
28153
|
async function uploadObject(params) {
|
|
27990
28154
|
try {
|
|
27991
28155
|
logger.info(`Uploading file: ${params.file_path} to bucket: ${params.bucket_name}`);
|
|
27992
|
-
if (!
|
|
28156
|
+
if (!fs2.existsSync(params.file_path)) {
|
|
27993
28157
|
return {
|
|
27994
28158
|
content: [
|
|
27995
28159
|
{
|
|
@@ -28051,15 +28215,15 @@ var registerUploadObjectTool = (server) => {
|
|
|
28051
28215
|
"upload_object",
|
|
28052
28216
|
{
|
|
28053
28217
|
description: "Uploads a file to a GCS bucket.",
|
|
28054
|
-
inputSchema:
|
|
28218
|
+
inputSchema: inputSchema19
|
|
28055
28219
|
},
|
|
28056
28220
|
uploadObject
|
|
28057
28221
|
);
|
|
28058
28222
|
};
|
|
28059
28223
|
|
|
28060
28224
|
// src/tools/objects/upload_object_safe.ts
|
|
28061
|
-
import * as
|
|
28062
|
-
var
|
|
28225
|
+
import * as fs3 from "fs";
|
|
28226
|
+
var inputSchema20 = {
|
|
28063
28227
|
bucket_name: external_exports.string().describe("The name of the GCS bucket."),
|
|
28064
28228
|
file_path: external_exports.string().describe("The local path of the file to upload."),
|
|
28065
28229
|
object_name: external_exports.string().optional().describe(
|
|
@@ -28070,7 +28234,7 @@ var inputSchema19 = {
|
|
|
28070
28234
|
async function uploadObjectSafe(params) {
|
|
28071
28235
|
try {
|
|
28072
28236
|
logger.info(`Uploading safe file: ${params.file_path} to bucket: ${params.bucket_name}`);
|
|
28073
|
-
if (!
|
|
28237
|
+
if (!fs3.existsSync(params.file_path)) {
|
|
28074
28238
|
const errorMsg = `File not found at path: ${params.file_path}`;
|
|
28075
28239
|
logger.error(errorMsg);
|
|
28076
28240
|
return {
|
|
@@ -28093,7 +28257,7 @@ async function uploadObjectSafe(params) {
|
|
|
28093
28257
|
}
|
|
28094
28258
|
const file = bucket.file(objectName, { generation: 0 });
|
|
28095
28259
|
const contentType = params.content_type || getContentType(params.file_path);
|
|
28096
|
-
await file.save(
|
|
28260
|
+
await file.save(fs3.readFileSync(params.file_path), {
|
|
28097
28261
|
contentType
|
|
28098
28262
|
});
|
|
28099
28263
|
const [metadata] = await file.getMetadata();
|
|
@@ -28138,14 +28302,14 @@ var registerUploadObjectSafeTool = (server) => {
|
|
|
28138
28302
|
"upload_object_safe",
|
|
28139
28303
|
{
|
|
28140
28304
|
description: "Uploads a file to a GCS bucket. Fails if the object already exists.",
|
|
28141
|
-
inputSchema:
|
|
28305
|
+
inputSchema: inputSchema20
|
|
28142
28306
|
},
|
|
28143
28307
|
uploadObjectSafe
|
|
28144
28308
|
);
|
|
28145
28309
|
};
|
|
28146
28310
|
|
|
28147
28311
|
// src/tools/objects/write_object.ts
|
|
28148
|
-
var
|
|
28312
|
+
var inputSchema21 = {
|
|
28149
28313
|
bucket_name: external_exports.string().describe("The name of the GCS bucket."),
|
|
28150
28314
|
object_name: external_exports.string().describe("The name of the object to write."),
|
|
28151
28315
|
content: external_exports.string().describe("The content to write to the object, encoded in base64."),
|
|
@@ -28217,14 +28381,14 @@ var registerWriteObjectTool = (server) => {
|
|
|
28217
28381
|
"write_object",
|
|
28218
28382
|
{
|
|
28219
28383
|
description: "Writes a new object to the bucket.",
|
|
28220
|
-
inputSchema:
|
|
28384
|
+
inputSchema: inputSchema21
|
|
28221
28385
|
},
|
|
28222
28386
|
writeObject
|
|
28223
28387
|
);
|
|
28224
28388
|
};
|
|
28225
28389
|
|
|
28226
28390
|
// src/tools/objects/write_object_safe.ts
|
|
28227
|
-
var
|
|
28391
|
+
var inputSchema22 = {
|
|
28228
28392
|
bucket_name: external_exports.string().describe("The name of the GCS bucket."),
|
|
28229
28393
|
object_name: external_exports.string().describe("The name of the object to write."),
|
|
28230
28394
|
content: external_exports.string().describe("The content to write to the object, encoded in base64."),
|
|
@@ -28303,7 +28467,7 @@ var registerWriteObjectSafeTool = (server) => {
|
|
|
28303
28467
|
"write_object_safe",
|
|
28304
28468
|
{
|
|
28305
28469
|
description: "Writes a new object to the bucket. Fails if the object already exists.",
|
|
28306
|
-
inputSchema:
|
|
28470
|
+
inputSchema: inputSchema22
|
|
28307
28471
|
},
|
|
28308
28472
|
writeObjectSafe
|
|
28309
28473
|
);
|
|
@@ -28311,7 +28475,7 @@ var registerWriteObjectSafeTool = (server) => {
|
|
|
28311
28475
|
|
|
28312
28476
|
// src/tools/insights/get_metadata_table_schema.ts
|
|
28313
28477
|
var serviceName = "storageinsights.googleapis.com";
|
|
28314
|
-
var
|
|
28478
|
+
var inputSchema23 = {
|
|
28315
28479
|
datasetConfigName: external_exports.string().describe("The name of the dataset configuration."),
|
|
28316
28480
|
datasetConfigLocation: external_exports.string().describe("The location of the dataset configuration."),
|
|
28317
28481
|
projectId: external_exports.string().optional().describe("The project ID to check Storage Insights availability for.")
|
|
@@ -28545,14 +28709,14 @@ var registerGetMetadataTableSchemaTool = (server) => {
|
|
|
28545
28709
|
"get_metadata_table_schema",
|
|
28546
28710
|
{
|
|
28547
28711
|
description: "Checks if GCS insights service is enabled and returns the BigQuery table schema for a given insights dataset configuration in JSON format. Also returns hints for each column in the table",
|
|
28548
|
-
inputSchema:
|
|
28712
|
+
inputSchema: inputSchema23
|
|
28549
28713
|
},
|
|
28550
28714
|
getMetadataTableSchema
|
|
28551
28715
|
);
|
|
28552
28716
|
};
|
|
28553
28717
|
|
|
28554
28718
|
// src/tools/insights/execute_insights_query.ts
|
|
28555
|
-
var
|
|
28719
|
+
var inputSchema24 = {
|
|
28556
28720
|
config: external_exports.string().describe(
|
|
28557
28721
|
"The JSON object of the BigQuery table schema for a given insights dataset configuration."
|
|
28558
28722
|
),
|
|
@@ -28664,7 +28828,7 @@ var registerExecuteInsightsQueryTool = (server) => {
|
|
|
28664
28828
|
"execute_insights_query",
|
|
28665
28829
|
{
|
|
28666
28830
|
description: "Executes a BigQuery SQL query against an insights dataset and returns the result.",
|
|
28667
|
-
inputSchema:
|
|
28831
|
+
inputSchema: inputSchema24
|
|
28668
28832
|
},
|
|
28669
28833
|
executeInsightsQuery
|
|
28670
28834
|
);
|
|
@@ -28672,7 +28836,7 @@ var registerExecuteInsightsQueryTool = (server) => {
|
|
|
28672
28836
|
|
|
28673
28837
|
// src/tools/insights/list_insights_configs.ts
|
|
28674
28838
|
var serviceName2 = "storageinsights.googleapis.com";
|
|
28675
|
-
var
|
|
28839
|
+
var inputSchema25 = {
|
|
28676
28840
|
projectId: external_exports.string().optional().describe("The project ID to list Storage Insights dataset configurations for.")
|
|
28677
28841
|
};
|
|
28678
28842
|
async function listInsightsConfigs(params) {
|
|
@@ -28737,7 +28901,7 @@ var registerListInsightsConfigsTool = (server) => {
|
|
|
28737
28901
|
"list_insights_configs",
|
|
28738
28902
|
{
|
|
28739
28903
|
description: "Lists the names of all Storage Insights dataset configurations for a given project.",
|
|
28740
|
-
inputSchema:
|
|
28904
|
+
inputSchema: inputSchema25
|
|
28741
28905
|
},
|
|
28742
28906
|
listInsightsConfigs
|
|
28743
28907
|
);
|
|
@@ -28754,7 +28918,7 @@ var commonSafeTools = [
|
|
|
28754
28918
|
registerListObjectsTool,
|
|
28755
28919
|
registerReadObjectContentTool,
|
|
28756
28920
|
registerReadObjectMetadataTool,
|
|
28757
|
-
|
|
28921
|
+
registerDownloadObjectSafeTool,
|
|
28758
28922
|
registerDeleteObjectTool,
|
|
28759
28923
|
registerGetMetadataTableSchemaTool,
|
|
28760
28924
|
registerExecuteInsightsQueryTool,
|
|
@@ -28774,7 +28938,8 @@ var otherDestructiveTools = [
|
|
|
28774
28938
|
registerDeleteBucketTool,
|
|
28775
28939
|
registerUpdateBucketLabelsTool,
|
|
28776
28940
|
registerMoveObjectTool,
|
|
28777
|
-
registerUpdateObjectMetadataTool
|
|
28941
|
+
registerUpdateObjectMetadataTool,
|
|
28942
|
+
registerDownloadObjectTool
|
|
28778
28943
|
];
|
|
28779
28944
|
|
|
28780
28945
|
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
@@ -28869,84 +29034,6 @@ var StdioServerTransport = class {
|
|
|
28869
29034
|
}
|
|
28870
29035
|
};
|
|
28871
29036
|
|
|
28872
|
-
// package.json
|
|
28873
|
-
var package_default = {
|
|
28874
|
-
name: "@google-cloud/storage-mcp",
|
|
28875
|
-
version: "0.3.3",
|
|
28876
|
-
type: "module",
|
|
28877
|
-
main: "dist/bundle.js",
|
|
28878
|
-
bin: {
|
|
28879
|
-
"storage-mcp": "./dist/bundle.js"
|
|
28880
|
-
},
|
|
28881
|
-
files: [
|
|
28882
|
-
"dist/"
|
|
28883
|
-
],
|
|
28884
|
-
scripts: {
|
|
28885
|
-
build: "tsc --noemit && node build.js",
|
|
28886
|
-
test: "vitest run",
|
|
28887
|
-
"test:integration": "vitest run --config vitest.config.integration.ts",
|
|
28888
|
-
"test:e2e": "vitest run --config vitest.config.e2e.ts",
|
|
28889
|
-
start: "node dist/bundle.js",
|
|
28890
|
-
lint: "prettier --check . && eslint . --max-warnings 0",
|
|
28891
|
-
fix: "prettier --write . && eslint . --fix",
|
|
28892
|
-
prepare: "npm run build",
|
|
28893
|
-
pretest: "npm run build",
|
|
28894
|
-
posttest: "npm run lint"
|
|
28895
|
-
},
|
|
28896
|
-
repository: {
|
|
28897
|
-
type: "git",
|
|
28898
|
-
url: "https://github.com/googleapis/gcloud-mcp.git",
|
|
28899
|
-
directory: "packages/storage-mcp"
|
|
28900
|
-
},
|
|
28901
|
-
keywords: [
|
|
28902
|
-
"storage",
|
|
28903
|
-
"gcp",
|
|
28904
|
-
"google cloud",
|
|
28905
|
-
"mcp",
|
|
28906
|
-
"mcp server"
|
|
28907
|
-
],
|
|
28908
|
-
license: "Apache-2.0",
|
|
28909
|
-
bugs: {
|
|
28910
|
-
url: "https://github.com/googleapis/gcloud-mcp/issues"
|
|
28911
|
-
},
|
|
28912
|
-
homepage: "https://github.com/googleapis/gcloud-mcp#readme",
|
|
28913
|
-
description: "Model Context Protocol (MCP) Server for interacting with GCS APIs",
|
|
28914
|
-
devDependencies: {
|
|
28915
|
-
"@tsconfig/strictest": "^2.0.5",
|
|
28916
|
-
"@types/mime": "^3.0.4",
|
|
28917
|
-
"@types/mime-types": "^2.1.4",
|
|
28918
|
-
"@types/node": "^24.2.1",
|
|
28919
|
-
"@typescript-eslint/eslint-plugin": "^8.39.0",
|
|
28920
|
-
"@typescript-eslint/parser": "^8.39.0",
|
|
28921
|
-
"@vitest/coverage-v8": "^3.2.4",
|
|
28922
|
-
eslint: "^9.32.0",
|
|
28923
|
-
"eslint-config-prettier": "^10.1.8",
|
|
28924
|
-
"eslint-plugin-import": "^2.32.0",
|
|
28925
|
-
"eslint-plugin-license-header": "^0.8.0",
|
|
28926
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
28927
|
-
prettier: "^3.6.2",
|
|
28928
|
-
turbo: "latest",
|
|
28929
|
-
typescript: "^5.9.2",
|
|
28930
|
-
"typescript-eslint": "^8.39.0",
|
|
28931
|
-
vitest: "^3.2.4"
|
|
28932
|
-
},
|
|
28933
|
-
dependencies: {
|
|
28934
|
-
"@google-cloud/bigquery": "^8.0.0",
|
|
28935
|
-
"@google-cloud/service-usage": "^4.2.0",
|
|
28936
|
-
"@google-cloud/storage": "^7.17.1",
|
|
28937
|
-
"@google-cloud/storageinsights": "^2.2.0",
|
|
28938
|
-
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
28939
|
-
"@types/yargs": "^17.0.33",
|
|
28940
|
-
chardet: "^2.1.0",
|
|
28941
|
-
"google-auth-library": "^9.11.0",
|
|
28942
|
-
googleapis: "^171.0.0",
|
|
28943
|
-
"iconv-lite": "^0.7.0",
|
|
28944
|
-
"mime-types": "^2.1.35",
|
|
28945
|
-
yargs: "^18.0.0",
|
|
28946
|
-
zod: "^3.25.76"
|
|
28947
|
-
}
|
|
28948
|
-
};
|
|
28949
|
-
|
|
28950
29037
|
// ../../node_modules/yargs/lib/platform-shims/esm.mjs
|
|
28951
29038
|
import { notStrictEqual, strictEqual } from "assert";
|
|
28952
29039
|
|
|
@@ -34314,10 +34401,10 @@ For example, you can use the tools to:
|
|
|
34314
34401
|
## GCS Reference Documentation
|
|
34315
34402
|
|
|
34316
34403
|
If additional context or information is needed on GCS, reference documentation can be found at https://cloud.google.com/storage/docs.`;
|
|
34317
|
-
var initializeGeminiCLI = async (local = false, enableDestructiveTools = false,
|
|
34404
|
+
var initializeGeminiCLI = async (local = false, enableDestructiveTools = false, fs4 = { mkdir, writeFile: writeFile2 }) => {
|
|
34318
34405
|
try {
|
|
34319
34406
|
const extensionDir = join2(os.homedir(), ".gemini", "extensions", "storage-mcp");
|
|
34320
|
-
await
|
|
34407
|
+
await fs4.mkdir(extensionDir, { recursive: true });
|
|
34321
34408
|
const extensionFile = join2(extensionDir, "gemini-extension.json");
|
|
34322
34409
|
const commandArgs = local ? ["-y", "storage-mcp"] : ["-y", "@google-cloud/storage-mcp"];
|
|
34323
34410
|
if (enableDestructiveTools) {
|
|
@@ -34335,10 +34422,10 @@ var initializeGeminiCLI = async (local = false, enableDestructiveTools = false,
|
|
|
34335
34422
|
}
|
|
34336
34423
|
}
|
|
34337
34424
|
};
|
|
34338
|
-
await
|
|
34425
|
+
await fs4.writeFile(extensionFile, JSON.stringify(extensionJson, null, 2));
|
|
34339
34426
|
console.log(`Created: ${extensionFile}`);
|
|
34340
34427
|
const geminiMdDestPath = join2(extensionDir, "GEMINI.md");
|
|
34341
|
-
await
|
|
34428
|
+
await fs4.writeFile(geminiMdDestPath, geminiMdContent);
|
|
34342
34429
|
console.log(`Created: ${geminiMdDestPath}`);
|
|
34343
34430
|
console.log(`\u{1F331} storage-mcp Gemini CLI extension initialized.`);
|
|
34344
34431
|
} catch (err) {
|