Skip to main content
Glama

download_file

Retrieve files from project storage buckets by specifying project ID, bucket name, and file path to access stored content.

Instructions

Download a file from project storage. Returns the file content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesThe project ID
bucketYesStorage bucket name
pathYesFile path within the bucket

Implementation Reference

  • The main handler function that executes the download_file tool logic. It retrieves the project configuration, makes a GET request to the storage API endpoint, and returns the file content formatted as markdown.
    export async function handleDownloadFile(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: "GET",
        headers: {
          apikey: project.anon_key,
          Authorization: `Bearer ${project.anon_key}`,
        },
      });
    
      if (!res.ok) return formatApiError(res, "downloading file");
    
      const content = typeof res.body === "string" ? res.body : JSON.stringify(res.body, null, 2);
    
      return {
        content: [
          {
            type: "text",
            text: `**${args.bucket}/${args.path}:**\n\n\`\`\`\n${content}\n\`\`\``,
          },
        ],
      };
    }
  • Schema definition using Zod that defines the three required input parameters: project_id, bucket, and path, each with descriptive metadata.
    export const downloadFileSchema = {
      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:116-121 (registration)
    Registration of the download_file tool with the MCP server, associating the tool name, description, schema, and handler function.
    server.tool(
      "download_file",
      "Download a file from project storage. Returns the file content.",
      downloadFileSchema,
      async (args) => handleDownloadFile(args),
    );

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