Metadata-Version: 2.5
Name: strands-mongodb-storage
Version: 0.1.0
Summary: MongoDB implementation of the Strands Agents Storage interface — durable bytes-under-keys for sessions, context offload, and memory
Project-URL: Homepage, https://github.com/skamalj/strands-agents-session
Project-URL: Repository, https://github.com/skamalj/strands-agents-session.git
Author-email: Kamal <skamalj@gmail.com>
Keywords: context-offload,memory,mongodb,session,storage,strands,strands-agents
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: pymongo>=4.0
Requires-Dist: strands-agents>=1.50
Description-Content-Type: text/markdown

# strands-mongodb-storage

A **MongoDB** implementation of the [Strands Agents](https://strandsagents.com) unified `Storage` interface — durable bytes-under-string-keys that backs session snapshots, context offloading, memory stores, and anything else that consumes `strands.storage.Storage`.

```bash
pip install strands-mongodb-storage
```

```python
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
