Skip to main content
The Supabase resource mounts a Supabase Storage bucket at some prefix such as /supabase/. All operations involve network I/O to the remote object store. Uses aioboto3 against Supabase’s S3-compatible API. For credential setup, see Supabase Setup.

Config

import os

from mirage import MountMode, Workspace
from mirage.resource.supabase import SupabaseConfig, SupabaseResource

config = SupabaseConfig(
    bucket=os.environ["SUPABASE_BUCKET"],
    region=os.environ["SUPABASE_REGION"],
    project_ref=os.environ["SUPABASE_PROJECT_REF"],
    access_key_id=os.environ["SUPABASE_ACCESS_KEY_ID"],
    secret_access_key=os.environ["SUPABASE_SECRET_ACCESS_KEY"],
    # Optional:
    # endpoint_url="https://{project_ref}.storage.supabase.co/storage/v1/s3",
    # session_token="...",
    # timeout=30,
    # proxy="http://proxy:8080",
)
resource = SupabaseResource(config=config)
ws = Workspace({"/supabase": resource}, mode=MountMode.READ)
SupabaseResource(config) takes a SupabaseConfig object with the bucket name, region, and either project_ref (endpoint is auto-built as https://{project_ref}.storage.supabase.co/storage/v1/s3) or an explicit endpoint_url. Both READ and WRITE modes are supported.

Filesystem Layout

The Supabase resource maps object keys to virtual paths under the mount prefix. Supabase “directories” are prefix-based — there are no real directory objects. For example, if bucket my-bucket contains:
avatars/user-001.png
avatars/user-002.png
documents/report.pdf
documents/data.csv
Then mounting at /supabase/ exposes:
/supabase/
  avatars/
    user-001.png
    user-002.png
  documents/
    report.pdf
    data.csv
Path mapping: virtual /supabase/avatars/user-001.png maps to Supabase key avatars/user-001.png.

Cache

The Supabase resource uses IndexCacheStore with index_ttl = 600 (10 minutes). Directory listings are cached for up to 600 seconds before being refreshed from Supabase.

Example

import asyncio
import os

from dotenv import load_dotenv

from mirage import MountMode, Workspace
from mirage.resource.supabase import SupabaseConfig, SupabaseResource

load_dotenv(".env.development")

config = SupabaseConfig(
    bucket=os.environ["SUPABASE_BUCKET"],
    region=os.environ["SUPABASE_REGION"],
    project_ref=os.environ["SUPABASE_PROJECT_REF"],
    access_key_id=os.environ["SUPABASE_ACCESS_KEY_ID"],
    secret_access_key=os.environ["SUPABASE_SECRET_ACCESS_KEY"],
)

resource = SupabaseResource(config=config)


async def main() -> None:
    ws = Workspace({"/supabase/": resource}, mode=MountMode.READ)

    r = await ws.execute("ls /supabase/")
    print(await r.stdout_str())

    r = await ws.execute("cat /supabase/documents/data.csv | head -n 10")
    print(await r.stdout_str())

    r = await ws.execute("tree -L 2 /supabase/")
    print(await r.stdout_str())

    r = await ws.execute("find /supabase/ -name '*.pdf'")
    print(await r.stdout_str())

    r = await ws.execute("stat /supabase/avatars/user-001.png")
    print(await r.stdout_str())


if __name__ == "__main__":
    asyncio.run(main())

Shell Commands

The Supabase resource supports the full set of shell commands since it operates on real file content (text, binary, JSON, CSV, etc.). Large files benefit from range reads to avoid downloading entire objects.

Read Commands

CommandNotes
catRead file content
head / tailFirst/last N lines
grep / rgPattern search (file or directory level)
jqQuery JSON fields
wcLine/word/byte counts
statFile metadata (name, size, type, modified)
findRecursive search with -name, -maxdepth
treeDirectory tree view
nlNumber lines
duDisk usage summary
fileDetect file type
stringsExtract printable strings from binary
xxdHex dump
md5MD5 checksum
sha256sumSHA-256 checksum

Text Processing

CommandNotes
awkPattern scanning and processing
sedStream editor
trTranslate or delete characters
sortSort lines
uniqRemove duplicate lines
cutExtract fields/columns
joinJoin lines on a common field
pasteMerge lines side by side
columnColumnate output
foldWrap lines to a specified width
expandConvert tabs to spaces
unexpandConvert spaces to tabs
fmtSimple text formatter
revReverse lines
tacConcatenate and print in reverse
lookDisplay lines beginning with a given string
shufShuffle lines
tsortTopological sort
commCompare two sorted files
cmpCompare two files byte by byte
diffCompare files line by line
patchApply a diff patch
iconvCharacter encoding conversion

File Operations

CommandNotes
cpCopy files
mvMove/rename files
rmRemove files
mkdirCreate directories
touchCreate empty file or update timestamp
lnCreate symbolic links
teeWrite stdin to file and stdout
mktempCreate temporary file
splitSplit file into pieces
csplitSplit file by context

Path Utilities

CommandNotes
basenameStrip directory from path
dirnameStrip filename from path
realpathResolve path
readlinkPrint symbolic link target
lsList directory contents

Compression

CommandNotes
gzipCompress files
gunzipDecompress gzip files
zipCreate zip archives
unzipExtract zip archives
tarArchive files
zcatCat compressed files
zgrepGrep compressed files

Encoding

CommandNotes
base64Base64 encode/decode

Data Format Support

Commands with format-specific variants for structured data files:
FormatExtensionVariants
Parquet.parquetcat, head, tail, wc, stat, cut, grep, ls, file
Feather.feathercat, head, tail, wc, stat, cut, grep, ls, file
ORC.orccat, head, tail, wc, stat, cut, grep, ls, file
HDF5.hdf5cat, head, tail, wc, stat, cut, grep, ls, file
These variants auto-detect the format by extension and convert to tabular text (CSV) for processing.

Use Cases

  • AI agents accessing Supabase data: Mount Supabase buckets for agents to read and process datasets
  • Data pipelines: Read and write Supabase objects with shell-like commands
  • FUSE mounting: Expose Supabase buckets through a virtual FUSE mount for external tools