Skip to main content
Glama

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
NameRequiredDescriptionDefault
project_idYesThe project ID
bucketYesStorage bucket name
pathYesFile path within the bucket

Implementation Reference

  • 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.`,
          },
        ],
      };
    }
  • 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";

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kychee-com/run402'

If you have feedback or need assistance with the MCP directory API, please join our Discord server