1- import  {  defaultDriverOptions ,   defaultTestConfig ,  expectDefined ,   setupIntegrationTest  }  from  "./helpers.js" ; 
1+ import  {  defaultTestConfig ,  expectDefined  }  from  "./helpers.js" ; 
22import  {  describeWithMongoDB  }  from  "./tools/mongodb/mongodbHelpers.js" ; 
33import  {  describe ,  expect ,  it  }  from  "vitest" ; 
44
@@ -15,81 +15,84 @@ describe("Server integration test", () => {
1515                expect ( atlasTools . length ) . toBeLessThanOrEqual ( 0 ) ; 
1616            } ) ; 
1717        } , 
18-         ( )  =>  ( { 
19-             ...defaultTestConfig , 
20-             apiClientId : undefined , 
21-             apiClientSecret : undefined , 
22-         } ) , 
23-         ( )  =>  defaultDriverOptions 
18+         { 
19+             getUserConfig : ( )  =>  ( { 
20+                 ...defaultTestConfig , 
21+                 apiClientId : undefined , 
22+                 apiClientSecret : undefined , 
23+             } ) , 
24+         } 
2425    ) ; 
2526
26-     describe ( "with atlas" ,  ( )  =>  { 
27-         const  integration  =  setupIntegrationTest ( 
28-             ( )  =>  ( { 
27+     describeWithMongoDB ( 
28+         "with atlas" , 
29+         ( integration )  =>  { 
30+             describe ( "list capabilities" ,  ( )  =>  { 
31+                 it ( "should return positive number of tools and have some atlas tools" ,  async  ( )  =>  { 
32+                     const  tools  =  await  integration . mcpClient ( ) . listTools ( ) ; 
33+                     expectDefined ( tools ) ; 
34+                     expect ( tools . tools . length ) . toBeGreaterThan ( 0 ) ; 
35+ 
36+                     const  atlasTools  =  tools . tools . filter ( ( tool )  =>  tool . name . startsWith ( "atlas-" ) ) ; 
37+                     expect ( atlasTools . length ) . toBeGreaterThan ( 0 ) ; 
38+                 } ) ; 
39+ 
40+                 it ( "should return no prompts" ,  async  ( )  =>  { 
41+                     await  expect ( ( )  =>  integration . mcpClient ( ) . listPrompts ( ) ) . rejects . toMatchObject ( { 
42+                         message : "MCP error -32601: Method not found" , 
43+                     } ) ; 
44+                 } ) ; 
45+ 
46+                 it ( "should return capabilities" ,  ( )  =>  { 
47+                     const  capabilities  =  integration . mcpClient ( ) . getServerCapabilities ( ) ; 
48+                     expectDefined ( capabilities ) ; 
49+                     expectDefined ( capabilities ?. logging ) ; 
50+                     expectDefined ( capabilities ?. completions ) ; 
51+                     expectDefined ( capabilities ?. tools ) ; 
52+                     expectDefined ( capabilities ?. resources ) ; 
53+                     expect ( capabilities . experimental ) . toBeUndefined ( ) ; 
54+                     expect ( capabilities . prompts ) . toBeUndefined ( ) ; 
55+                 } ) ; 
56+             } ) ; 
57+         } , 
58+         { 
59+             getUserConfig : ( )  =>  ( { 
2960                ...defaultTestConfig , 
3061                apiClientId : "test" , 
3162                apiClientSecret : "test" , 
3263            } ) , 
33-              ( )   =>   defaultDriverOptions 
34-          ) ; 
64+         } 
65+     ) ; 
3566
36-         describe ( "list capabilities" ,  ( )  =>  { 
37-             it ( "should return positive number of tools and have some atlas tools" ,  async  ( )  =>  { 
67+     describeWithMongoDB ( 
68+         "with read-only mode" , 
69+         ( integration )  =>  { 
70+             it ( "should only register read and metadata operation tools when read-only mode is enabled" ,  async  ( )  =>  { 
3871                const  tools  =  await  integration . mcpClient ( ) . listTools ( ) ; 
3972                expectDefined ( tools ) ; 
4073                expect ( tools . tools . length ) . toBeGreaterThan ( 0 ) ; 
4174
42-                 const  atlasTools  =  tools . tools . filter ( ( tool )  =>  tool . name . startsWith ( "atlas-" ) ) ; 
43-                 expect ( atlasTools . length ) . toBeGreaterThan ( 0 ) ; 
44-             } ) ; 
45- 
46-             it ( "should return no prompts" ,  async  ( )  =>  { 
47-                 await  expect ( ( )  =>  integration . mcpClient ( ) . listPrompts ( ) ) . rejects . toMatchObject ( { 
48-                     message : "MCP error -32601: Method not found" , 
49-                 } ) ; 
50-             } ) ; 
75+                 // Check that we have some tools available (the read and metadata ones) 
76+                 expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "find" ) ) . toBe ( true ) ; 
77+                 expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "collection-schema" ) ) . toBe ( true ) ; 
78+                 expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "list-databases" ) ) . toBe ( true ) ; 
79+                 expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "atlas-list-orgs" ) ) . toBe ( true ) ; 
80+                 expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "atlas-list-projects" ) ) . toBe ( true ) ; 
5181
52-             it ( "should return capabilities" ,  ( )  =>  { 
53-                 const  capabilities  =  integration . mcpClient ( ) . getServerCapabilities ( ) ; 
54-                 expectDefined ( capabilities ) ; 
55-                 expectDefined ( capabilities ?. logging ) ; 
56-                 expectDefined ( capabilities ?. completions ) ; 
57-                 expectDefined ( capabilities ?. tools ) ; 
58-                 expectDefined ( capabilities ?. resources ) ; 
59-                 expect ( capabilities . experimental ) . toBeUndefined ( ) ; 
60-                 expect ( capabilities . prompts ) . toBeUndefined ( ) ; 
82+                 // Check that non-read tools are NOT available 
83+                 expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "insert-one" ) ) . toBe ( false ) ; 
84+                 expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "update-many" ) ) . toBe ( false ) ; 
85+                 expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "delete-one" ) ) . toBe ( false ) ; 
86+                 expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "drop-collection" ) ) . toBe ( false ) ; 
6187            } ) ; 
62-         } ) ; 
63-     } ) ; 
64- 
65-     describe ( "with read-only mode" ,  ( )  =>  { 
66-         const  integration  =  setupIntegrationTest ( 
67-             ( )  =>  ( { 
88+         } , 
89+         { 
90+             getUserConfig : ( )  =>  ( { 
6891                ...defaultTestConfig , 
6992                readOnly : true , 
7093                apiClientId : "test" , 
7194                apiClientSecret : "test" , 
7295            } ) , 
73-             ( )  =>  defaultDriverOptions 
74-         ) ; 
75- 
76-         it ( "should only register read and metadata operation tools when read-only mode is enabled" ,  async  ( )  =>  { 
77-             const  tools  =  await  integration . mcpClient ( ) . listTools ( ) ; 
78-             expectDefined ( tools ) ; 
79-             expect ( tools . tools . length ) . toBeGreaterThan ( 0 ) ; 
80- 
81-             // Check that we have some tools available (the read and metadata ones) 
82-             expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "find" ) ) . toBe ( true ) ; 
83-             expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "collection-schema" ) ) . toBe ( true ) ; 
84-             expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "list-databases" ) ) . toBe ( true ) ; 
85-             expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "atlas-list-orgs" ) ) . toBe ( true ) ; 
86-             expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "atlas-list-projects" ) ) . toBe ( true ) ; 
87- 
88-             // Check that non-read tools are NOT available 
89-             expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "insert-one" ) ) . toBe ( false ) ; 
90-             expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "update-many" ) ) . toBe ( false ) ; 
91-             expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "delete-one" ) ) . toBe ( false ) ; 
92-             expect ( tools . tools . some ( ( tool )  =>  tool . name  ===  "drop-collection" ) ) . toBe ( false ) ; 
93-         } ) ; 
94-     } ) ; 
96+         } 
97+     ) ; 
9598} ) ; 
0 commit comments