@@ -10,8 +10,8 @@ describeWithMongoDB(
10
10
beforeEach ( async ( ) => {
11
11
const mongoClient = integration . mongoClient ( ) ;
12
12
await mongoClient
13
- . db ( integration . randomDbName ( ) )
14
- . collection ( "foo " )
13
+ . db ( "db" )
14
+ . collection ( "coll " )
15
15
. insertMany ( [
16
16
{ name : "foo" , longNumber : new Long ( 1234 ) } ,
17
17
{ name : "bar" , bigInt : new Long ( 123412341234 ) } ,
@@ -34,10 +34,10 @@ describeWithMongoDB(
34
34
it ( "should return an error" , async ( ) => {
35
35
await integration . connectMcpClient ( ) ;
36
36
const response = await integration . mcpClient ( ) . readResource ( {
37
- uri : "exported-data://foo.bar .json" ,
37
+ uri : "exported-data://db.coll .json" ,
38
38
} ) ;
39
39
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" ) ;
41
41
expect ( response . contents [ 0 ] ?. text ) . toEqual (
42
42
"Error reading from exported-data://{exportName}: Requested export does not exist!"
43
43
) ;
@@ -49,7 +49,7 @@ describeWithMongoDB(
49
49
await integration . connectMcpClient ( ) ;
50
50
const exportResponse = await integration . mcpClient ( ) . callTool ( {
51
51
name : "export" ,
52
- arguments : { database : integration . randomDbName ( ) , collection : "foo " } ,
52
+ arguments : { database : "db" , collection : "coll " } ,
53
53
} ) ;
54
54
55
55
const exportedResourceURI = ( exportResponse as CallToolResult ) . content . find (
@@ -75,7 +75,7 @@ describeWithMongoDB(
75
75
await integration . connectMcpClient ( ) ;
76
76
const exportResponse = await integration . mcpClient ( ) . callTool ( {
77
77
name : "export" ,
78
- arguments : { database : integration . randomDbName ( ) , collection : "foo " } ,
78
+ arguments : { database : "db" , collection : "coll " } ,
79
79
} ) ;
80
80
81
81
const exportedResourceURI = ( exportResponse as CallToolResult ) . content . find (
@@ -90,6 +90,31 @@ describeWithMongoDB(
90
90
expect ( response . contents [ 0 ] ?. mimeType ) . toEqual ( "application/json" ) ;
91
91
expect ( response . contents [ 0 ] ?. text ) . toContain ( "foo" ) ;
92
92
} ) ;
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
+ } ) ;
93
118
} ) ;
94
119
} ,
95
120
( ) => {
0 commit comments