You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// if we have a positional argument that matches a connection string
257
264
// store it as the connection specifier and remove it from the argument
258
265
// list, so it doesn't get misunderstood by the mongosh args-parser
@@ -264,6 +271,28 @@ function parseCliConfig(args: string[]): CliOptions {
264
271
returnparsed;
265
272
}
266
273
274
+
exportfunctionwarnAboutDeprecatedCliArgs(
275
+
args: CliOptions&
276
+
UserConfig&{
277
+
_?: string[];
278
+
},
279
+
warn: (msg: string)=>void
280
+
): void{
281
+
letusedDeprecatedArgument=false;
282
+
// the first position argument should be used
283
+
// instead of --connectionString, as it's how the mongosh works.
284
+
if(args.connectionString){
285
+
usedDeprecatedArgument=true;
286
+
warn(
287
+
"The --connectionString argument is deprecated. Prefer using the first positional argument for the connection string or the MDB_MCP_CONNECTION_STRING environment variable."
288
+
);
289
+
}
290
+
291
+
if(usedDeprecatedArgument){
292
+
warn("Refer to https://www.mongodb.com/docs/mcp-server/get-started/ for setting up the MCP Server.");
? `Note to LLM: prefer using the "${atlasConnectTool.name}" tool to connect to an Atlas cluster over using a connection string. Make sure to ask the user to specify a cluster name they want to connect to or ask them if they want to use the "list-clusters" tool to list all their clusters. Do not invent cluster names or connection strings unless the user has explicitly specified them. If they've previously connected to MongoDB using MCP, you can ask them if they want to reconnect using the same cluster/connection.`
25
+
: "Note to LLM: do not invent connection strings and explicitly ask the user to provide one. If they have previously connected to MongoDB using MCP, you can ask them if they want to reconnect using the same connection string.";
text: `The user needs to finish their OIDC connection by opening '${connectionState.oidcLoginUrl}' in the browser and use the following user code: '${connectionState.oidcUserCode}'`,
34
+
});
35
+
}else{
36
+
additionalPromptForConnectivity.push({
37
+
type: "text",
38
+
text: connectToolsNames
39
+
? `Please use one of the following tools: ${connectToolsNames} to connect to a MongoDB instance or update the MCP server configuration to include a connection string. ${llmConnectHint}`
40
+
: "There are no tools available to connect. Please update the configuration to include a connection string and restart the server.",
41
+
});
42
+
}
43
+
44
+
switch(error.code){
45
+
caseErrorCodes.NotConnectedToMongoDB:
46
+
return{
47
+
errorHandled: true,
48
+
result: {
49
+
content: [
50
+
{
51
+
type: "text",
52
+
text: "You need to connect to a MongoDB instance before you can access its data.",
53
+
},
54
+
...additionalPromptForConnectivity,
55
+
],
56
+
isError: true,
57
+
},
58
+
};
59
+
caseErrorCodes.MisconfiguredConnectionString:
60
+
return{
61
+
errorHandled: true,
62
+
result: {
63
+
content: [
64
+
{
65
+
type: "text",
66
+
text: "The configured connection string is not valid. Please check the connection string and confirm it points to a valid MongoDB instance.",
67
+
},
68
+
{
69
+
type: "text",
70
+
text: connectTools
71
+
? `Alternatively, you can use one of the following tools: ${connectToolsNames} to connect to a MongoDB instance. ${llmConnectHint}`
72
+
: "Please update the configuration to use a valid connection string and restart the server.",
// Placed here to start the connection to the config connection string as soon as the server is initialized.
121
126
voidthis.connectToConfigConnectionString();
122
-
123
127
this.session.logger.info({
124
128
id: LogId.serverInitialized,
125
129
context: "server",
126
-
message: `Server started with transport ${transport.constructor.name} and agent runner ${this.session.mcpClient?.name}`,
130
+
message: `Server with version ${packageInfo.version}started with transport ${transport.constructor.name} and agent runner ${JSON.stringify(this.session.mcpClient)}`,
0 commit comments