Skip to content

Commit 515973f

Browse files
committed
Merge branch 'main' into ni/integration-tests
* main: feat: change Atlas API auth to service accounts (#59)
2 parents 6d89b3e + 9e09c1e commit 515973f

21 files changed

+281
-373
lines changed

README.md

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ npm run build
4848

4949
#### MongoDB Atlas Tools
5050

51-
- `atlas-auth` - Authenticate to MongoDB Atlas
5251
- `atlas-list-clusters` - Lists MongoDB Atlas clusters
5352
- `atlas-list-projects` - Lists MongoDB Atlas projects
5453
- `atlas-inspect-cluster` - Inspect a specific MongoDB Atlas cluster
5554
- `atlas-create-free-cluster` - Create a free MongoDB Atlas cluster
5655
- `atlas-create-access-list` - Configure IP/CIDR access list for MongoDB Atlas clusters
5756
- `atlas-inspect-access-list` - Inspect IP/CIDR ranges with access to MongoDB Atlas clusters
57+
- `atlas-list-db-users` - List MongoDB Atlas database users
58+
- `atlas-create-db-user` - List MongoDB Atlas database users
5859

5960
#### MongoDB Database Tools
6061

@@ -110,6 +111,8 @@ It should look like this
110111
}
111112
```
112113

114+
Notes: You can configure the server with atlas access, make sure to follow configuration section for more details.
115+
113116
Step 3: Open the copilot chat and check that the toolbox icon is visible and has the mcp server listed.
114117

115118
Step 4: Try running a command
@@ -146,10 +149,90 @@ Paste the mcp server configuration into the file
146149

147150
Step 3: Launch Claude Desktop and click on the hammer icon, the Demo MCP server should be detected. Type in the chat "show me a demo of MCP" and allow the tool to get access.
148151

149-
- Detailed instructions with screenshots can be found in this [document](https://docs.google.com/document/d/1_C8QBMZ5rwImV_9v4G96661OqcBk1n1SfEgKyNalv9c/edit?tab=t.2hhewstzj7ck#bookmark=id.nktw0lg0fn7t).
150-
151152
Note: If you make changes to your MCP server code, rebuild the project with `npm run build` and restart the server and Claude Desktop.
152153

154+
## Configuration
155+
156+
The MongoDB MCP Server can be configured using multiple methods, with the following precedence (highest to lowest):
157+
158+
1. Command-line arguments
159+
2. Environment variables
160+
3. Configuration file
161+
4. Default values
162+
163+
### Configuration Options
164+
165+
| Option | Description |
166+
| ------------------ | --------------------------------------------------------------------------------------------------------------------- |
167+
| `apiClientId` | Atlas API client ID for authentication |
168+
| `apiClientSecret` | Atlas API client secret for authentication |
169+
| `connectionString` | MongoDB connection string for direct database connections (optional users may choose to inform it on every tool call) |
170+
171+
### Atlas API Access
172+
173+
To use the Atlas API tools, you'll need to create a service account in MongoDB Atlas:
174+
175+
1. **Create a Service Account:**
176+
177+
- Log in to MongoDB Atlas at [cloud.mongodb.com](https://cloud.mongodb.com)
178+
- Navigate to Access Manager > Organization Access
179+
- Click Add New > Applications > Service Accounts
180+
- Enter name, description and expiration for your service account (e.g., "MCP, MCP Server Access, 7 days")
181+
- Select appropriate permissions (for full access, use Organization Owner)
182+
- Click "Create"
183+
184+
2. **Save Client Credentials:**
185+
186+
- After creation, you'll be shown the Client ID and Client Secret
187+
- **Important:** Copy and save the Client Secret immediately as it won't be displayed again
188+
189+
3. **Add Access List Entry (Optional but recommended):**
190+
191+
- Add your IP address to the API access list
192+
193+
4. **Configure the MCP Server:**
194+
- Use one of the configuration methods below to set your `apiClientId` and `apiClientSecret`
195+
196+
### Configuration Methods
197+
198+
#### Configuration File
199+
200+
Create a JSON configuration file at one of these locations:
201+
202+
- Linux/macOS: `/etc/mongodb-mcp.conf`
203+
- Windows: `%LOCALAPPDATA%\mongodb\mongodb-mcp\mongodb-mcp.conf`
204+
205+
Example configuration file:
206+
207+
```json
208+
{
209+
"apiClientId": "your-atlas-client-id",
210+
"apiClientSecret": "your-atlas-client-secret",
211+
"connectionString": "mongodb+srv://username:[email protected]/myDatabase"
212+
}
213+
```
214+
215+
#### Environment Variables
216+
217+
Set environment variables with the prefix `MDB_MCP_` followed by the option name in uppercase with underscores:
218+
219+
```shell
220+
# Set Atlas API credentials
221+
export MDB_MCP_API_CLIENT_ID="your-atlas-client-id"
222+
export MDB_MCP_API_CLIENT_SECRET="your-atlas-client-secret"
223+
224+
# Set a custom MongoDB connection string
225+
export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:[email protected]/myDatabase"
226+
```
227+
228+
#### Command-Line Arguments
229+
230+
Pass configuration options as command-line arguments when starting the server:
231+
232+
```shell
233+
node dist/index.js --apiClientId="your-atlas-client-id" --apiClientSecret="your-atlas-client-secret" --connectionString="mongodb+srv://username:[email protected]/myDatabase"
234+
```
235+
153236
## 🤝 Contributing
154237

155238
Interested in contributing? Great! Please check our [Contributing Guide](CONTRIBUTING.md) for guidelines on code contributions, standards, adding new tools, and troubleshooting information.

package-lock.json

Lines changed: 106 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"mongodb-redact": "^1.1.6",
6969
"mongodb-schema": "^12.6.2",
7070
"openapi-fetch": "^0.13.5",
71+
"simple-oauth2": "^5.1.0",
7172
"yargs-parser": "^21.1.1",
7273
"zod": "^3.24.2"
7374
},

0 commit comments

Comments
 (0)