delete_file
Remove files from project storage by specifying project ID, bucket name, and file path to manage storage resources effectively.
Instructions
Delete a file from project storage.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | The project ID | |
| bucket | Yes | Storage bucket name | |
| path | Yes | File path within the bucket |
Implementation Reference
- src/tools/delete-file.ts:12-40 (handler)The handleDeleteFile async function that executes the delete_file tool logic. It validates the project exists, constructs the API path, makes a DELETE request to the storage API, and returns a success message or error.
export async function handleDeleteFile(args: { project_id: string; bucket: string; path: string; }): Promise<{ content: Array<{ type: "text"; text: string }>; isError?: boolean }> { const project = getProject(args.project_id); if (!project) return projectNotFound(args.project_id); const apiPath = `/storage/v1/object/${args.bucket}/${args.path}`; const res = await apiRequest(apiPath, { method: "DELETE", headers: { apikey: project.anon_key, Authorization: `Bearer ${project.anon_key}`, }, }); if (!res.ok) return formatApiError(res, "deleting file"); return { content: [ { type: "text", text: `File \`${args.bucket}/${args.path}\` deleted.`, }, ], }; } - src/tools/delete-file.ts:6-10 (schema)The deleteFileSchema object defining the input parameters for the delete_file tool: project_id (string), bucket (string), and path (string).
export const deleteFileSchema = { project_id: z.string().describe("The project ID"), bucket: z.string().describe("Storage bucket name"), path: z.string().describe("File path within the bucket"), }; - src/index.ts:123-128 (registration)Registration of the 'delete_file' tool with the MCP server, binding the schema and handler function.
server.tool( "delete_file", "Delete a file from project storage.", deleteFileSchema, async (args) => handleDeleteFile(args), ); - src/index.ts:34-34 (registration)Import statement that brings in deleteFileSchema and handleDeleteFile from the tools/delete-file.js module.
import { deleteFileSchema, handleDeleteFile } from "./tools/delete-file.js";