strands-mongodb-storage
A MongoDB implementation of the Strands Agents unified Storage interface — durable bytes-under-string-keys that backs session snapshots, context offloading, memory stores, and anything else that consumes strands.storage.Storage.
pip install strands-mongodb-storage
from strands.storage import Storage
from strands_mongodb_storage import MongoDBStorage
storage = MongoDBStorage("mongodb://localhost:27017")
assert isinstance(storage, Storage)
await storage.write("sessions/abc/state.json", b"...bytes...")
data = await storage.read("sessions/abc/state.json") # -> bytes | None
keys = await storage.list("sessions/") # sorted, prefix-matched
await storage.delete("sessions/abc/state.json") # no-op if absent
Interface
| Method | Behaviour |
|---|---|
write(key, data) |
Upsert bytes under a /-separated key |
read(key) |
Return the bytes, or None if absent |
delete(key) |
Delete the key (no-op if missing) |
list(prefix) |
Full keys matching the prefix, sorted ascending |
Data model
One document per key: {_id: <key>, data: <BinData>} in a single collection (strands_storage.storage by default). An optional prefix= namespaces all keys. Blocking PyMongo calls run in a thread so the async interface never blocks the event loop.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file strands_mongodb_storage-0.1.0.tar.gz.
File metadata
- Download URL: strands_mongodb_storage-0.1.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9677f89a4bd0e8978dfc696889e2aba35df7fe25e5de96a0b71ab941a80bf86
|
|
| MD5 |
8eff1d9bdbf934534a6091688e4cbd1a
|
|
| BLAKE2b-256 |
ac019ef1854c841acc30ec893cb845720e84eb2e48c2604243a73f2b022e8307
|
File details
Details for the file strands_mongodb_storage-0.1.0-py3-none-any.whl.
File metadata
- Download URL: strands_mongodb_storage-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a2c30287d474cfc94b2a59966001d5d0daea2647f3c1f5c1ef823d5fa2f5854
|
|
| MD5 |
253e1132c51772e7b3b809cefd37e0fb
|
|
| BLAKE2b-256 |
8aaa098c02143eb987575570f3d3ad10612259ee6593b09f2788f88170b39e32
|