-
Notifications
You must be signed in to change notification settings - Fork 108
feat: change Atlas API auth to service accounts #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,13 +48,14 @@ npm run build | |
|
||
#### MongoDB Atlas Tools | ||
|
||
- `atlas-auth` - Authenticate to MongoDB Atlas | ||
- `atlas-list-clusters` - Lists MongoDB Atlas clusters | ||
- `atlas-list-projects` - Lists MongoDB Atlas projects | ||
- `atlas-inspect-cluster` - Inspect a specific MongoDB Atlas cluster | ||
- `atlas-create-free-cluster` - Create a free MongoDB Atlas cluster | ||
- `atlas-create-access-list` - Configure IP/CIDR access list for MongoDB Atlas clusters | ||
- `atlas-inspect-access-list` - Inspect IP/CIDR ranges with access to MongoDB Atlas clusters | ||
- `atlas-list-db-users` - List MongoDB Atlas database users | ||
- `atlas-create-db-user` - List MongoDB Atlas database users | ||
|
||
#### MongoDB Database Tools | ||
|
||
|
@@ -110,6 +111,8 @@ It should look like this | |
} | ||
``` | ||
|
||
Notes: You can configure the server with atlas access, make sure to follow configuration section for more details. | ||
|
||
Step 3: Open the copilot chat and check that the toolbox icon is visible and has the mcp server listed. | ||
|
||
Step 4: Try running a command | ||
|
@@ -146,10 +149,91 @@ Paste the mcp server configuration into the file | |
|
||
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. | ||
|
||
- 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). | ||
|
||
Note: If you make changes to your MCP server code, rebuild the project with `npm run build` and restart the server and Claude Desktop. | ||
|
||
## Configuration | ||
|
||
The MongoDB MCP Server can be configured using multiple methods, with the following precedence (highest to lowest): | ||
|
||
1. Command-line arguments | ||
2. Environment variables | ||
3. Configuration file | ||
4. Default values | ||
|
||
### Configuration Options | ||
|
||
| Option | Description | | ||
| ------------------ | --------------------------------------------------------------------------- | | ||
| `apiClientId` | Atlas API client ID for authentication | | ||
| `apiClientSecret` | Atlas API client secret for authentication | | ||
| `stateFile` | Path to store application state (default ~/.mongodb/mongodb-mcp/state.json) | | ||
| `connectionString` | MongoDB connection string for direct database connections | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably indicate this is optional and if not provided, the |
||
|
||
### Atlas API Access | ||
|
||
To use the Atlas API tools, you'll need to create a service account in MongoDB Atlas: | ||
|
||
1. **Create a Service Account:** | ||
|
||
- Log in to MongoDB Atlas at [cloud.mongodb.com](https://cloud.mongodb.com) | ||
- Navigate to Access Manager > Organization Access | ||
- Click Add New > Applications > Service Accounts | ||
- Enter name, description and expiration for your service account (e.g., "MCP, MCP Server Access, 7 days") | ||
- Select appropriate permissions (for full access, use Organization Owner) | ||
- Click "Create" | ||
|
||
2. **Save Client Credentials:** | ||
|
||
- After creation, you'll be shown the Client ID and Client Secret | ||
- **Important:** Copy and save the Client Secret immediately as it won't be displayed again | ||
|
||
3. **Add Access List Entry (Optional but recommended):** | ||
|
||
- Add your IP address to the API access list | ||
|
||
4. **Configure the MCP Server:** | ||
- Use one of the configuration methods below to set your `apiClientId` and `apiClientSecret` | ||
|
||
### Configuration Methods | ||
|
||
#### Configuration File | ||
|
||
Create a JSON configuration file at one of these locations: | ||
|
||
- Linux/macOS: `/etc/mongodb-mcp.conf` | ||
- Windows: `%LOCALAPPDATA%\mongodb\mongodb-mcp\mongodb-mcp.conf` | ||
|
||
Example configuration file: | ||
|
||
```json | ||
{ | ||
"apiClientId": "your-atlas-client-id", | ||
"apiClientSecret": "your-atlas-client-secret", | ||
"connectionString": "mongodb+srv://username:[email protected]/myDatabase" | ||
} | ||
``` | ||
|
||
#### Environment Variables | ||
|
||
Set environment variables with the prefix `MDB_MCP_` followed by the option name in uppercase with underscores: | ||
|
||
```shell | ||
# Set Atlas API credentials | ||
export MDB_MCP_API_CLIENT_ID="your-atlas-client-id" | ||
export MDB_MCP_API_CLIENT_SECRET="your-atlas-client-secret" | ||
|
||
# Set a custom MongoDB connection string | ||
export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:[email protected]/myDatabase" | ||
``` | ||
|
||
#### Command-Line Arguments | ||
|
||
Pass configuration options as command-line arguments when starting the server: | ||
|
||
```shell | ||
node dist/index.js --apiClientId="your-atlas-client-id" --apiClientSecret="your-atlas-client-secret" --connectionString="mongodb+srv://username:[email protected]/myDatabase" | ||
``` | ||
|
||
## 🤝 Contributing | ||
|
||
Interested in contributing? Great! Please check our [Contributing Guide](CONTRIBUTING.md) for guidelines on code contributions, standards, adding new tools, and troubleshooting information. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can drop this now - I forgot to remove it as part of #48 😅