Skip to content

Commit 63224d3

Browse files
chore: moved all existing tests to vercel mcp client
1 parent 11e92b6 commit 63224d3

11 files changed

+181
-236
lines changed

src/tools/mongodb/read/find.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const FindArgs = {
1313
.describe("The query filter, matching the syntax of the query argument of db.collection.find()"),
1414
projection: z
1515
.record(z.string(), z.unknown())
16-
// .optional()
16+
.optional()
1717
.describe("The projection, matching the syntax of the projection argument of db.collection.find()"),
1818
limit: z.number().optional().default(10).describe("The maximum number of documents to return"),
1919
sort: z
Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,30 @@
1-
import { describeAccuracyTests } from "./sdk/describe-accuracy-tests.js";
1+
import { describeAccuracyTests, describeSuite } from "./sdk/describe-accuracy-tests.js";
22
import { getAvailableModels } from "./sdk/models.js";
33
import { AccuracyTestConfig } from "./sdk/describe-accuracy-tests.js";
4-
import { collectionIndexesResponse } from "../../src/tools/mongodb/read/collectionIndexes.js";
54

65
function callsCollectionIndexes(prompt: string): AccuracyTestConfig {
76
return {
87
injectConnectedAssumption: true,
98
prompt: prompt,
10-
mockedTools: {
11-
"collection-indexes": function collectionIndexes() {
12-
return collectionIndexesResponse({
13-
database: "db1",
14-
collection: "coll1",
15-
indexes: [
16-
{
17-
name: "year",
18-
key: JSON.stringify({ _id: 1 }),
19-
},
20-
],
21-
});
22-
},
23-
},
9+
mockedTools: {},
2410
expectedToolCalls: [
2511
{
2612
toolName: "collection-indexes",
2713
parameters: {
28-
database: "db1",
29-
collection: "coll1",
14+
database: "mflix",
15+
collection: "movies",
3016
},
3117
},
3218
],
3319
};
3420
}
3521

36-
describeAccuracyTests("collection-indexes", getAvailableModels(), [
37-
callsCollectionIndexes("How many indexes do I have in 'db1.coll1' namespace?"),
38-
callsCollectionIndexes("List all the indexes in coll1 collection in db1 database"),
39-
callsCollectionIndexes(
40-
`Is the following query: ${JSON.stringify({ year: 1994 })} on the namespace 'db1.coll1' indexed?`
41-
),
42-
]);
22+
describeAccuracyTests(getAvailableModels(), {
23+
...describeSuite("should call 'collection-indexes' tool", [
24+
callsCollectionIndexes("How many indexes do I have in 'mflix.movies' namespace?"),
25+
callsCollectionIndexes("List all the indexes in movies collection in mflix database"),
26+
callsCollectionIndexes(
27+
`Is the following query: ${JSON.stringify({ runtime: { $lt: 100 } })} on the namespace 'mflix.movies' indexed?`
28+
),
29+
]),
30+
});

tests/accuracy/collection-schema.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describeAccuracyTests } from "./sdk/describe-accuracy-tests.js";
1+
import { describeAccuracyTests, describeSuite } from "./sdk/describe-accuracy-tests.js";
22
import { getAvailableModels } from "./sdk/models.js";
33
import { AccuracyTestConfig } from "./sdk/describe-accuracy-tests.js";
44
import { collectionSchemaResponse } from "../../src/tools/mongodb/metadata/collectionSchema.js";
@@ -41,7 +41,9 @@ function callsCollectionSchema(prompt: string): AccuracyTestConfig {
4141
};
4242
}
4343

44-
describeAccuracyTests("collection-schema", getAvailableModels(), [
45-
callsCollectionSchema("Is there a title field in 'db1.coll1' namespace?"),
46-
callsCollectionSchema("What is the type of value stored in title field in coll1 collection in db1 database?"),
47-
]);
44+
describeAccuracyTests(getAvailableModels(), {
45+
...describeSuite("should call 'collection-schema' tool", [
46+
callsCollectionSchema("Is there a title field in 'db1.coll1' namespace?"),
47+
callsCollectionSchema("What is the type of value stored in title field in coll1 collection in db1 database?"),
48+
]),
49+
});

tests/accuracy/delete-many.test.ts

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describeAccuracyTests } from "./sdk/describe-accuracy-tests.js";
1+
import { describeAccuracyTests, describeSuite } from "./sdk/describe-accuracy-tests.js";
22
import { getAvailableModels } from "./sdk/models.js";
33
import { AccuracyTestConfig } from "./sdk/describe-accuracy-tests.js";
44
import { deleteManyResponse } from "../../src/tools/mongodb/delete/deleteMany.js";
@@ -7,17 +7,13 @@ function callsDeleteManyWithEmptyFilters(prompt: string): AccuracyTestConfig {
77
return {
88
injectConnectedAssumption: true,
99
prompt: prompt,
10-
mockedTools: {
11-
"delete-many": function listDatabases() {
12-
return deleteManyResponse("coll1", 10);
13-
},
14-
},
10+
mockedTools: {},
1511
expectedToolCalls: [
1612
{
1713
toolName: "delete-many",
1814
parameters: {
19-
database: "db1",
20-
collection: "coll1",
15+
database: "mflix",
16+
collection: "movies",
2117
},
2218
},
2319
],
@@ -28,26 +24,26 @@ function callsDeleteManyWithFilters(prompt: string): AccuracyTestConfig {
2824
return {
2925
injectConnectedAssumption: true,
3026
prompt: prompt,
31-
mockedTools: {
32-
"delete-many": function listDatabases() {
33-
return deleteManyResponse("coll1", 10);
34-
},
35-
},
27+
mockedTools: {},
3628
expectedToolCalls: [
3729
{
3830
toolName: "delete-many",
3931
parameters: {
40-
database: "db1",
41-
collection: "coll1",
42-
filters: { provider: "BongoDB" },
32+
database: "mflix",
33+
collection: "movies",
34+
filter: { runtime: { $lt: 100 } },
4335
},
4436
},
4537
],
4638
};
4739
}
4840

49-
describeAccuracyTests("delete-many", getAvailableModels(), [
50-
callsDeleteManyWithEmptyFilters("Delete all the documents from 'db1.coll1' namespace"),
51-
callsDeleteManyWithEmptyFilters("Purge the collection 'coll1' in database 'db1'"),
52-
callsDeleteManyWithFilters("Remove all the documents from namespace 'db1.coll1' where provider is 'BongoDB'"),
53-
]);
41+
describeAccuracyTests(getAvailableModels(), {
42+
...describeSuite("should call 'delete-many' tool", [
43+
callsDeleteManyWithEmptyFilters("Delete all the documents from 'mflix.movies' namespace"),
44+
callsDeleteManyWithEmptyFilters("Purge the collection 'movies' in database 'mflix'"),
45+
callsDeleteManyWithFilters(
46+
"Remove all the documents from namespace 'mflix.movies' where runtime is less than 100"
47+
),
48+
]),
49+
});

tests/accuracy/find.test.ts

Lines changed: 61 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,157 +1,129 @@
1-
import { describeAccuracyTests } from "./sdk/describe-accuracy-tests.js";
1+
import { describeAccuracyTests, describeSuite } from "./sdk/describe-accuracy-tests.js";
22
import { getAvailableModels } from "./sdk/models.js";
33
import { AccuracyTestConfig } from "./sdk/describe-accuracy-tests.js";
4-
import { findResponse } from "../../src/tools/mongodb/read/find.js";
5-
import { MockedTools } from "./sdk/test-tools.js";
6-
import { collectionSchemaResponse } from "../../src/tools/mongodb/metadata/collectionSchema.js";
7-
import { getSimplifiedSchema } from "mongodb-schema";
84

9-
const documents = [
10-
{
11-
title: "book1",
12-
author: "author1",
13-
date_of_publish: "01.01.1990",
14-
},
15-
{
16-
title: "book2",
17-
author: "author1",
18-
date_of_publish: "01.01.1992",
19-
},
20-
{
21-
title: "book3",
22-
author: "author2",
23-
date_of_publish: "01.01.1990",
24-
},
25-
];
26-
27-
function callsFindNoFilter(prompt: string): AccuracyTestConfig {
5+
function callsFindNoFilter(prompt: string, database = "mflix", collection = "movies"): AccuracyTestConfig {
286
return {
297
injectConnectedAssumption: true,
308
prompt: prompt,
31-
mockedTools: {
32-
"collection-schema": async () =>
33-
collectionSchemaResponse("db1", "coll1", await getSimplifiedSchema(documents)),
34-
find: () => findResponse("coll1", documents),
35-
},
9+
mockedTools: {},
3610
expectedToolCalls: [
3711
{
3812
toolName: "find",
3913
parameters: {
40-
database: "db1",
41-
collection: "coll1",
14+
database,
15+
collection,
4216
},
4317
},
4418
],
4519
};
4620
}
4721

48-
function callsFindWithFilter(prompt: string): AccuracyTestConfig {
22+
function callsFindWithFilter(prompt: string, filter: Record<string, unknown>): AccuracyTestConfig {
4923
return {
5024
injectConnectedAssumption: true,
5125
prompt: prompt,
52-
mockedTools: {
53-
"collection-schema": async () =>
54-
collectionSchemaResponse("db1", "coll1", await getSimplifiedSchema(documents)),
55-
find: () =>
56-
findResponse(
57-
"coll1",
58-
documents.filter((doc) => doc.author === "author1")
59-
),
60-
},
26+
mockedTools: {},
6127
expectedToolCalls: [
6228
{
6329
toolName: "find",
6430
parameters: {
65-
database: "db1",
66-
collection: "coll1",
67-
filter: { author: "author1" },
31+
database: "mflix",
32+
collection: "movies",
33+
filter: filter,
6834
},
6935
},
7036
],
7137
};
7238
}
7339

74-
function callsFindWithProjection(prompt: string): AccuracyTestConfig {
40+
function callsFindWithProjection(prompt: string, projection: Record<string, number>): AccuracyTestConfig {
7541
return {
7642
injectConnectedAssumption: true,
7743
prompt: prompt,
78-
mockedTools: {
79-
"collection-schema": async () =>
80-
collectionSchemaResponse("db1", "coll1", await getSimplifiedSchema(documents)),
81-
find: () => findResponse("coll1", documents),
82-
},
44+
mockedTools: {},
8345
expectedToolCalls: [
8446
{
8547
toolName: "find",
8648
parameters: {
87-
database: "db1",
88-
collection: "coll1",
89-
projection: { title: 1 },
49+
database: "mflix",
50+
collection: "movies",
51+
projection,
9052
},
9153
},
9254
],
9355
};
9456
}
9557

96-
function callsFindWithProjectionAndFilters(prompt: string): AccuracyTestConfig {
58+
function callsFindWithProjectionAndFilters(
59+
prompt: string,
60+
filter: Record<string, unknown>,
61+
projection: Record<string, number>
62+
): AccuracyTestConfig {
9763
return {
9864
injectConnectedAssumption: true,
9965
prompt: prompt,
100-
mockedTools: {
101-
"collection-schema": async () =>
102-
collectionSchemaResponse("db1", "coll1", await getSimplifiedSchema(documents)),
103-
find: () =>
104-
findResponse(
105-
"coll1",
106-
documents.filter((doc) => doc.date_of_publish === "01.01.1992")
107-
),
108-
},
66+
mockedTools: {},
10967
expectedToolCalls: [
11068
{
11169
toolName: "find",
11270
parameters: {
113-
database: "db1",
114-
collection: "coll1",
115-
filter: { date_of_publish: "01.01.1992" },
116-
projection: { title: 1 },
71+
database: "mflix",
72+
collection: "movies",
73+
filter,
74+
projection,
11775
},
11876
},
11977
],
12078
};
12179
}
12280

123-
function callsFindWithSortAndLimit(prompt: string): AccuracyTestConfig {
81+
function callsFindWithFilterSortAndLimit(
82+
prompt: string,
83+
filter: Record<string, unknown>,
84+
sort: Record<string, number>,
85+
limit: number
86+
): AccuracyTestConfig {
12487
return {
12588
injectConnectedAssumption: true,
12689
prompt: prompt,
127-
mockedTools: {
128-
"collection-schema": async () =>
129-
collectionSchemaResponse("db1", "coll1", await getSimplifiedSchema(documents)),
130-
find: () => findResponse("coll1", [documents[0], documents[1]]),
131-
},
90+
mockedTools: {},
13291
expectedToolCalls: [
13392
{
13493
toolName: "find",
13594
parameters: {
136-
database: "db1",
137-
collection: "coll1",
138-
sort: { date_of_publish: 1 },
139-
limit: 2,
95+
database: "mflix",
96+
collection: "movies",
97+
filter,
98+
sort,
99+
limit,
140100
},
141101
},
142102
],
143103
};
144104
}
145105

146-
describeAccuracyTests("find", getAvailableModels(), [
147-
callsFindNoFilter("List all the documents in 'db1.coll1' namespace"),
148-
callsFindNoFilter("Find all the documents from collection coll1 in database db1"),
149-
callsFindWithFilter("Find all the books published by author name 'author1' in db1.coll1 namespace"),
150-
callsFindWithFilter("Find all the documents in coll1 collection and db1 database where author is 'author1'"),
151-
callsFindWithProjection("Give me all the title of the books available in 'db1.coll1' namespace"),
152-
callsFindWithProjection("Give me all the title of the books published in available in 'db1.coll1' namespace"),
153-
callsFindWithProjectionAndFilters(
154-
"Find all the book titles from 'db1.coll1' namespace where date_of_publish is '01.01.1992'"
155-
),
156-
callsFindWithSortAndLimit("List first two books sorted by the field date_of_publish in namespace db1.coll1"),
157-
]);
106+
describeAccuracyTests(getAvailableModels(), {
107+
...describeSuite("should only call find tool", [
108+
callsFindNoFilter("List all the movies in 'mflix.movies' namespace."),
109+
callsFindNoFilter("List all the documents in 'comics.books' namespace.", "comics", "books"),
110+
callsFindWithFilter("Find all the movies in 'mflix.movies' namespace with runtime less than 100.", {
111+
runtime: { $lt: 100 },
112+
}),
113+
callsFindWithFilter("Find all movies in 'mflix.movies' collection where director is 'Christina Collins'", {
114+
director: "Christina Collins",
115+
}),
116+
callsFindWithProjection("Give me all the movie titles available in 'mflix.movies' namespace", { title: 1 }),
117+
callsFindWithProjectionAndFilters(
118+
"Use 'mflix.movies' namespace to answer who were casted in the movie 'Certain Fish'",
119+
{ title: "Certain Fish" },
120+
{ cast: 1 }
121+
),
122+
callsFindWithFilterSortAndLimit(
123+
"From the mflix.movies namespace, give me first 2 movies of Horror genre sorted ascending by their runtime",
124+
{ genres: "Horror" },
125+
{ runtime: 1 },
126+
2
127+
),
128+
]),
129+
});

0 commit comments

Comments
 (0)