Skip to content

Commit fc9325c

Browse files
committed
chore: more accuracy test tweaks
1 parent 17b595b commit fc9325c

File tree

12 files changed

+61
-10
lines changed

12 files changed

+61
-10
lines changed

src/tools/mongodb/metadata/collectionSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class CollectionSchemaTool extends MongoDBToolBase {
2121
.optional()
2222
.default(ONE_MB)
2323
.describe(
24-
`The maximum number of bytes to return in the response. This value is capped by the servers configured maxBytesPerQuery and cannot be exceeded.`
24+
`The maximum number of bytes to return in the response. This value is capped by the server's configured maxBytesPerQuery and cannot be exceeded.`
2525
),
2626
};
2727

src/tools/mongodb/read/aggregate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { LogId } from "../../../common/logger.js";
1717
export const AggregateArgs = {
1818
pipeline: z.array(zEJSON()).describe("An array of aggregation stages to execute"),
1919
responseBytesLimit: z.number().optional().default(ONE_MB).describe(`\
20-
The maximum number of bytes to return in the response. This value is capped by the servers configured maxBytesPerQuery and cannot be exceeded. \
20+
The maximum number of bytes to return in the response. This value is capped by the server's configured maxBytesPerQuery and cannot be exceeded. \
2121
Note to LLM: If the entire aggregation result is required, use the "export" tool instead of increasing this limit.\
2222
`),
2323
};

src/tools/mongodb/read/find.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const FindArgs = {
3030
"A document, describing the sort order, matching the syntax of the sort argument of cursor.sort(). The keys of the object are the fields to sort on, while the values are the sort directions (1 for ascending, -1 for descending)."
3131
),
3232
responseBytesLimit: z.number().optional().default(ONE_MB).describe(`\
33-
The maximum number of bytes to return in the response. This value is capped by the servers configured maxBytesPerQuery and cannot be exceeded. \
33+
The maximum number of bytes to return in the response. This value is capped by the server's configured maxBytesPerQuery and cannot be exceeded. \
3434
Note to LLM: If the entire query result is required, use the "export" tool instead of increasing this limit.\
3535
`),
3636
};

tests/accuracy/collectionSchema.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,41 @@
11
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
2+
import { Matcher } from "./sdk/matcher.js";
3+
4+
const listCollectionsOptionalCall = {
5+
toolName: "list-collections",
6+
parameters: {
7+
database: "mflix",
8+
},
9+
optional: true,
10+
};
211

312
describeAccuracyTests([
413
{
514
prompt: "Is there a title field in 'mflix.movies' namespace?",
615
expectedToolCalls: [
16+
listCollectionsOptionalCall,
717
{
818
toolName: "collection-schema",
919
parameters: {
1020
database: "mflix",
1121
collection: "movies",
22+
sampleSize: Matcher.anyOf(Matcher.undefined, Matcher.number()),
23+
responseBytesLimit: Matcher.anyOf(Matcher.undefined, Matcher.number()),
1224
},
1325
},
1426
],
1527
},
1628
{
1729
prompt: "What is the type of value stored in title field in movies collection in mflix database?",
1830
expectedToolCalls: [
31+
listCollectionsOptionalCall,
1932
{
2033
toolName: "collection-schema",
2134
parameters: {
2235
database: "mflix",
2336
collection: "movies",
37+
sampleSize: Matcher.anyOf(Matcher.undefined, Matcher.number()),
38+
responseBytesLimit: Matcher.anyOf(Matcher.undefined, Matcher.number()),
2439
},
2540
},
2641
],

tests/accuracy/explain.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ describeAccuracyTests([
4545
$match: { release_year: 2020 },
4646
},
4747
],
48+
responseBytesLimit: Matcher.anyOf(Matcher.undefined, Matcher.number()),
4849
},
4950
},
5051
],

