@@ -17,8 +17,13 @@ export interface AtlasClusterConnectionInfo {
17
17
expiryDate : Date ;
18
18
}
19
19
20
+ export interface ConnectionSettings {
21
+ connectionString : string ;
22
+ atlas ?: AtlasClusterConnectionInfo ;
23
+ }
24
+
20
25
type ConnectionTag = "connected" | "connecting" | "disconnected" | "errored" ;
21
- export type OIDCConnectionAuthType = "oidc-auth-flow" | "oidc-device-flow" ;
26
+ type OIDCConnectionAuthType = "oidc-auth-flow" | "oidc-device-flow" ;
22
27
export type ConnectionStringAuthType = "scram" | "ldap" | "kerberos" | OIDCConnectionAuthType | "x.509" ;
23
28
24
29
export interface ConnectionState {
@@ -63,11 +68,6 @@ export interface ConnectionManagerEvents {
63
68
"connection-errored" : [ ConnectionStateErrored ] ;
64
69
}
65
70
66
- export interface ConnectionSettings {
67
- connectionString : string ;
68
- atlas ?: AtlasClusterConnectionInfo ;
69
- }
70
-
71
71
export abstract class ConnectionManager {
72
72
protected clientName : string = "unknown" ;
73
73
@@ -119,7 +119,7 @@ export class MCPConnectionManager extends ConnectionManager {
119
119
this . clientName = "unknown" ;
120
120
}
121
121
122
- async connect ( connectParams : ConnectionSettings ) : Promise < AnyConnectionState > {
122
+ async connect ( settings : ConnectionSettings ) : Promise < AnyConnectionState > {
123
123
this . _events . emit ( "connection-requested" , this . state ) ;
124
124
125
125
if ( this . state . tag === "connected" || this . state . tag === "connecting" ) {
@@ -130,22 +130,22 @@ export class MCPConnectionManager extends ConnectionManager {
130
130
let connectionInfo : ConnectionInfo ;
131
131
132
132
try {
133
- connectParams = { ...connectParams } ;
133
+ settings = { ...settings } ;
134
134
const appNameComponents : AppNameComponents = {
135
135
appName : `${ packageInfo . mcpServerName } ${ packageInfo . version } ` ,
136
136
deviceId : this . deviceId . get ( ) ,
137
137
clientName : this . clientName ,
138
138
} ;
139
139
140
- connectParams . connectionString = await setAppNameParamIfMissing ( {
141
- connectionString : connectParams . connectionString ,
140
+ settings . connectionString = await setAppNameParamIfMissing ( {
141
+ connectionString : settings . connectionString ,
142
142
components : appNameComponents ,
143
143
} ) ;
144
144
145
145
connectionInfo = generateConnectionInfoFromCliArgs ( {
146
146
...this . userConfig ,
147
147
...this . driverOptions ,
148
- connectionSpecifier : connectParams . connectionString ,
148
+ connectionSpecifier : settings . connectionString ,
149
149
} ) ;
150
150
151
151
if ( connectionInfo . driverOptions . oidc ) {
@@ -171,7 +171,7 @@ export class MCPConnectionManager extends ConnectionManager {
171
171
this . changeState ( "connection-errored" , {
172
172
tag : "errored" ,
173
173
errorReason,
174
- connectedAtlasCluster : connectParams . atlas ,
174
+ connectedAtlasCluster : settings . atlas ,
175
175
} ) ;
176
176
throw new MongoDBError ( ErrorCodes . MisconfiguredConnectionString , errorReason ) ;
177
177
}
@@ -186,7 +186,7 @@ export class MCPConnectionManager extends ConnectionManager {
186
186
187
187
return this . changeState ( "connection-requested" , {
188
188
tag : "connecting" ,
189
- connectedAtlasCluster : connectParams . atlas ,
189
+ connectedAtlasCluster : settings . atlas ,
190
190
serviceProvider,
191
191
connectionStringAuthType : connectionType ,
192
192
oidcConnectionType : connectionType as OIDCConnectionAuthType ,
@@ -197,7 +197,7 @@ export class MCPConnectionManager extends ConnectionManager {
197
197
198
198
return this . changeState ( "connection-succeeded" , {
199
199
tag : "connected" ,
200
- connectedAtlasCluster : connectParams . atlas ,
200
+ connectedAtlasCluster : settings . atlas ,
201
201
serviceProvider,
202
202
connectionStringAuthType : connectionType ,
203
203
} ) ;
@@ -206,7 +206,7 @@ export class MCPConnectionManager extends ConnectionManager {
206
206
this . changeState ( "connection-errored" , {
207
207
tag : "errored" ,
208
208
errorReason,
209
- connectedAtlasCluster : connectParams . atlas ,
209
+ connectedAtlasCluster : settings . atlas ,
210
210
} ) ;
211
211
throw new MongoDBError ( ErrorCodes . NotConnectedToMongoDB , errorReason ) ;
212
212
}
0 commit comments