@@ -3,7 +3,8 @@ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
3
import { AtlasToolBase } from "../atlasTool.js" ;
4
4
import { ToolArgs , OperationType } from "../../tool.js" ;
5
5
6
- function generateSecurePassword ( ) : string { // TODO: use a better password generator
6
+ function generateSecurePassword ( ) : string {
7
+ // TODO: use a better password generator
7
8
return `pwdMcp${ Math . floor ( Math . random ( ) * 100000 ) } ` ;
8
9
}
9
10
@@ -44,7 +45,7 @@ export class ConnectClusterTool extends AtlasToolBase {
44
45
params : {
45
46
path : {
46
47
groupId : projectId ,
47
- }
48
+ } ,
48
49
} ,
49
50
body : {
50
51
databaseName : "admin" ,
@@ -55,25 +56,30 @@ export class ConnectClusterTool extends AtlasToolBase {
55
56
databaseName : "admin" ,
56
57
} ,
57
58
] ,
58
- scopes : [ { type : "CLUSTER" , name : clusterName } ] ,
59
+ scopes : [ { type : "CLUSTER" , name : clusterName } ] ,
59
60
username,
60
61
password,
61
62
awsIAMType : "NONE" ,
62
63
ldapAuthType : "NONE" ,
63
64
oidcAuthType : "NONE" ,
64
65
x509Type : "NONE" ,
65
66
deleteAfterDate : expiryDate . toISOString ( ) ,
66
- }
67
+ } ,
67
68
} ) ;
68
69
69
- setTimeout ( async ( ) => { // disconnect after 12 hours
70
+ setTimeout ( async ( ) => {
71
+ // disconnect after 12 hours
70
72
if ( this . session . serviceProvider ) {
71
73
await this . session . serviceProvider ?. close ( true ) ;
72
74
this . session . serviceProvider = undefined ;
73
75
}
74
76
} , expiryMs ) ;
75
77
76
- const connectionString = ( cluster . connectionStrings . standardSrv || cluster . connectionStrings . standard || "" ) . replace ( '://' , `://${ username } :${ password } @` ) + `?authSource=admin` ;
78
+ const connectionString =
79
+ ( cluster . connectionStrings . standardSrv || cluster . connectionStrings . standard || "" ) . replace (
80
+ "://" ,
81
+ `://${ username } :${ password } @`
82
+ ) + `?authSource=admin` ;
77
83
78
84
await this . connectToMongoDB ( connectionString ) ;
79
85
@@ -83,7 +89,7 @@ export class ConnectClusterTool extends AtlasToolBase {
83
89
type : "text" ,
84
90
text : `Connected to cluster "${ clusterName } "` ,
85
91
} ,
86
- ]
92
+ ] ,
87
93
} ;
88
94
}
89
95
}
0 commit comments