@@ -17,8 +17,13 @@ export interface AtlasClusterConnectionInfo {
1717 expiryDate : Date ;
1818}
1919
20+ export interface ConnectionSettings {
21+ connectionString : string ;
22+ atlas ?: AtlasClusterConnectionInfo ;
23+ }
24+
2025type ConnectionTag = "connected" | "connecting" | "disconnected" | "errored" ;
21- export type OIDCConnectionAuthType = "oidc-auth-flow" | "oidc-device-flow" ;
26+ type OIDCConnectionAuthType = "oidc-auth-flow" | "oidc-device-flow" ;
2227export type ConnectionStringAuthType = "scram" | "ldap" | "kerberos" | OIDCConnectionAuthType | "x.509" ;
2328
2429export interface ConnectionState {
@@ -63,11 +68,6 @@ export interface ConnectionManagerEvents {
6368 "connection-errored" : [ ConnectionStateErrored ] ;
6469}
6570
66- export interface ConnectionSettings {
67- connectionString : string ;
68- atlas ?: AtlasClusterConnectionInfo ;
69- }
70-
7171export abstract class ConnectionManager {
7272 protected clientName : string = "unknown" ;
7373
@@ -119,7 +119,7 @@ export class MCPConnectionManager extends ConnectionManager {
119119 this . clientName = "unknown" ;
120120 }
121121
122- async connect ( connectParams : ConnectionSettings ) : Promise < AnyConnectionState > {
122+ async connect ( settings : ConnectionSettings ) : Promise < AnyConnectionState > {
123123 this . _events . emit ( "connection-requested" , this . state ) ;
124124
125125 if ( this . state . tag === "connected" || this . state . tag === "connecting" ) {
@@ -130,22 +130,22 @@ export class MCPConnectionManager extends ConnectionManager {
130130 let connectionInfo : ConnectionInfo ;
131131
132132 try {
133- connectParams = { ...connectParams } ;
133+ settings = { ...settings } ;
134134 const appNameComponents : AppNameComponents = {
135135 appName : `${ packageInfo . mcpServerName } ${ packageInfo . version } ` ,
136136 deviceId : this . deviceId . get ( ) ,
137137 clientName : this . clientName ,
138138 } ;
139139
140- connectParams . connectionString = await setAppNameParamIfMissing ( {
141- connectionString : connectParams . connectionString ,
140+ settings . connectionString = await setAppNameParamIfMissing ( {
141+ connectionString : settings . connectionString ,
142142 components : appNameComponents ,
143143 } ) ;
144144
145145 connectionInfo = generateConnectionInfoFromCliArgs ( {
146146 ...this . userConfig ,
147147 ...this . driverOptions ,
148- connectionSpecifier : connectParams . connectionString ,
148+ connectionSpecifier : settings . connectionString ,
149149 } ) ;
150150
151151 if ( connectionInfo . driverOptions . oidc ) {
@@ -171,7 +171,7 @@ export class MCPConnectionManager extends ConnectionManager {
171171 this . changeState ( "connection-errored" , {
172172 tag : "errored" ,
173173 errorReason,
174- connectedAtlasCluster : connectParams . atlas ,
174+ connectedAtlasCluster : settings . atlas ,
175175 } ) ;
176176 throw new MongoDBError ( ErrorCodes . MisconfiguredConnectionString , errorReason ) ;
177177 }
@@ -186,7 +186,7 @@ export class MCPConnectionManager extends ConnectionManager {
186186
187187 return this . changeState ( "connection-requested" , {
188188 tag : "connecting" ,
189- connectedAtlasCluster : connectParams . atlas ,
189+ connectedAtlasCluster : settings . atlas ,
190190 serviceProvider,
191191 connectionStringAuthType : connectionType ,
192192 oidcConnectionType : connectionType as OIDCConnectionAuthType ,
@@ -197,7 +197,7 @@ export class MCPConnectionManager extends ConnectionManager {
197197
198198 return this . changeState ( "connection-succeeded" , {
199199 tag : "connected" ,
200- connectedAtlasCluster : connectParams . atlas ,
200+ connectedAtlasCluster : settings . atlas ,
201201 serviceProvider,
202202 connectionStringAuthType : connectionType ,
203203 } ) ;
@@ -206,7 +206,7 @@ export class MCPConnectionManager extends ConnectionManager {
206206 this . changeState ( "connection-errored" , {
207207 tag : "errored" ,
208208 errorReason,
209- connectedAtlasCluster : connectParams . atlas ,
209+ connectedAtlasCluster : settings . atlas ,
210210 } ) ;
211211 throw new MongoDBError ( ErrorCodes . NotConnectedToMongoDB , errorReason ) ;
212212 }
0 commit comments