Connecting to MongoDB
Agent M makes it easy to connect to your MongoDB databases with secure credential storage and multiple connection options.
Connection Methods
The easiest way to connect is using a MongoDB connection string, which contains all your connection information in one place. A typical connection string looks like mongodb://username:password@host:port/database
. For example, if you're connecting to a local MongoDB instance, you might use mongodb://admin:password123@localhost:27017/mydatabase
.
If you prefer to enter your connection details separately, Agent M also supports individual parameters. You'll need to provide the host address (like localhost
or your server's IP), the port number (usually 27017 for MongoDB), the database name you want to connect to, and your username and password credentials.
Connection Types
Local MongoDB
This is the simplest setup for development work. You'll typically connect to localhost
on port 27017, and authentication is usually not required for local development instances.
MongoDB Atlas
MongoDB's cloud service requires your Atlas cluster connection string along with the username and password you created in Atlas. SSL is usually required and enabled by default for security.
MongoDB Server with Authentication
If you're connecting to a MongoDB server with authentication, you'll need to provide your username and password, along with the specific database you want to authenticate against. This is common in production environments where security is important.
Step-by-Step Connection
When you first open Agent M, you'll see the connection setup screen. Here you can choose between using a connection string (which contains all your connection information in one place) or entering individual parameters (host, port, database, username, and password separately).
After entering your connection details, it's always a good idea to test the connection before saving. Click "Test Connection" to verify that Agent M can successfully connect to your MongoDB instance. If the test is successful, you can save the connection and then select which database you want to work with from the dropdown menu.
Connection Security
Agent M takes security seriously. All your passwords are encrypted and stored locally on your device, so your credentials never leave your computer. The application also remembers your recently used connections locally, making it easy to reconnect without having to re-enter your details every time.
Troubleshooting
Connection Failed
- Check if MongoDB is running
- Verify your connection string format
- Ensure firewall allows MongoDB port (27017)
- Check username/password credentials
Authentication Error
- Verify username and password
- Check if the user has access to the specified database
- Ensure the authentication database is correct
Network Issues
- Check your internet connection (for Atlas)
- Verify the host address is correct
- Check if the port is accessible
Next Steps
Your First AI Query
Learn how to chat with AI using natural language to build MongoDB queries. No syntax knowledge required - just describe what you want in plain English.
Understanding the Interface
Get familiar with Agent M's layout, navigation, and features. Learn about the database explorer, query editor, results area, and conversation tabs.