Skip to content

Commit 4089fb9

Browse files
authored
Add MongoDB connection page (#173)
* add mongodb connection page * updates
1 parent 774791a commit 4089fb9

File tree

15 files changed

+310
-1
lines changed

15 files changed

+310
-1
lines changed

agents/available-connections.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,31 @@ agent card for the full list.
201201
</div>
202202
Weaviate is an open‑source vector database.
203203
</Card>
204+
<Card>
205+
<div className="flex items-center gap-2">
206+
<img
207+
src="/images/agents/connections/icons/mongodb.svg"
208+
alt="MongoDB"
209+
width={24}
210+
height={24}
211+
/>
212+
<span className="text-lg font-semibold">MongoDB</span>
213+
</div>
214+
MongoDB is an open source NoSQL database management program.
215+
<div className="mt-4 flex items-center justify-between">
216+
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">
217+
8 tools
218+
</span>
219+
220+
<a
221+
href="/agents/connections/mongodb"
222+
className="px-3 py-1 bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600 dark:text-gray-200 rounded"
223+
>
224+
Details
225+
</a>
226+
</div>
227+
228+
</Card>
204229
</CardGroup>
205230

206231
### Development tools

agents/connections/mongodb.mdx

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
---
2+
title: Using MongoDB with Hypermode
3+
sidebarTitle: MongoDB
4+
description:
5+
Connect your Hypermode agent to MongoDB for scalable document database
6+
operations
7+
---
8+
9+
<div className="flex items-center gap-3 mb-6">
10+
<img
11+
src="/images/agents/connections/icons/mongodb.svg"
12+
alt="MongoDB"
13+
width={48}
14+
height={48}
15+
/>
16+
<div>
17+
<h2 className="text-2xl font-bold m-0">MongoDB</h2>
18+
<p className="text-gray-600 m-0">
19+
Document-oriented NoSQL database platform
20+
</p>
21+
</div>
22+
</div>
23+
24+
## Overview
25+
26+
MongoDB is a popular NoSQL document database that provides flexible schema
27+
design and powerful querying capabilities. This guide will walk you through
28+
connecting your Hypermode agent to MongoDB, enabling seamless document
29+
operations and data management for your applications.
30+
31+
## Prerequisites
32+
33+
Before connecting MongoDB to Hypermode, you'll need:
34+
35+
1. A [MongoDB Atlas account](https://www.mongodb.com/cloud/atlas) or local
36+
MongoDB installation
37+
2. A MongoDB database with connection credentials
38+
3. A [Hypermode workspace](https://hypermode.com/)
39+
40+
## Setting up MongoDB
41+
42+
### Step 1: Create your MongoDB Atlas account
43+
44+
If you haven't already, sign up for a
45+
[free MongoDB Atlas account](https://www.mongodb.com/cloud/atlas) to get started
46+
with cloud-hosted MongoDB.
47+
48+
### Step 2: Create a cluster and database
49+
50+
1. Create a new cluster in MongoDB Atlas
51+
2. Set up database access credentials
52+
3. Configure network access (whitelist IP addresses)
53+
4. Create your first database and collection
54+
55+
Check the box to load sample data. This will create a movies database with
56+
sample data in several collections.
57+
58+
![Create MongoDB cluster](/images/connections/mongodb/create-cluster.png)
59+
60+
You'll also need to create a user and password for your database.
61+
62+
![Create MongoDB user](/images/connections/mongodb/create-user.png)
63+
64+
### Step 3: Generate connection string
65+
66+
Navigate to your cluster and get the connection string:
67+
68+
1. Click "Connect" on your cluster
69+
2. Choose "Connect"
70+
3. Copy the connection string and replace `<password>` with your database user
71+
password. You'll use this connection string to connect your Hypermode agent
72+
to MongoDB.
73+
74+
![MongoDB connection string](/images/connections/mongodb/connection-string.png)
75+
76+
<Note>
77+
Your connection string will look like:
78+
`mongodb+srv://username:[email protected]/database?retryWrites=true&w=majority`
79+
</Note>
80+
81+
### Step 4: Whitelist IP addresses
82+
83+
Navigate to your cluster and whitelist IP addresses to allow connections from
84+
your Hypermode agent:
85+
86+
1. Click "Network Access" on your cluster
87+
2. Add the IP address range `0.0.0.0/0` to allow connections from any IP address
88+
89+
![Whitelist IP addresses](/images/connections/mongodb/mongodb-connection-ip-address.png)
90+
91+
## Creating your MongoDB agent
92+
93+
### Step 1: Create a new agent
94+
95+
From the Hypermode interface, create a new agent manually:
96+
97+
1. Click the agent dropdown menu
98+
2. Select "Create new Agent"
99+
100+
### Step 2: Configure agent settings
101+
102+
Use these recommended settings for your MongoDB agent:
103+
104+
- **Agent Name**: MongoAgent
105+
- **Agent Title**: Connects to MongoDB
106+
- **Description**: MongoAgent manages document operations
107+
- **Instructions**: You have a connection to MongoDB and various other developer
108+
tools to streamline document data access and management. You can perform CRUD
109+
operations, aggregations, and complex queries on MongoDB collections.
110+
- **Model**: GPT-4.1
111+
112+
![Create agent modal](/images/connections/mongodb/create-agent-modal.png)
113+
114+
## Connecting to MongoDB
115+
116+
### Step 1: Add the MongoDB connection
117+
118+
Navigate to the **Connections** tab and add MongoDB:
119+
120+
1. Click "Add connection"
121+
2. Select "MongoDB" from the dropdown
122+
123+
![Add MongoDB connection](/images/connections/mongodb/add-mongodb-connection.png)
124+
125+
### Step 2: Configure credentials
126+
127+
Enter your MongoDB credentials:
128+
129+
- **Username**: The username of your MongoDB user
130+
- **Password**: The password of your MongoDB user
131+
- **Database Name**: The default database to connect to
132+
- **Hostname**: The hostname of your MongoDB cluster. This is the part of your
133+
MongoDB connection string that comes after `mongodb+srv://` and is a domain
134+
name. For example given the connection string
135+
`mongodb+srv://will:<db_password>@hypermodeturorials.o7ygcmn.mongodb.net/?retryWrites=true&w=majority&appName=HypermodeTurorials`,
136+
the hostname is `hypermodeturorials.o7ygcmn.mongodb.net`
137+
138+
![MongoDB connection modal](/images/connections/mongodb/mongodb-connection-modal.png)
139+
140+
<Warning>
141+
Keep your connection string secure! This contains your database credentials
142+
and should never be exposed in client-side code.
143+
</Warning>
144+
145+
## Testing the connection
146+
147+
Your agent can create collections, add documents, and perform queries on your
148+
MongoDB database. Since we created a sample movies database, let's test it out
149+
using the sample data in MongoDB.
150+
151+
### Test 1: Query empty collections
152+
153+
Start a new thread and test with a simple query:
154+
155+
```text
156+
Can you show me all movies in the database?
157+
```
158+
159+
You should see a MongoDB tool call in the chat history, confirming the
160+
connection works:
161+
162+
![Empty movies query](/images/connections/mongodb/empty-movies.png)
163+
164+
### Test 2: Insert documents
165+
166+
Now try adding data to your database:
167+
168+
```text
169+
Can you add The Matrix from 1999 directed by the Wachowskis to my MongoDB database?
170+
```
171+
172+
![Add Matrix movie](/images/connections/mongodb/add-matrix.png)
173+
174+
### Test 3: Complex queries
175+
176+
Test more advanced operations:
177+
178+
```text
179+
Can you find all movies from the 1910s and show their average rating?
180+
```
181+
182+
![Complex query](/images/connections/mongodb/complex-query.png)
183+
184+
## What you can do
185+
186+
With your MongoDB connection established, your agent can:
187+
188+
- **Query documents** with complex filters and projections
189+
- **Insert, update, and delete** documents
190+
- **Perform aggregations** for data analysis and reporting
191+
- **Work with embedded documents** and arrays
192+
- **Execute transactions** for multi-document operations
193+
- **Create indexes** for improved query performance
194+
- **Integrate with other tools** like GitHub, Slack, and Stripe
195+
196+
## Best practices
197+
198+
1. **Schema design**: Design your document structure to match your query
199+
patterns
200+
2. **Indexing**: Create indexes on frequently queried fields
201+
3. **Connection management**: Use connection pooling for better performance
202+
4. **Error handling**: Your agent will handle common database errors gracefully
203+
5. **Data validation**: Consider using MongoDB schema validation for data
204+
consistency
205+
206+
## Advanced operations
207+
208+
### Aggregation pipelines
209+
210+
Your agent can perform complex aggregation operations:
211+
212+
```text
213+
Can you group movies by decade and show the count and average rating for each decade?
214+
```
215+
216+
### Text search
217+
218+
Enable text search on your collections:
219+
220+
```text
221+
Can you find all movies that mention "robot" in their title or description?
222+
```
223+
224+
### Geospatial queries
225+
226+
For location-based data:
227+
228+
```text
229+
Find all movie theaters within 10 miles of coordinates [40.7128, -74.0060]
230+
```
231+
232+
## Troubleshooting
233+
234+
### Common connection issues
235+
236+
1. **Network access**: Ensure your IP is whitelisted in MongoDB Atlas
237+
2. **Authentication**: Verify your username and password are correct
238+
3. **Connection string**: Check that your connection string format is valid
239+
4. **Database permissions**: Ensure your user has appropriate read/write
240+
permissions
241+
242+
### Performance optimization
243+
244+
1. **Query optimization**: Use explain() to analyze query performance
245+
2. **Index usage**: Monitor index usage and create appropriate indexes
246+
3. **Document size**: Keep documents reasonably sized for better performance
247+
4. **Connection pooling**: Configure appropriate connection pool settings
248+
249+
## Learn more
250+
251+
- [MongoDB Documentation](https://docs.mongodb.com/)
252+
- [MongoDB Atlas Documentation](https://docs.atlas.mongodb.com/)
253+
- [MongoDB Query Language](https://docs.mongodb.com/manual/tutorial/query-documents/)
254+
- [Aggregation Framework](https://docs.mongodb.com/manual/aggregation/)
255+
256+
<Tip>
257+
Combine MongoDB with other Hypermode connections to build powerful workflows.
258+
For example, use GitHub to track code changes that affect your data models, or
259+
Slack to notify your team of important database updates and analytics
260+
insights.
261+
</Tip>
262+
263+
## Example workflows
264+
265+
### E-commerce integration
266+
267+
```text
268+
Track inventory levels and automatically update product availability when stock changes
269+
```
270+
271+
### Content management
272+
273+
```text
274+
Manage blog posts, user comments, and media assets with flexible document structures
275+
```
276+
277+
### Analytics and reporting
278+
279+
```text
280+
Generate real-time reports on user behavior, sales metrics, and application performance
281+
```

docs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
"pages": [
7171
"agents/available-connections",
7272
"agents/connections/supabase",
73-
"agents/connections/neo4j"
73+
"agents/connections/neo4j",
74+
"agents/connections/mongodb"
7475
]
7576
}
7677
]
Lines changed: 1 addition & 0 deletions
Loading
159 KB
Loading
38.1 KB
Loading
168 KB
Loading
167 KB
Loading
127 KB
Loading
208 KB
Loading

0 commit comments

Comments
 (0)