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
| 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/download-file.ts:12-42 (handler)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\`\`\``, }, ], }; } - src/tools/download-file.ts:6-10 (schema)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), );