Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,76 @@ result = agent.tool.elasticsearch_memory(
)
```

### MongoDB Atlas Memory

**Note**: This tool requires AWS account credentials to generate embeddings using Amazon Bedrock Titan models.

```python
from strands import Agent
from strands_tools.mongodb_memory import mongodb_memory

# Create agent with direct tool usage
agent = Agent(tools=[mongodb_memory])

# Store a memory with semantic embeddings
result = agent.tool.mongodb_memory(
action="record",
content="User prefers vegetarian pizza with extra cheese",
metadata={"category": "food_preferences", "type": "dietary"},
cluster_uri="mongodb+srv://user:[email protected]/?retryWrites=true&w=majority",
Copy link
Member

Choose a reason for hiding this comment

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

I believe cluster_uri can be defined upfront (using class based init) so the agents have no access to possible sensitive information like password of cluster

Copy link
Contributor

Choose a reason for hiding this comment

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

we dont need ?retryWrites=true&w=majority and all other places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

database_name="memory_db",
collection_name="memories",
namespace="user_123"
)

# Search memories using semantic similarity (vector search)
result = agent.tool.mongodb_memory(
action="retrieve",
query="food preferences and dietary restrictions",
max_results=5,
cluster_uri="mongodb+srv://user:[email protected]/?retryWrites=true&w=majority",
database_name="memory_db",
collection_name="memories",
namespace="user_123"
)

# Use configuration dictionary for cleaner code
config = {
"cluster_uri": "mongodb+srv://user:[email protected]/?retryWrites=true&w=majority",
"database_name": "memory_db",
"collection_name": "memories",
"namespace": "user_123"
}

# List all memories with pagination
result = agent.tool.mongodb_memory(
action="list",
max_results=10,
**config
)

# Get specific memory by ID
result = agent.tool.mongodb_memory(
action="get",
memory_id="mem_1234567890_abcd1234",
**config
)

# Delete a memory
result = agent.tool.mongodb_memory(
action="delete",
memory_id="mem_1234567890_abcd1234",
**config
)

# Use environment variables for configuration
result = agent.tool.mongodb_memory(
action="record",
content="User prefers vegetarian pizza"
# cluster_uri, database_name, etc. will be read from environment variables
)
```

## 🌍 Environment Variables Configuration

Agents Tools provides extensive customization through environment variables. This allows you to configure tool behavior without modifying code, making it ideal for different environments (development, testing, production).
Expand Down Expand Up @@ -1075,6 +1145,16 @@ The Mem0 Memory Tool supports three different backend configurations:
| STRANDS_RSS_UPDATE_INTERVAL | Default amount of time between updating rss feeds in minutes | 60 |
| STRANDS_RSS_STORAGE_PATH | Default storage path where rss feeds are stored locally | strands_rss_feeds (this may vary based on your system) |

#### MongoDB Atlas Memory Tool

| Environment Variable | Description | Default |
|----------------------|-------------|---------|
| MONGODB_ATLAS_CLUSTER_URI | MongoDB Atlas connection URI | None |
| MONGODB_DATABASE_NAME | Default database name for MongoDB operations | memory_db |
| MONGODB_COLLECTION_NAME | Default collection name for MongoDB operations | memories |
| MONGODB_NAMESPACE | Default namespace for memory isolation | default |
| MONGODB_EMBEDDING_MODEL | Bedrock model for generating embeddings | amazon.titan-embed-text-v2:0 |

#### Video Tools

| Environment Variable | Description | Default |
Expand Down
Loading