Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mongodb-feature-storage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@voltagent/mongodb": minor
---

Initial release of MongoDB memory storage adapter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Initial release of MongoDB memory storage adapter
feat: initial release of MongoDB memory storage adapter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add minimal usage example?

40 changes: 40 additions & 0 deletions packages/mongodb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# @voltagent/mongodb

MongoDB storage adapter for VoltAgent memory.

## Installation

```bash
npm install @voltagent/mongodb
```

## Usage

```typescript
import { MongoDBMemoryAdapter } from "@voltagent/mongodb";
import { Memory } from "@voltagent/core";

const memory = new Memory({
storage: new MongoDBMemoryAdapter({
connection: process.env.MONGO_URI,
database: "voltagent", // optional
collectionPrefix: "voltagent_memory", // optional
}),
});
```

## Features

- **Persistent Storage**: Stores messages, conversations, and workflow states in MongoDB.
- **Efficient Queries**: Indexed for fast retrieval by user, conversation, or date.
- **Type Safe**: Fully typed implementation of the VoltAgent StorageAdapter interface.
- **Workflow Support**: Native support for resuming suspended workflows.

## Configuration

| Option | Type | Default | Description |
| ------------------ | --------- | -------------------- | ---------------------- |
| `connection` | `string` | required | MongoDB connection URI |
| `database` | `string` | `"voltagent"` | Database name |
| `collectionPrefix` | `string` | `"voltagent_memory"` | Prefix for collections |
| `debug` | `boolean` | `false` | Enable debug logging |
18 changes: 18 additions & 0 deletions packages/mongodb/docker-compose.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
services:
mongodb-test:
image: mongo:7.0
container_name: 'voltagent-mongodb-test'
ports:
- '27017:27017'
environment:
MONGO_INITDB_DATABASE: voltagent_test
volumes:
- test_mongodb_data:/data/db
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 2s
timeout: 5s
retries: 10

volumes:
test_mongodb_data:
55 changes: 55 additions & 0 deletions packages/mongodb/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "@voltagent/mongodb",
"description": "VoltAgent MongoDB - MongoDB Memory provider integration for VoltAgent",
"version": "2.0.2",
"dependencies": {
"mongodb": "^7.0.0"
},
"devDependencies": {
"@vitest/coverage-v8": "^3.2.4",
"@voltagent/core": "^2.0.2",
"ai": "^6.0.0"
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"files": [
"dist"
],
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"peerDependencies": {
"@voltagent/core": "^2.0.0",
"ai": "^6.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/VoltAgent/voltagent.git",
"directory": "packages/mongodb"
},
"scripts": {
"attw": "attw --pack",
"build": "tsup",
"dev": "tsup --watch",
"lint": "biome check .",
"lint:fix": "biome check . --write",
"publint": "publint --strict",
"test": "vitest",
"test:coverage": "vitest run --coverage",
"test:integration": "npm run test:integration:setup && vitest run --config vitest.integration.config.mts && npm run test:integration:teardown",
"test:integration:ci": "vitest run --config vitest.integration.config.mts",
"test:integration:setup": "docker compose -f docker-compose.test.yaml up -d && sleep 10",
"test:integration:teardown": "docker compose -f docker-compose.test.yaml down -v"
},
"types": "dist/index.d.ts"
}
Loading