@@ -13,9 +13,10 @@ describe("Connect tool", () => {
13
13
14
14
validateParameters ( connectTool , [
15
15
{
16
- name : "connectionStringOrClusterName" ,
17
- description : "MongoDB connection string (in the mongodb:// or mongodb+srv:// format) or cluster name" ,
18
- type : "string" ,
16
+ name : "options" ,
17
+ description :
18
+ "Options for connecting to MongoDB. If not provided, the connection string from the config://connection-string resource will be used. If the user hasn't specified Atlas cluster name or a connection string explicitly and the `config://connection-string` resource is present, always invoke this with no arguments." ,
19
+ type : "array" ,
19
20
required : false ,
20
21
} ,
21
22
] ) ;
@@ -27,15 +28,20 @@ describe("Connect tool", () => {
27
28
const response = await integration . mcpClient ( ) . callTool ( { name : "connect" , arguments : { } } ) ;
28
29
const content = getResponseContent ( response . content ) ;
29
30
expect ( content ) . toContain ( "No connection details provided" ) ;
30
- expect ( content ) . toContain ( "mongodb://localhost:27017" ) ;
31
31
} ) ;
32
32
} ) ;
33
33
34
34
describe ( "with connection string" , ( ) => {
35
35
it ( "connects to the database" , async ( ) => {
36
36
const response = await integration . mcpClient ( ) . callTool ( {
37
37
name : "connect" ,
38
- arguments : { connectionStringOrClusterName : integration . connectionString ( ) } ,
38
+ arguments : {
39
+ options : [
40
+ {
41
+ connectionString : integration . connectionString ( ) ,
42
+ } ,
43
+ ] ,
44
+ } ,
39
45
} ) ;
40
46
const content = getResponseContent ( response . content ) ;
41
47
expect ( content ) . toContain ( "Successfully connected" ) ;
@@ -47,7 +53,7 @@ describe("Connect tool", () => {
47
53
it ( "returns error message" , async ( ) => {
48
54
const response = await integration . mcpClient ( ) . callTool ( {
49
55
name : "connect" ,
50
- arguments : { connectionStringOrClusterName : "mongodb://localhost:12345" } ,
56
+ arguments : { options : [ { connectionString : "mongodb://localhost:12345" } ] } ,
51
57
} ) ;
52
58
const content = getResponseContent ( response . content ) ;
53
59
expect ( content ) . toContain ( "Error running connect" ) ;
@@ -74,7 +80,13 @@ describe("Connect tool", () => {
74
80
const newConnectionString = `${ integration . connectionString ( ) } ?appName=foo-bar` ;
75
81
const response = await integration . mcpClient ( ) . callTool ( {
76
82
name : "connect" ,
77
- arguments : { connectionStringOrClusterName : newConnectionString } ,
83
+ arguments : {
84
+ options : [
85
+ {
86
+ connectionString : newConnectionString ,
87
+ } ,
88
+ ] ,
89
+ } ,
78
90
} ) ;
79
91
const content = getResponseContent ( response . content ) ;
80
92
expect ( content ) . toContain ( "Successfully connected" ) ;
@@ -85,7 +97,13 @@ describe("Connect tool", () => {
85
97
it ( "suggests the config connection string if set" , async ( ) => {
86
98
const response = await integration . mcpClient ( ) . callTool ( {
87
99
name : "connect" ,
88
- arguments : { connectionStringOrClusterName : "mongodb://localhost:12345" } ,
100
+ arguments : {
101
+ options : [
102
+ {
103
+ connectionString : "mongodb://localhost:12345" ,
104
+ } ,
105
+ ] ,
106
+ } ,
89
107
} ) ;
90
108
const content = getResponseContent ( response . content ) ;
91
109
expect ( content ) . toContain ( "Failed to connect to MongoDB at 'mongodb://localhost:12345'" ) ;
@@ -98,7 +116,13 @@ describe("Connect tool", () => {
98
116
config . connectionString = "mongodb://localhost:12345" ;
99
117
const response = await integration . mcpClient ( ) . callTool ( {
100
118
name : "connect" ,
101
- arguments : { connectionStringOrClusterName : "mongodb://localhost:12345" } ,
119
+ arguments : {
120
+ options : [
121
+ {
122
+ connectionString : "mongodb://localhost:12345" ,
123
+ } ,
124
+ ] ,
125
+ } ,
102
126
} ) ;
103
127
104
128
const content = getResponseContent ( response . content ) ;
0 commit comments