Skip to main content

A fast, ergonomic workspace in the cloud for AI agents — backed by Hugging Face Storage Buckets.

Project description

membase

A fast, ergonomic workspace in the cloud for AI agents.

membase gives AI agents a filesystem interface backed by Hugging Face Storage Buckets — designed from the ground up for tool-calling agents that need to read, write, search, and organize files in persistent cloud storage.

from membase import Workspace

ws = Workspace("my-project")
ws.write("hello.txt", "Hello from membase.")
print(ws.read("hello.txt"))

Why membase?

AI agents already have great filesystem tools on local machines — Read, Write, Glob, Grep. But when agents need persistent, shareable, cloud-native storage, they get raw APIs designed for human developers: long bucket URIs, manual grep loops, no batching, no parallelism.

membase closes this gap with:

  • One line to start. ws = Workspace("my-project") — auth is automatic, the bucket is created if needed.
  • Familiar vocabulary. read, write, ls, glob, grep, tree, mv, cp, rm — the same operations agents already know.
  • Parallel reads. Multi-file operations use 16 concurrent workers by default — 16x faster than sequential reads.
  • Batched writes. write_many() sends any number of files in a single network call (~700ms whether it's 1 file or 200).
  • Token-efficient output. Short paths, compact tree views, bounded search results — designed to minimize context window cost.
  • Agent-friendly errors. Exceptions include suggestions for what to do next, so agents can self-correct.

Installation

pip install membase

Requires Python 3.9+ and a Hugging Face account with an API token.

Authentication

membase discovers credentials automatically:

# Option 1: environment variable
export HF_TOKEN=hf_your_token_here

# Option 2: CLI login (stores token locally)
pip install huggingface_hub
huggingface-cli login

Quick Start

Create a workspace and write files

from membase import Workspace

ws = Workspace("my-project")

# Write a single file (parent directories created automatically)
ws.write("src/main.py", "def main():\n    print('hello')\n")

# Write multiple files in one network call
ws.write_many({
    "src/__init__.py": "",
    "src/utils.py": "def helper():\n    pass\n",
    "tests/test_main.py": "def test_main():\n    assert True\n",
})

Explore the workspace

# ASCII tree view
print(ws.tree())

# List a directory
for entry in ws.ls("src/"):
    print(entry)

# Find files by pattern
py_files = ws.glob("**/*.py")

Search file contents

# Search across all Python files
results = ws.grep("def main", include="*.py")
for match in results:
    print(f"{match.path}:{match.line_number}: {match.line}")

Read and edit files

# Read a file
content = ws.read("src/main.py")

# Read just the first 10 lines of a large file
head = ws.read("data/large.csv", head=10)

# Find-and-replace (no need to read the whole file into context)
ws.edit("src/main.py", old="print('hello')", new="print('goodbye')")

API Overview

Operation Method Description
Read ws.read(path) Read a file as string
Write ws.write(path, content) Create or overwrite a file
Batch write ws.write_many({path: content, ...}) Write multiple files (one network call)
Edit ws.edit(path, old=..., new=...) Find-and-replace within a file
Append ws.append(path, content) Append to an existing file
List ws.ls(path) List directory contents
Tree ws.tree() ASCII tree of the workspace
Glob ws.glob(pattern) Find files by pattern
Grep ws.grep(pattern) Search inside file contents
Exists ws.exists(path) Check if a path exists
Stat ws.stat(path) File metadata (size, modified time)
Delete ws.rm(path) Delete a file or directory
Move ws.mv(src, dst) Move or rename
Copy ws.cp(src, dst) Copy within workspace
Info ws.info() Workspace metadata

Design Principles

  • Token-efficient. Every API surface minimizes context window cost.
  • Network-aware. Parallel reads, batched writes, aggressive caching.
  • One dependency. Only huggingface_hub is required.
  • Agent-first. Structured returns, compact repr, actionable errors.

License

MIT — see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

membase-0.0.1.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

membase-0.0.1-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file membase-0.0.1.tar.gz.

File metadata

  • Download URL: membase-0.0.1.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for membase-0.0.1.tar.gz
Algorithm Hash digest
SHA256 4aa1d8b82ecdee54342adc01c9ef141a6456bf921921b922f98a320cf3dcaf4f
MD5 245748c55c89286f395d33036e016e7e
BLAKE2b-256 931cca09d341d28c3a741c168a90183234bb7a0bfff63c8e0289972eb2b6d7b4

See more details on using hashes here.

File details

Details for the file membase-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: membase-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for membase-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9ab4179e4c3e233c453bb111f5ddabf7c8364cf52d53e6fc7264ccb43dd033d7
MD5 051d25ff4bcb258c8fc0c53c81acc7bf
BLAKE2b-256 c32dbe3ffdb2dfb04be93b3c78450eb666bf33bc08aee3a269754bebd7b4658b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page