A Solace Agent Mesh plugin for natural language querying of MongoDB databases.
Project description
sam-mongodb SAM Plugin
A plugin that provides a MongoDB agent to perform complex queries based on natural language.
This plugin enables Solace Agent Mesh (SAM) agents to interact with MongoDB databases through natural language queries. The agent translates user questions into MongoDB aggregation pipelines and executes them, returning results in various formats.
About Solace Agent Mesh
Solace Agent Mesh (SAM) is an open-source framework for building event-driven, multi-agent AI systems where specialized agents collaborate on complex tasks. It provides a standardized way for agents to communicate, share data, and integrate with external systems while keeping components loosely coupled and production-ready.
SAM helps you:
- Build event-driven multi-agent systems on Solace Event Mesh
- Connect agents, tools, gateways, and services through a common runtime
- Extend projects with installable plugins such as
sam-mongodb
Learn more in the Solace Agent Mesh documentation and the main project repository.
Features
- Natural Language to MongoDB: Converts user queries into MongoDB aggregation pipelines
- Lifecycle Management: Efficient database connection management with initialization and cleanup
- Schema Auto-Detection: Automatically detects and summarizes database schema for better LLM context
- Multiple Output Formats: Supports JSON, YAML, CSV, and Markdown output formats
- Artifact Management: Large results are saved as artifacts for efficient handling
- Configurable Collection Targeting: Can target specific collections or query across all collections
Architecture
The plugin follows a modern, tool-based architecture with clear separation of concerns:
lifecycle.py: Manages agent initialization and cleanup, including database connections and schema detectionsearch_query.py: Contains the mainmongo_querytool that executes aggregation pipelinesservices/database_service.py: Encapsulates all MongoDB operations and connection management
Installation
sam plugin add <your-component-name> --plugin sam-mongodb
This creates a new component configuration at configs/plugins/<your-component-name-kebab-case>.yaml.
Configuration
Environment Variables
Set the following environment variables for your MongoDB connection:
export MONGO_HOST="localhost"
export MONGO_PORT=27017
export MONGO_USER="your_username"
export MONGO_PASSWORD="your_password"
export MONGO_DB="your_database"
export MONGO_COLLECTION="your_collection"
export DB_PURPOSE="Description of your database purpose"
export DB_DESCRIPTION="Detailed description of your data"
Agent Configuration
The plugin uses agent lifecycle functions for efficient resource management. Key configuration sections:
Agent Initialization
agent_init_function:
module: "sam_mongodb.lifecycle"
name: "initialize_mongo_agent"
config:
db_host: "${MONGO_HOST}"
db_port: ${MONGO_PORT}
db_user: "${MONGO_USER}"
db_password: "${MONGO_PASSWORD}"
db_name: "${MONGO_DB}"
database_collection: "${MONGO_COLLECTION}"
database_purpose: "${DB_PURPOSE}"
data_description: "${DB_DESCRIPTION}"
auto_detect_schema: true
max_inline_results: 10
Tool Configuration
tools:
- tool_type: python
component_module: "sam_mongodb.search_query"
function_name: "mongo_query"
tool_config:
collection: "${MONGO_COLLECTION}"
Example Queries
The agent can handle various types of MongoDB queries:
- Aggregation queries: "Show me the top 5 products by sales"
- Filtering: "Find all users registered in the last 30 days"
- Grouping: "Group orders by status and count them"
- Complex pipelines: "Calculate average order value by customer segment"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 sam_mongodb-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sam_mongodb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b596624e8f84b1dab8607e158cfcf421622485ca01cd5270decafa1f167f742
|
|
| MD5 |
3f8496f3e671172a6f460b26f041f738
|
|
| BLAKE2b-256 |
c09b0bf7cfbeab3c723ddb326c112530e7a10b5c58670c96fd845779dd5e7ed9
|
Provenance
The following attestation bundles were made for sam_mongodb-0.1.0-py3-none-any.whl:
Publisher:
release.yaml on SolaceLabs/solace-agent-mesh-core-plugins
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sam_mongodb-0.1.0-py3-none-any.whl -
Subject digest:
4b596624e8f84b1dab8607e158cfcf421622485ca01cd5270decafa1f167f742 - Sigstore transparency entry: 1219400683
- Sigstore integration time:
-
Permalink:
SolaceLabs/solace-agent-mesh-core-plugins@cd412e689d5be369c0072351e589c02e815096d3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/SolaceLabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@cd412e689d5be369c0072351e589c02e815096d3 -
Trigger Event:
workflow_dispatch
-
Statement type: