@@ -10,8 +10,8 @@ describeWithMongoDB(
1010 beforeEach ( async ( ) => {
1111 const mongoClient = integration . mongoClient ( ) ;
1212 await mongoClient
13- . db ( integration . randomDbName ( ) )
14- . collection ( "foo " )
13+ . db ( "db" )
14+ . collection ( "coll " )
1515 . insertMany ( [
1616 { name : "foo" , longNumber : new Long ( 1234 ) } ,
1717 { name : "bar" , bigInt : new Long ( 123412341234 ) } ,
@@ -34,10 +34,10 @@ describeWithMongoDB(
3434 it ( "should return an error" , async ( ) => {
3535 await integration . connectMcpClient ( ) ;
3636 const response = await integration . mcpClient ( ) . readResource ( {
37- uri : "exported-data://foo.bar .json" ,
37+ uri : "exported-data://db.coll .json" ,
3838 } ) ;
3939 expect ( response . isError ) . toEqual ( true ) ;
40- expect ( response . contents [ 0 ] ?. uri ) . toEqual ( "exported-data://foo.bar .json" ) ;
40+ expect ( response . contents [ 0 ] ?. uri ) . toEqual ( "exported-data://db.coll .json" ) ;
4141 expect ( response . contents [ 0 ] ?. text ) . toEqual (
4242 "Error reading from exported-data://{exportName}: Requested export does not exist!"
4343 ) ;
@@ -49,7 +49,7 @@ describeWithMongoDB(
4949 await integration . connectMcpClient ( ) ;
5050 const exportResponse = await integration . mcpClient ( ) . callTool ( {
5151 name : "export" ,
52- arguments : { database : integration . randomDbName ( ) , collection : "foo " } ,
52+ arguments : { database : "db" , collection : "coll " } ,
5353 } ) ;
5454
5555 const exportedResourceURI = ( exportResponse as CallToolResult ) . content . find (
@@ -75,7 +75,7 @@ describeWithMongoDB(
7575 await integration . connectMcpClient ( ) ;
7676 const exportResponse = await integration . mcpClient ( ) . callTool ( {
7777 name : "export" ,
78- arguments : { database : integration . randomDbName ( ) , collection : "foo " } ,
78+ arguments : { database : "db" , collection : "coll " } ,
7979 } ) ;
8080
8181 const exportedResourceURI = ( exportResponse as CallToolResult ) . content . find (
@@ -90,6 +90,31 @@ describeWithMongoDB(
9090 expect ( response . contents [ 0 ] ?. mimeType ) . toEqual ( "application/json" ) ;
9191 expect ( response . contents [ 0 ] ?. text ) . toContain ( "foo" ) ;
9292 } ) ;
93+
94+ it ( "should be able to autocomplete the resource" , async ( ) => {
95+ await integration . connectMcpClient ( ) ;
96+ const exportResponse = await integration . mcpClient ( ) . callTool ( {
97+ name : "export" ,
98+ arguments : { database : "big" , collection : "coll" } ,
99+ } ) ;
100+
101+ const exportedResourceURI = ( exportResponse as CallToolResult ) . content . find (
102+ ( part ) => part . type === "resource_link"
103+ ) ?. uri ;
104+ expect ( exportedResourceURI ) . toBeDefined ( ) ;
105+
106+ const completeResponse = await integration . mcpClient ( ) . complete ( {
107+ ref : {
108+ type : "ref/resource" ,
109+ uri : "exported-data://{exportName}" ,
110+ } ,
111+ argument : {
112+ name : "exportName" ,
113+ value : "b" ,
114+ } ,
115+ } ) ;
116+ expect ( completeResponse . completion . total ) . toEqual ( 1 ) ;
117+ } ) ;
93118 } ) ;
94119 } ,
95120 ( ) => {
0 commit comments