get_file_url
Generate secure, time-limited download URLs for files stored in Supabase Storage buckets to enable controlled access to stored content.
Instructions
Generate signed download URL for secure file access
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"bucket_name": "<bucket_name>",
"storage_path": "<storage_path>"
},
"name": "get_file_url"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucket_name | Yes | Source bucket | |
| storage_path | Yes | Full file path in storage | |
| expires_in | No | URL expiration in seconds (default: 7200) |
Implementation Reference
- src/index.ts:762-803 (handler)The core handler function that implements the get_file_url tool logic: extracts parameters, generates a signed URL using Supabase storage.createSignedUrl, handles errors, audits the request, and returns the signed URL with expiration info.
async function handleGetFileUrl(args: any, requestId: string, startTime: number) { const { bucket_name, storage_path, expires_in = 7200 } = args; const inputHash = generateSecureHash(JSON.stringify({ bucket_name, storage_path, expires_in })); try { const { data, error } = await supabase.storage .from(bucket_name) .createSignedUrl(storage_path, expires_in); if (error) { throw new Error(`Failed to create signed URL: ${error.message}`); } const expiresAt = new Date(Date.now() + expires_in * 1000).toISOString(); auditRequest('get_file_url', true, inputHash); const result: SignedUrlResult = { signedUrl: data.signedUrl, expiresAt, fileSize: 0, // Would need additional call to get file info mimeType: 'unknown' // Would need additional call to get file info }; return { content: [ { type: 'text', text: JSON.stringify({ ...result, request_id: requestId, processing_time: Date.now() - startTime }, null, 2) } ] }; } catch (error) { auditRequest('get_file_url', false, inputHash, getErrorMessage(error)); throw error; } } - src/index.ts:205-233 (schema)The input schema definition for the get_file_url tool, specifying parameters bucket_name (string), storage_path (string), and optional expires_in (number with constraints).
{ name: 'get_file_url', description: 'Generate signed download URL for secure file access', inputSchema: { type: 'object', properties: { bucket_name: { type: 'string', description: 'Source bucket', minLength: 3, maxLength: 63 }, storage_path: { type: 'string', description: 'Full file path in storage', maxLength: 1024 }, expires_in: { type: 'number', description: 'URL expiration in seconds (default: 7200)', minimum: 60, maximum: 604800, default: 7200 } }, required: ['bucket_name', 'storage_path'], additionalProperties: false } }, - src/index.ts:476-477 (registration)Registration/dispatch in the main CallToolRequestSchema switch statement that routes calls to the get_file_url tool to its handler function.
case 'get_file_url': return await handleGetFileUrl(args, requestId, startTime);