tests/accuracy/export.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ describeAccuracyTests([
1414
exportTarget: [
1515
{
1616
name: "find",
17-
arguments: {},
17+
arguments: {
18+
filter: Matcher.emptyObjectOrUndefined,
19+
},
1820
},
1921
],
2022
jsonExportFormat: Matcher.anyValue,

tests/accuracy/find.test.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1+
import type { ExpectedToolCall } from "./sdk/accuracyResultStorage/resultStorage.js";
12
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
23
import { Matcher } from "./sdk/matcher.js";
34

5+
const optionalListCalls: (database: string) => ExpectedToolCall[] = (database) => [
6+
{
7+
toolName: "list-databases",
8+
parameters: {},
9+
optional: true,
10+
},
11+
{
12+
toolName: "list-collections",
13+
parameters: {
14+
database,
15+
},
16+
optional: true,
17+
},
18+
];
19+
420
describeAccuracyTests([
521
{
622
prompt: "List all the movies in 'mflix.movies' namespace.",
723
expectedToolCalls: [
24+
...optionalListCalls("mflix"),
825
{
926
toolName: "find",
1027
parameters: {
@@ -18,6 +35,7 @@ describeAccuracyTests([
1835
{
1936
prompt: "List all the documents in 'comics.books' namespace.",
2037
expectedToolCalls: [
38+
...optionalListCalls("comics"),
2139
{
2240
toolName: "find",
2341
parameters: {
@@ -31,6 +49,7 @@ describeAccuracyTests([
3149
{
3250
prompt: "Find all the movies in 'mflix.movies' namespace with runtime less than 100.",
3351
expectedToolCalls: [
52+
...optionalListCalls("mflix"),
3453
{
3554
toolName: "find",
3655
parameters: {
@@ -46,6 +65,7 @@ describeAccuracyTests([
4665
{
4766
prompt: "Find all movies in 'mflix.movies' collection where director is 'Christina Collins'",
4867
expectedToolCalls: [
68+
...optionalListCalls("mflix"),
4969
{
5070
toolName: "find",
5171
parameters: {
@@ -61,6 +81,7 @@ describeAccuracyTests([
6181
{
6282
prompt: "Give me all the movie titles available in 'mflix.movies' namespace",
6383
expectedToolCalls: [
84+
...optionalListCalls("mflix"),
6485
{
6586
toolName: "find",
6687
parameters: {
@@ -81,6 +102,7 @@ describeAccuracyTests([
81102
{
82103
prompt: "Use 'mflix.movies' namespace to answer who were casted in the movie 'Certain Fish'",
83104
expectedToolCalls: [
105+
...optionalListCalls("mflix"),
84106
{
85107
toolName: "find",
86108
parameters: {
@@ -99,6 +121,7 @@ describeAccuracyTests([
99121
{
100122
prompt: "From the mflix.movies namespace, give me first 2 movies of Horror genre sorted ascending by their runtime",
101123
expectedToolCalls: [
124+
...optionalListCalls("mflix"),
102125
{
103126
toolName: "find",
104127
parameters: {
@@ -112,8 +135,9 @@ describeAccuracyTests([
112135
],
113136
},
114137
{
115-
prompt: "I want a COMPLETE list of all the movies ONLY from 'mflix.movies' namespace.",
138+
prompt: "I want an exported COMPLETE list of all the movies ONLY from 'mflix.movies' namespace.",
116139
expectedToolCalls: [
140+
...optionalListCalls("mflix"),
117141
{
118142
toolName: "find",
119143
parameters: {

tests/accuracy/getPerformanceAdvisor.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
22
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3+
import { Matcher } from "./sdk/matcher.js";
34

45
// Shared mock tool implementations
56
const mockedTools = {
@@ -127,6 +128,15 @@ describeAccuracyTests([
127128
parameters: {
128129
projectId: "mflix",
129130
clusterName: "mflix-cluster",
131+
operations: Matcher.anyOf(
132+
Matcher.undefined,
133+
Matcher.value([
134+
"suggestedIndexes",
135+
"dropIndexSuggestions",
136+
"slowQueryLogs",
137+
"schemaSuggestions",
138+
])
139+
),
130140
},
131141
},
132142
],

tests/accuracy/logs.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describeAccuracyTests([
99
toolName: "mongodb-logs",
1010
parameters: {
1111
type: "startupWarnings",
12+
limit: Matcher.anyOf(Matcher.undefined, Matcher.number()),
1213
},
1314
},
1415
],

tests/integration/tools/mongodb/metadata/collectionSchema.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describeWithMongoDB("collectionSchema tool", (integration) => {
2626
{
2727
name: "responseBytesLimit",
2828
type: "number",
29-
description: `The maximum number of bytes to return in the response. This value is capped by the servers configured maxBytesPerQuery and cannot be exceeded.`,
29+
description: `The maximum number of bytes to return in the response. This value is capped by the server's configured maxBytesPerQuery and cannot be exceeded.`,
3030
required: false,
3131
},
3232
]);

0 commit comments

Comments
 (0)