@google-cloud/storage-mcp 0.5.1 → 0.6.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 CHANGED
@@ -149,7 +149,6 @@ ones. They will never modify or delete existing data in GCS.
149
149
  | `list_objects` | Lists objects in a GCS bucket. |
150
150
  | `read_object_metadata` | Reads comprehensive metadata for a specific object. |
151
151
  | `read_object_content` | Reads the content of a specific object. |
152
- | `download_object_safe` | Downloads an object from GCS to a local file. Fails if the destination file already exists. |
153
152
  | `write_object_new` | Writes a new object. Fails if the object already exists. |
154
153
  | `upload_object_new` | Uploads a file to a new object. Fails if the object already exists. |
155
154
  | `copy_object_new` | Copies an object to a new destination. Fails if the destination already exists. |
package/dist/bundle.js CHANGED
@@ -12480,12 +12480,12 @@ var require_dist = __commonJS({
12480
12480
  throw new Error(`Unknown format "${name}"`);
12481
12481
  return f;
12482
12482
  };
12483
- function addFormats(ajv, list, fs4, exportName) {
12483
+ function addFormats(ajv, list, fs3, exportName) {
12484
12484
  var _a2;
12485
12485
  var _b2;
12486
12486
  (_a2 = (_b2 = ajv.opts.code).formats) !== null && _a2 !== void 0 ? _a2 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
12487
12487
  for (const f of list)
12488
- ajv.addFormat(f, fs4[f]);
12488
+ ajv.addFormat(f, fs3[f]);
12489
12489
  }
12490
12490
  module.exports = exports = formatsPlugin;
12491
12491
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -26334,12 +26334,12 @@ var McpServer = class {
26334
26334
  }
26335
26335
  return registeredPrompt;
26336
26336
  }
26337
- _createRegisteredTool(name, title, description, inputSchema26, outputSchema, annotations, execution, _meta, handler) {
26337
+ _createRegisteredTool(name, title, description, inputSchema25, outputSchema, annotations, execution, _meta, handler) {
26338
26338
  validateAndWarnToolName(name);
26339
26339
  const registeredTool = {
26340
26340
  title,
26341
26341
  description,
26342
- inputSchema: getZodSchemaObject(inputSchema26),
26342
+ inputSchema: getZodSchemaObject(inputSchema25),
26343
26343
  outputSchema: getZodSchemaObject(outputSchema),
26344
26344
  annotations,
26345
26345
  execution,
@@ -26390,7 +26390,7 @@ var McpServer = class {
26390
26390
  throw new Error(`Tool ${name} is already registered`);
26391
26391
  }
26392
26392
  let description;
26393
- let inputSchema26;
26393
+ let inputSchema25;
26394
26394
  let outputSchema;
26395
26395
  let annotations;
26396
26396
  if (typeof rest[0] === "string") {
@@ -26399,7 +26399,7 @@ var McpServer = class {
26399
26399
  if (rest.length > 1) {
26400
26400
  const firstArg = rest[0];
26401
26401
  if (isZodRawShapeCompat(firstArg)) {
26402
- inputSchema26 = rest.shift();
26402
+ inputSchema25 = rest.shift();
26403
26403
  if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShapeCompat(rest[0])) {
26404
26404
  annotations = rest.shift();
26405
26405
  }
@@ -26408,7 +26408,7 @@ var McpServer = class {
26408
26408
  }
26409
26409
  }
26410
26410
  const callback = rest[0];
26411
- return this._createRegisteredTool(name, void 0, description, inputSchema26, outputSchema, annotations, { taskSupport: "forbidden" }, void 0, callback);
26411
+ return this._createRegisteredTool(name, void 0, description, inputSchema25, outputSchema, annotations, { taskSupport: "forbidden" }, void 0, callback);
26412
26412
  }
26413
26413
  /**
26414
26414
  * Registers a tool with a config object and callback.
@@ -26417,8 +26417,8 @@ var McpServer = class {
26417
26417
  if (this._registeredTools[name]) {
26418
26418
  throw new Error(`Tool ${name} is already registered`);
26419
26419
  }
26420
- const { title, description, inputSchema: inputSchema26, outputSchema, annotations, _meta } = config2;
26421
- return this._createRegisteredTool(name, title, description, inputSchema26, outputSchema, annotations, { taskSupport: "forbidden" }, _meta, cb);
26420
+ const { title, description, inputSchema: inputSchema25, outputSchema, annotations, _meta } = config2;
26421
+ return this._createRegisteredTool(name, title, description, inputSchema25, outputSchema, annotations, { taskSupport: "forbidden" }, _meta, cb);
26422
26422
  }
26423
26423
  prompt(name, ...rest) {
26424
26424
  if (this._registeredPrompts[name]) {
@@ -26575,7 +26575,7 @@ import { StorageInsightsClient } from "@google-cloud/storageinsights";
26575
26575
  // package.json
26576
26576
  var package_default = {
26577
26577
  name: "@google-cloud/storage-mcp",
26578
- version: "0.5.1",
26578
+ version: "0.6.0",
26579
26579
  type: "module",
26580
26580
  main: "dist/bundle.js",
26581
26581
  bin: {
@@ -27528,71 +27528,8 @@ var registerDownloadObjectTool = (server) => {
27528
27528
  );
27529
27529
  };
27530
27530
 
27531
- // src/tools/objects/download_object_safe.ts
27532
- import fs from "fs";
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
27531
  // src/tools/objects/list_objects.ts
27595
- var inputSchema14 = {
27532
+ var inputSchema13 = {
27596
27533
  bucket_name: external_exports.string().describe("The name of the GCS bucket."),
27597
27534
  prefix: external_exports.string().optional().describe("Filters results to objects whose names begin with this prefix."),
27598
27535
  delimiter: external_exports.string().optional().describe(
@@ -27669,14 +27606,14 @@ var registerListObjectsTool = (server) => {
27669
27606
  "list_objects",
27670
27607
  {
27671
27608
  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.",
27672
- inputSchema: inputSchema14
27609
+ inputSchema: inputSchema13
27673
27610
  },
27674
27611
  listObjects
27675
27612
  );
27676
27613
  };
27677
27614
 
27678
27615
  // src/tools/objects/move_object.ts
27679
- var inputSchema15 = {
27616
+ var inputSchema14 = {
27680
27617
  source_bucket_name: external_exports.string().describe("The name of the source GCS bucket."),
27681
27618
  source_object_name: external_exports.string().describe("The name of the source object."),
27682
27619
  destination_bucket_name: external_exports.string().describe("The name of the destination GCS bucket."),
@@ -27730,7 +27667,7 @@ var registerMoveObjectTool = (server) => {
27730
27667
  "move_object",
27731
27668
  {
27732
27669
  description: "Moves an object from one bucket to another or renames it within the same bucket by copying and deleting the original.",
27733
- inputSchema: inputSchema15
27670
+ inputSchema: inputSchema14
27734
27671
  },
27735
27672
  moveObject
27736
27673
  );
@@ -27873,7 +27810,7 @@ function detectBufferType(buffer, contentType, fileName) {
27873
27810
 
27874
27811
  // src/tools/objects/read_object_content.ts
27875
27812
  var { decode } = iconv;
27876
- var inputSchema16 = {
27813
+ var inputSchema15 = {
27877
27814
  bucket_name: external_exports.string().describe("The name of the GCS bucket."),
27878
27815
  object_name: external_exports.string().describe("The name of the object.")
27879
27816
  };
@@ -28008,14 +27945,14 @@ var registerReadObjectContentTool = (server) => {
28008
27945
  "read_object_content",
28009
27946
  {
28010
27947
  description: "Reads the content of a specific object.",
28011
- inputSchema: inputSchema16
27948
+ inputSchema: inputSchema15
28012
27949
  },
28013
27950
  readObjectContent
28014
27951
  );
28015
27952
  };
28016
27953
 
28017
27954
  // src/tools/objects/read_object_metadata.ts
28018
- var inputSchema17 = {
27955
+ var inputSchema16 = {
28019
27956
  bucket_name: external_exports.string().describe("The name of the GCS bucket."),
28020
27957
  object_name: external_exports.string().describe("The name of the object.")
28021
27958
  };
@@ -28072,14 +28009,14 @@ var registerReadObjectMetadataTool = (server) => {
28072
28009
  "read_object_metadata",
28073
28010
  {
28074
28011
  description: "Reads metadata for a specific object.",
28075
- inputSchema: inputSchema17
28012
+ inputSchema: inputSchema16
28076
28013
  },
28077
28014
  readObjectMetadata
28078
28015
  );
28079
28016
  };
28080
28017
 
28081
28018
  // src/tools/objects/update_object_metadata.ts
28082
- var inputSchema18 = {
28019
+ var inputSchema17 = {
28083
28020
  bucket_name: external_exports.string().describe("The name of the GCS bucket."),
28084
28021
  object_name: external_exports.string().describe("The name of the object to update."),
28085
28022
  metadata: external_exports.record(external_exports.string()).describe("A dictionary of metadata to set on the object.")
@@ -28133,16 +28070,16 @@ var registerUpdateObjectMetadataTool = (server) => {
28133
28070
  "update_object_metadata",
28134
28071
  {
28135
28072
  description: "Updates the metadata of an existing object.",
28136
- inputSchema: inputSchema18
28073
+ inputSchema: inputSchema17
28137
28074
  },
28138
28075
  updateObjectMetadata
28139
28076
  );
28140
28077
  };
28141
28078
 
28142
28079
  // src/tools/objects/upload_object.ts
28143
- import * as fs2 from "fs";
28080
+ import * as fs from "fs";
28144
28081
  import * as path2 from "path";
28145
- var inputSchema19 = {
28082
+ var inputSchema18 = {
28146
28083
  bucket_name: external_exports.string().describe("The name of the GCS bucket."),
28147
28084
  file_path: external_exports.string().describe("The local path of the file to upload."),
28148
28085
  object_name: external_exports.string().optional().describe(
@@ -28153,7 +28090,7 @@ var inputSchema19 = {
28153
28090
  async function uploadObject(params) {
28154
28091
  try {
28155
28092
  logger.info(`Uploading file: ${params.file_path} to bucket: ${params.bucket_name}`);
28156
- if (!fs2.existsSync(params.file_path)) {
28093
+ if (!fs.existsSync(params.file_path)) {
28157
28094
  return {
28158
28095
  content: [
28159
28096
  {
@@ -28215,15 +28152,15 @@ var registerUploadObjectTool = (server) => {
28215
28152
  "upload_object",
28216
28153
  {
28217
28154
  description: "Uploads a file to a GCS bucket.",
28218
- inputSchema: inputSchema19
28155
+ inputSchema: inputSchema18
28219
28156
  },
28220
28157
  uploadObject
28221
28158
  );
28222
28159
  };
28223
28160
 
28224
28161
  // src/tools/objects/upload_object_safe.ts
28225
- import * as fs3 from "fs";
28226
- var inputSchema20 = {
28162
+ import * as fs2 from "fs";
28163
+ var inputSchema19 = {
28227
28164
  bucket_name: external_exports.string().describe("The name of the GCS bucket."),
28228
28165
  file_path: external_exports.string().describe("The local path of the file to upload."),
28229
28166
  object_name: external_exports.string().optional().describe(
@@ -28234,7 +28171,7 @@ var inputSchema20 = {
28234
28171
  async function uploadObjectSafe(params) {
28235
28172
  try {
28236
28173
  logger.info(`Uploading safe file: ${params.file_path} to bucket: ${params.bucket_name}`);
28237
- if (!fs3.existsSync(params.file_path)) {
28174
+ if (!fs2.existsSync(params.file_path)) {
28238
28175
  const errorMsg = `File not found at path: ${params.file_path}`;
28239
28176
  logger.error(errorMsg);
28240
28177
  return {
@@ -28257,7 +28194,7 @@ async function uploadObjectSafe(params) {
28257
28194
  }
28258
28195
  const file = bucket.file(objectName, { generation: 0 });
28259
28196
  const contentType = params.content_type || getContentType(params.file_path);
28260
- await file.save(fs3.readFileSync(params.file_path), {
28197
+ await file.save(fs2.readFileSync(params.file_path), {
28261
28198
  contentType
28262
28199
  });
28263
28200
  const [metadata] = await file.getMetadata();
@@ -28302,14 +28239,14 @@ var registerUploadObjectSafeTool = (server) => {
28302
28239
  "upload_object_safe",
28303
28240
  {
28304
28241
  description: "Uploads a file to a GCS bucket. Fails if the object already exists.",
28305
- inputSchema: inputSchema20
28242
+ inputSchema: inputSchema19
28306
28243
  },
28307
28244
  uploadObjectSafe
28308
28245
  );
28309
28246
  };
28310
28247
 
28311
28248
  // src/tools/objects/write_object.ts
28312
- var inputSchema21 = {
28249
+ var inputSchema20 = {
28313
28250
  bucket_name: external_exports.string().describe("The name of the GCS bucket."),
28314
28251
  object_name: external_exports.string().describe("The name of the object to write."),
28315
28252
  content: external_exports.string().describe("The content to write to the object, encoded in base64."),
@@ -28381,14 +28318,14 @@ var registerWriteObjectTool = (server) => {
28381
28318
  "write_object",
28382
28319
  {
28383
28320
  description: "Writes a new object to the bucket.",
28384
- inputSchema: inputSchema21
28321
+ inputSchema: inputSchema20
28385
28322
  },
28386
28323
  writeObject
28387
28324
  );
28388
28325
  };
28389
28326
 
28390
28327
  // src/tools/objects/write_object_safe.ts
28391
- var inputSchema22 = {
28328
+ var inputSchema21 = {
28392
28329
  bucket_name: external_exports.string().describe("The name of the GCS bucket."),
28393
28330
  object_name: external_exports.string().describe("The name of the object to write."),
28394
28331
  content: external_exports.string().describe("The content to write to the object, encoded in base64."),
@@ -28467,7 +28404,7 @@ var registerWriteObjectSafeTool = (server) => {
28467
28404
  "write_object_safe",
28468
28405
  {
28469
28406
  description: "Writes a new object to the bucket. Fails if the object already exists.",
28470
- inputSchema: inputSchema22
28407
+ inputSchema: inputSchema21
28471
28408
  },
28472
28409
  writeObjectSafe
28473
28410
  );
@@ -28475,7 +28412,7 @@ var registerWriteObjectSafeTool = (server) => {
28475
28412
 
28476
28413
  // src/tools/insights/get_metadata_table_schema.ts
28477
28414
  var serviceName = "storageinsights.googleapis.com";
28478
- var inputSchema23 = {
28415
+ var inputSchema22 = {
28479
28416
  datasetConfigName: external_exports.string().describe("The name of the dataset configuration."),
28480
28417
  datasetConfigLocation: external_exports.string().describe("The location of the dataset configuration."),
28481
28418
  projectId: external_exports.string().optional().describe("The project ID to check Storage Insights availability for.")
@@ -28709,14 +28646,14 @@ var registerGetMetadataTableSchemaTool = (server) => {
28709
28646
  "get_metadata_table_schema",
28710
28647
  {
28711
28648
  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",
28712
- inputSchema: inputSchema23
28649
+ inputSchema: inputSchema22
28713
28650
  },
28714
28651
  getMetadataTableSchema
28715
28652
  );
28716
28653
  };
28717
28654
 
28718
28655
  // src/tools/insights/execute_insights_query.ts
28719
- var inputSchema24 = {
28656
+ var inputSchema23 = {
28720
28657
  config: external_exports.string().describe(
28721
28658
  "The JSON object of the BigQuery table schema for a given insights dataset configuration."
28722
28659
  ),
@@ -28828,7 +28765,7 @@ var registerExecuteInsightsQueryTool = (server) => {
28828
28765
  "execute_insights_query",
28829
28766
  {
28830
28767
  description: "Executes a BigQuery SQL query against an insights dataset and returns the result.",
28831
- inputSchema: inputSchema24
28768
+ inputSchema: inputSchema23
28832
28769
  },
28833
28770
  executeInsightsQuery
28834
28771
  );
@@ -28836,7 +28773,7 @@ var registerExecuteInsightsQueryTool = (server) => {
28836
28773
 
28837
28774
  // src/tools/insights/list_insights_configs.ts
28838
28775
  var serviceName2 = "storageinsights.googleapis.com";
28839
- var inputSchema25 = {
28776
+ var inputSchema24 = {
28840
28777
  projectId: external_exports.string().optional().describe("The project ID to list Storage Insights dataset configurations for.")
28841
28778
  };
28842
28779
  async function listInsightsConfigs(params) {
@@ -28901,7 +28838,7 @@ var registerListInsightsConfigsTool = (server) => {
28901
28838
  "list_insights_configs",
28902
28839
  {
28903
28840
  description: "Lists the names of all Storage Insights dataset configurations for a given project.",
28904
- inputSchema: inputSchema25
28841
+ inputSchema: inputSchema24
28905
28842
  },
28906
28843
  listInsightsConfigs
28907
28844
  );
@@ -28918,7 +28855,6 @@ var commonSafeTools = [
28918
28855
  registerListObjectsTool,
28919
28856
  registerReadObjectContentTool,
28920
28857
  registerReadObjectMetadataTool,
28921
- registerDownloadObjectSafeTool,
28922
28858
  registerGetMetadataTableSchemaTool,
28923
28859
  registerExecuteInsightsQueryTool,
28924
28860
  registerListInsightsConfigsTool
@@ -34401,10 +34337,10 @@ For example, you can use the tools to:
34401
34337
  ## GCS Reference Documentation
34402
34338
 
34403
34339
  If additional context or information is needed on GCS, reference documentation can be found at https://cloud.google.com/storage/docs.`;
34404
- var initializeGeminiCLI = async (local = false, enableDestructiveTools = false, fs4 = { mkdir, writeFile: writeFile2 }) => {
34340
+ var initializeGeminiCLI = async (local = false, enableDestructiveTools = false, fs3 = { mkdir, writeFile: writeFile2 }) => {
34405
34341
  try {
34406
34342
  const extensionDir = join2(os.homedir(), ".gemini", "extensions", "storage-mcp");
34407
- await fs4.mkdir(extensionDir, { recursive: true });
34343
+ await fs3.mkdir(extensionDir, { recursive: true });
34408
34344
  const extensionFile = join2(extensionDir, "gemini-extension.json");
34409
34345
  const commandArgs = local ? ["-y", "storage-mcp"] : ["-y", "@google-cloud/storage-mcp"];
34410
34346
  if (enableDestructiveTools) {
@@ -34422,10 +34358,10 @@ var initializeGeminiCLI = async (local = false, enableDestructiveTools = false,
34422
34358
  }
34423
34359
  }
34424
34360
  };
34425
- await fs4.writeFile(extensionFile, JSON.stringify(extensionJson, null, 2));
34361
+ await fs3.writeFile(extensionFile, JSON.stringify(extensionJson, null, 2));
34426
34362
  console.log(`Created: ${extensionFile}`);
34427
34363
  const geminiMdDestPath = join2(extensionDir, "GEMINI.md");
34428
- await fs4.writeFile(geminiMdDestPath, geminiMdContent);
34364
+ await fs3.writeFile(geminiMdDestPath, geminiMdContent);
34429
34365
  console.log(`Created: ${geminiMdDestPath}`);
34430
34366
  console.log(`\u{1F331} storage-mcp Gemini CLI extension initialized.`);
34431
34367
  } catch (err) {