-
Notifications
You must be signed in to change notification settings - Fork 126
feat: add readOnly flag #130
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 1 commit
cc2bec5
e34b873
937edfc
c6a928c
aefccf7
9270c4f
669f044
a2819fb
de8e999
efbf964
17ab204
9612966
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 |
---|---|---|
|
@@ -106,6 +106,11 @@ class McpLogger extends LoggerBase { | |
} | ||
|
||
log(level: LogLevel, _: MongoLogId, context: string, message: string): void { | ||
// Only log if the server is connected | ||
if (this.server?.isConnected() === false) { | ||
|
||
return; | ||
} | ||
|
||
void this.server.server.sendLoggingMessage({ | ||
level, | ||
data: `[${context}]: ${message}`, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,16 @@ export class Server { | |
|
||
async connect(transport: Transport) { | ||
this.mcpServer.server.registerCapabilities({ logging: {} }); | ||
|
||
// Log read-only mode status if enabled | ||
if (this.userConfig.readOnlyMode) { | ||
logger.info( | ||
mongoLogId(1_000_005), | ||
|
||
"server", | ||
"Server starting in READ-ONLY mode. Only read and metadata operations will be available." | ||
); | ||
} | ||
|
||
this.registerTools(); | ||
this.registerResources(); | ||
|
||
|
@@ -116,6 +126,7 @@ export class Server { | |
|
||
if (command === "start") { | ||
event.properties.startup_time_ms = commandDuration; | ||
event.properties.read_only_mode = this.userConfig.readOnlyMode || false; | ||
} | ||
if (command === "stop") { | ||
event.properties.runtime_duration_ms = Date.now() - this.startTime; | ||
|
Uh oh!
There was an error while loading. Please reload this page.