/**
* list_buckets tool implementation
* Lists all storage buckets in the configured source
*/
import { z } from "zod";
import { ProviderManager } from "../providers/manager.js";
import { createToolSuccessResponse, createToolErrorResponse } from "../utils/response-formatter.js";
/**
* Schema for list_buckets tool (no parameters needed)
*/
export const listBucketsSchema = {};
/**
* Get metadata for list_buckets tool
*/
export function getListBucketsMetadata(sourceId: string) {
const toolName = sourceId === "default" ? "list_buckets" : `list_buckets_${sourceId}`;
return {
name: toolName,
title: `List Buckets (${sourceId})`,
description: `List all storage buckets available in the '${sourceId}' source. Returns bucket names, creation dates, and locations.`,
schema: listBucketsSchema,
annotations: {
title: `list_buckets (${sourceId})`,
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
};
}
/**
* Create list_buckets tool handler for a specific source
*/
export function createListBucketsToolHandler(sourceId?: string) {
return async (_args: any, _extra: any) => {
try {
const provider = ProviderManager.getCurrentProvider(sourceId);
const buckets = await provider.listBuckets();
return createToolSuccessResponse({
buckets,
count: buckets.length,
source_id: sourceId || "default",
});
} catch (error) {
return createToolErrorResponse((error as Error).message, "LIST_BUCKETS_ERROR");
}
};
}