-
Notifications
You must be signed in to change notification settings - Fork 72
chore: default examples with --readOnly #347
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[](https://insiders.vscode.dev/redirect/mcp/install?name=mongodb&inputs=%5B%7B%22id%22%3A%22connection_string%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22MongoDB%20connection%20string%22%7D%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22mongodb-mcp-server%22%5D%2C%22env%22%3A%7B%22MDB_MCP_CONNECTION_STRING%22%3A%22%24%7Binput%3Aconnection_string%7D%22%7D%7D) | ||
[](https://cursor.com/install-mcp?name=MongoDB&config=eyJjb21tYW5kIjoibnB4IC15IG1vbmdvZGItbWNwLXNlcnZlciJ9) | ||
[](https://insiders.vscode.dev/redirect/mcp/install?name=mongodb&inputs=%5B%7B%22id%22%3A%22connection_string%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22MongoDB%20connection%20string%22%7D%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22mongodb-mcp-server%22%2C%22--readOnly%22%5D%2C%22env%22%3A%7B%22MDB_MCP_CONNECTION_STRING%22%3A%22%24%7Binput%3Aconnection_string%7D%22%7D%7D) | ||
[](https://cursor.com/install-mcp?name=MongoDB&config=JTdCJTIyY29tbWFuZCUyMiUzQSUyMm5weCUyMC15JTIwbW9uZ29kYi1tY3Atc2VydmVyJTIwLS1yZWFkT25seSUyMiU3RA%3D%3D) | ||
[](https://smithery.ai/server/@mongodb-js/mongodb-mcp-server) | ||
|
||
# MongoDB MCP Server | ||
|
@@ -42,7 +42,7 @@ node -v | |
|
||
### Quick Start | ||
|
||
> **Note:** When using Atlas API credentials, be sure to assign only the minimum required permissions to your service account. See [Atlas API Permissions](#atlas-api-permissions) for details. | ||
**Note:** When using Atlas API credentials, be sure to assign only the minimum required permissions to your service account. See [Atlas API Permissions](#atlas-api-permissions) for details. | ||
|
||
Most MCP clients require a configuration file to be created or modified to add the MCP server. | ||
|
||
|
@@ -53,6 +53,8 @@ Note: The configuration file syntax can be different across clients. Please refe | |
- **Claude Desktop**: https://modelcontextprotocol.io/quickstart/user | ||
- **Cursor**: https://docs.cursor.com/context/model-context-protocol | ||
|
||
> **Default Safety Notice:** All examples below include `--readOnly` by default to ensure safe, read-only access to your data. Remove `--readOnly` if you need to enable write operations. | ||
|
||
#### Option 1: Connection String args | ||
|
||
You can pass your connection string via args, make sure to use a valid username and password. | ||
|
@@ -66,7 +68,8 @@ You can pass your connection string via args, make sure to use a valid username | |
"-y", | ||
"mongodb-mcp-server", | ||
"--connectionString", | ||
"mongodb://localhost:27017/myDatabase" | ||
"mongodb://localhost:27017/myDatabase", | ||
"--readOnly" | ||
] | ||
} | ||
} | ||
|
@@ -90,7 +93,8 @@ Use your Atlas API Service Accounts credentials. Must follow all the steps in [A | |
"--apiClientId", | ||
"your-atlas-service-accounts-client-id", | ||
"--apiClientSecret", | ||
"your-atlas-service-accounts-client-secret" | ||
"your-atlas-service-accounts-client-secret", | ||
"--readOnly" | ||
] | ||
} | ||
} | ||
|
@@ -102,7 +106,7 @@ Use your Atlas API Service Accounts credentials. Must follow all the steps in [A | |
Start Server using npx command: | ||
|
||
```shell | ||
npx -y mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id" --apiClientSecret="your-atlas-service-accounts-client-secret" | ||
npx -y mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id" --apiClientSecret="your-atlas-service-accounts-client-secret" --readOnly | ||
``` | ||
|
||
- For a complete list of arguments see [Configuration Options](#configuration-options) | ||
|
@@ -111,7 +115,7 @@ Start Server using npx command: | |
#### Option 4: Standalone Service using environment variables | ||
|
||
```shell | ||
npx -y mongodb-mcp-server | ||
npx -y mongodb-mcp-server --readOnly | ||
``` | ||
|
||
You can use environment variables in the config file or set them and run the server via npx. | ||
|
@@ -139,6 +143,7 @@ docker run --rm -i \ | |
```shell | ||
docker run --rm -i \ | ||
-e MDB_MCP_CONNECTION_STRING="mongodb+srv://username:[email protected]/myDatabase" \ | ||
-e MDB_MCP_READ_ONLY="true" \ | ||
mongodb/mongodb-mcp-server:latest | ||
``` | ||
|
||
|
@@ -148,7 +153,7 @@ docker run --rm -i \ | |
docker run --rm -i \ | ||
-e MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" \ | ||
-e MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" \ | ||
mongodb/mongodb-mcp-server:latest | ||
mongodb/mongodb-mcp-server:latest --readOnly | ||
``` | ||
|
||
##### Docker in MCP Configuration File | ||
|
@@ -160,7 +165,14 @@ Without options: | |
"mcpServers": { | ||
"MongoDB": { | ||
"command": "docker", | ||
"args": ["run", "--rm", "-i", "mongodb/mongodb-mcp-server:latest"] | ||
"args": [ | ||
"run", | ||
"--rm", | ||
"-e", | ||
"MDB_MCP_READ_ONLY=true", | ||
"-i", | ||
"mongodb/mongodb-mcp-server:latest" | ||
] | ||
} | ||
} | ||
} | ||
|
@@ -179,6 +191,8 @@ With connection string: | |
"-i", | ||
"-e", | ||
"MDB_MCP_CONNECTION_STRING=mongodb+srv://username:[email protected]/myDatabase", | ||
"-e", | ||
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. This seems to be passing the config parameters via env variables - I think we should consistently use the same patterns (i.e. either command-line args or env variables). 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. nice catch! thx updating |
||
"MDB_MCP_READ_ONLY=true", | ||
"mongodb/mongodb-mcp-server:latest" | ||
] | ||
} | ||
|
@@ -198,6 +212,8 @@ With Atlas API credentials: | |
"--rm", | ||
"-i", | ||
"-e", | ||
"MDB_MCP_READ_ONLY=true", | ||
"-e", | ||
"MDB_MCP_API_CLIENT_ID=your-atlas-service-accounts-client-id", | ||
"-e", | ||
"MDB_MCP_API_CLIENT_SECRET=your-atlas-service-accounts-client-secret", | ||
|
@@ -462,7 +478,8 @@ npx -y mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id" | |
"-y", | ||
"mongodb-mcp-server", | ||
"--connectionString", | ||
"mongodb+srv://username:[email protected]/myDatabase" | ||
"mongodb+srv://username:[email protected]/myDatabase", | ||
"--readOnly" | ||
] | ||
} | ||
} | ||
|
@@ -482,7 +499,8 @@ npx -y mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id" | |
"--apiClientId", | ||
"your-atlas-service-accounts-client-id", | ||
"--apiClientSecret", | ||
"your-atlas-service-accounts-client-secret" | ||
"your-atlas-service-accounts-client-secret", | ||
"--readOnly" | ||
] | ||
} | ||
} | ||
|
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.