@@ -3,7 +3,8 @@ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
33import { AtlasToolBase } from "../atlasTool.js" ;
44import { ToolArgs , OperationType } from "../../tool.js" ;
55
6- function generateSecurePassword ( ) : string { // TODO: use a better password generator
6+ function generateSecurePassword ( ) : string {
7+ // TODO: use a better password generator
78 return `pwdMcp${ Math . floor ( Math . random ( ) * 100000 ) } ` ;
89}
910
@@ -44,7 +45,7 @@ export class ConnectClusterTool extends AtlasToolBase {
4445 params : {
4546 path : {
4647 groupId : projectId ,
47- }
48+ } ,
4849 } ,
4950 body : {
5051 databaseName : "admin" ,
@@ -55,25 +56,30 @@ export class ConnectClusterTool extends AtlasToolBase {
5556 databaseName : "admin" ,
5657 } ,
5758 ] ,
58- scopes : [ { type : "CLUSTER" , name : clusterName } ] ,
59+ scopes : [ { type : "CLUSTER" , name : clusterName } ] ,
5960 username,
6061 password,
6162 awsIAMType : "NONE" ,
6263 ldapAuthType : "NONE" ,
6364 oidcAuthType : "NONE" ,
6465 x509Type : "NONE" ,
6566 deleteAfterDate : expiryDate . toISOString ( ) ,
66- }
67+ } ,
6768 } ) ;
6869
69- setTimeout ( async ( ) => { // disconnect after 12 hours
70+ setTimeout ( async ( ) => {
71+ // disconnect after 12 hours
7072 if ( this . session . serviceProvider ) {
7173 await this . session . serviceProvider ?. close ( true ) ;
7274 this . session . serviceProvider = undefined ;
7375 }
7476 } , expiryMs ) ;
7577
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` ;
7783
7884 await this . connectToMongoDB ( connectionString ) ;
7985
@@ -83,7 +89,7 @@ export class ConnectClusterTool extends AtlasToolBase {
8389 type : "text" ,
8490 text : `Connected to cluster "${ clusterName } "` ,
8591 } ,
86- ]
92+ ] ,
8793 } ;
8894 }
8995}
0 commit comments