Skip to content

Commit 937edfc

Browse files
committed
address comment: update flag
1 parent e34b873 commit 937edfc

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ The MongoDB MCP Server can be configured using multiple methods, with the follow
150150
| `connectionString` | MongoDB connection string for direct database connections (optional users may choose to inform it on every tool call) |
151151
| `logPath` | Folder to store logs |
152152
| `disabledTools` | An array of tool names, operation types, and/or categories of tools that will be disabled. |
153-
| `readOnlyMode` | When set to true, only allows read and metadata operation types, disabling create/update/delete operations |
153+
| `readOnly` | When set to true, only allows read and metadata operation types, disabling create/update/delete operations |
154154

155155
#### `logPath`
156156

@@ -184,14 +184,14 @@ Operation types:
184184

185185
#### Read-Only Mode
186186

187-
The `readOnlyMode` configuration option allows you to restrict the MCP server to only use tools with "read" and "metadata" operation types. When enabled, all tools that have "create", "update", "delete", or "cluster" operation types will not be registered with the server.
187+
The `readOnly` configuration option allows you to restrict the MCP server to only use tools with "read" and "metadata" operation types. When enabled, all tools that have "create", "update", "delete", or "cluster" operation types will not be registered with the server.
188188

189189
This is useful for scenarios where you want to provide access to MongoDB data for analysis without allowing any modifications to the data or infrastructure.
190190

191191
You can enable read-only mode using:
192192

193193
- **Environment variable**: `export MDB_MCP_READ_ONLY_MODE=true`
194-
- **Command-line argument**: `--readOnlyMode=true`
194+
- **Command-line argument**: `--readOnly=true`
195195

196196
When read-only mode is active, you'll see a message in the server logs indicating which tools were prevented from registering due to this restriction.
197197

src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface UserConfig {
2020
timeoutMS: number;
2121
};
2222
disabledTools: Array<string>;
23-
readOnlyMode?: boolean;
23+
readOnly?: boolean;
2424
}
2525

2626
const defaults: UserConfig = {
@@ -33,7 +33,7 @@ const defaults: UserConfig = {
3333
},
3434
disabledTools: [],
3535
telemetry: "disabled",
36-
readOnlyMode: false,
36+
readOnly: false,
3737
};
3838

3939
export const config = {

src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class Server {
3838
this.mcpServer.server.registerCapabilities({ logging: {} });
3939

4040
// Log read-only mode status if enabled
41-
if (this.userConfig.readOnlyMode) {
41+
if (this.userConfig.readOnly) {
4242
logger.info(
4343
mongoLogId(1_000_005),
4444
"server",
@@ -126,7 +126,7 @@ export class Server {
126126

127127
if (command === "start") {
128128
event.properties.startup_time_ms = commandDuration;
129-
event.properties.read_only_mode = this.userConfig.readOnlyMode || false;
129+
event.properties.read_only_mode = this.userConfig.readOnly || false;
130130
}
131131
if (command === "stop") {
132132
event.properties.runtime_duration_ms = Date.now() - this.startTime;

src/tools/tool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export abstract class ToolBase {
8888
let errorClarification: string | undefined;
8989

9090
// Check read-only mode first
91-
if (this.config.readOnlyMode && !["read", "metadata"].includes(this.operationType)) {
91+
if (this.config.readOnly && !["read", "metadata"].includes(this.operationType)) {
9292
logger.debug(
9393
mongoLogId(1_000_010),
9494
"tool",

tests/integration/server.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ describe("Server integration test", () => {
6262
describe("with read-only mode", () => {
6363
const integration = setupIntegrationTest({
6464
...config,
65-
readOnlyMode: true,
65+
readOnly: true,
66+
apiClientId: "test",
67+
apiClientSecret: "test",
6668
});
6769

6870
it("should only register read and metadata operation tools when read-only mode is enabled", async () => {
@@ -74,6 +76,8 @@ describe("Server integration test", () => {
7476
expect(tools.tools.some((tool) => tool.name === "find")).toBe(true);
7577
expect(tools.tools.some((tool) => tool.name === "collection-schema")).toBe(true);
7678
expect(tools.tools.some((tool) => tool.name === "list-databases")).toBe(true);
79+
expect(tools.tools.some((tool) => tool.name === "atlas-list-orgs")).toBe(true);
80+
expect(tools.tools.some((tool) => tool.name === "atlas-list-projects")).toBe(true);
7781

7882
// Check that non-read tools are NOT available
7983
expect(tools.tools.some((tool) => tool.name === "insert-one")).toBe(false);

0 commit comments

Comments
 (0)