Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/mongodb/metadata/collectionSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class CollectionSchemaTool extends MongoDBToolBase {
.optional()
.default(ONE_MB)
.describe(
`The maximum number of bytes to return in the response. This value is capped by the servers configured maxBytesPerQuery and cannot be exceeded.`
`The maximum number of bytes to return in the response. This value is capped by the server's configured maxBytesPerQuery and cannot be exceeded.`
),
};

Expand Down
2 changes: 1 addition & 1 deletion src/tools/mongodb/read/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { LogId } from "../../../common/logger.js";
export const AggregateArgs = {
pipeline: z.array(zEJSON()).describe("An array of aggregation stages to execute"),
responseBytesLimit: z.number().optional().default(ONE_MB).describe(`\
The maximum number of bytes to return in the response. This value is capped by the servers configured maxBytesPerQuery and cannot be exceeded. \
The maximum number of bytes to return in the response. This value is capped by the server's configured maxBytesPerQuery and cannot be exceeded. \
Note to LLM: If the entire aggregation result is required, use the "export" tool instead of increasing this limit.\
`),
};
Expand Down
2 changes: 1 addition & 1 deletion src/tools/mongodb/read/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const FindArgs = {
"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)."
),
responseBytesLimit: z.number().optional().default(ONE_MB).describe(`\
The maximum number of bytes to return in the response. This value is capped by the servers configured maxBytesPerQuery and cannot be exceeded. \
The maximum number of bytes to return in the response. This value is capped by the server's configured maxBytesPerQuery and cannot be exceeded. \
Note to LLM: If the entire query result is required, use the "export" tool instead of increasing this limit.\
`),
};
Expand Down
15 changes: 15 additions & 0 deletions tests/accuracy/collectionSchema.test.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
import { Matcher } from "./sdk/matcher.js";

const listCollectionsOptionalCall = {
toolName: "list-collections",
parameters: {
database: "mflix",
},
optional: true,
};

describeAccuracyTests([
{
prompt: "Is there a title field in 'mflix.movies' namespace?",
expectedToolCalls: [
listCollectionsOptionalCall,
{
toolName: "collection-schema",
parameters: {
database: "mflix",
collection: "movies",
sampleSize: Matcher.anyOf(Matcher.undefined, Matcher.number()),
responseBytesLimit: Matcher.anyOf(Matcher.undefined, Matcher.number()),
},
},
],
},
{
prompt: "What is the type of value stored in title field in movies collection in mflix database?",
expectedToolCalls: [
listCollectionsOptionalCall,
{
toolName: "collection-schema",
parameters: {
database: "mflix",
collection: "movies",
sampleSize: Matcher.anyOf(Matcher.undefined, Matcher.number()),
responseBytesLimit: Matcher.anyOf(Matcher.undefined, Matcher.number()),
},
},
],
Expand Down
1 change: 1 addition & 0 deletions tests/accuracy/explain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describeAccuracyTests([
$match: { release_year: 2020 },
},
],
responseBytesLimit: Matcher.anyOf(Matcher.undefined, Matcher.number()),
},
},
],
Expand Down
4 changes: 3 additions & 1 deletion tests/accuracy/export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ describeAccuracyTests([
exportTarget: [
{
name: "find",
arguments: {},
arguments: {
filter: Matcher.emptyObjectOrUndefined,
},
},
],
jsonExportFormat: Matcher.anyValue,
Expand Down
26 changes: 25 additions & 1 deletion tests/accuracy/find.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import type { ExpectedToolCall } from "./sdk/accuracyResultStorage/resultStorage.js";
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
import { Matcher } from "./sdk/matcher.js";

const optionalListCalls: (database: string) => ExpectedToolCall[] = (database) => [
{
toolName: "list-databases",
parameters: {},
optional: true,
},
{
toolName: "list-collections",
parameters: {
database,
},
optional: true,
},
];

describeAccuracyTests([
{
prompt: "List all the movies in 'mflix.movies' namespace.",
expectedToolCalls: [
...optionalListCalls("mflix"),
{
toolName: "find",
parameters: {
Expand All @@ -18,6 +35,7 @@ describeAccuracyTests([
{
prompt: "List all the documents in 'comics.books' namespace.",
expectedToolCalls: [
...optionalListCalls("comics"),
{
toolName: "find",
parameters: {
Expand All @@ -31,6 +49,7 @@ describeAccuracyTests([
{
prompt: "Find all the movies in 'mflix.movies' namespace with runtime less than 100.",
expectedToolCalls: [
...optionalListCalls("mflix"),
{
toolName: "find",
parameters: {
Expand All @@ -46,6 +65,7 @@ describeAccuracyTests([
{
prompt: "Find all movies in 'mflix.movies' collection where director is 'Christina Collins'",
expectedToolCalls: [
...optionalListCalls("mflix"),
{
toolName: "find",
parameters: {
Expand All @@ -61,6 +81,7 @@ describeAccuracyTests([
{
prompt: "Give me all the movie titles available in 'mflix.movies' namespace",
expectedToolCalls: [
...optionalListCalls("mflix"),
{
toolName: "find",
parameters: {
Expand All @@ -81,6 +102,7 @@ describeAccuracyTests([
{
prompt: "Use 'mflix.movies' namespace to answer who were casted in the movie 'Certain Fish'",
expectedToolCalls: [
...optionalListCalls("mflix"),
{
toolName: "find",
parameters: {
Expand All @@ -99,6 +121,7 @@ describeAccuracyTests([
{
prompt: "From the mflix.movies namespace, give me first 2 movies of Horror genre sorted ascending by their runtime",
expectedToolCalls: [
...optionalListCalls("mflix"),
{
toolName: "find",
parameters: {
Expand All @@ -112,8 +135,9 @@ describeAccuracyTests([
],
},
{
prompt: "I want a COMPLETE list of all the movies ONLY from 'mflix.movies' namespace.",
prompt: "I want an exported COMPLETE list of all the movies ONLY from 'mflix.movies' namespace.",
expectedToolCalls: [
...optionalListCalls("mflix"),
{
toolName: "find",
parameters: {
Expand Down
10 changes: 10 additions & 0 deletions tests/accuracy/getPerformanceAdvisor.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import { Matcher } from "./sdk/matcher.js";

// Shared mock tool implementations
const mockedTools = {
Expand Down Expand Up @@ -127,6 +128,15 @@ describeAccuracyTests([
parameters: {
projectId: "mflix",
clusterName: "mflix-cluster",
operations: Matcher.anyOf(
Matcher.undefined,
Matcher.value([
"suggestedIndexes",
"dropIndexSuggestions",
"slowQueryLogs",
"schemaSuggestions",
])
),
},
},
],
Expand Down
1 change: 1 addition & 0 deletions tests/accuracy/logs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describeAccuracyTests([
toolName: "mongodb-logs",
parameters: {
type: "startupWarnings",
limit: Matcher.anyOf(Matcher.undefined, Matcher.number()),
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describeWithMongoDB("collectionSchema tool", (integration) => {
{
name: "responseBytesLimit",
type: "number",
description: `The maximum number of bytes to return in the response. This value is capped by the servers configured maxBytesPerQuery and cannot be exceeded.`,
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.`,
required: false,
},
]);
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/tools/mongodb/read/aggregate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ describeWithMongoDB("aggregate tool", (integration) => {
},
{
name: "responseBytesLimit",
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. Note to LLM: If the entire aggregation result is required, use the "export" tool instead of increasing this limit.',
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. Note to LLM: If the entire aggregation result is required, use the "export" tool instead of increasing this limit.`,
type: "number",
required: false,
},
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/tools/mongodb/read/find.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ describeWithMongoDB("find tool with default configuration", (integration) => {
},
{
name: "responseBytesLimit",
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. Note to LLM: If the entire query result is required, use the "export" tool instead of increasing this limit.',
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. Note to LLM: If the entire query result is required, use the "export" tool instead of increasing this limit.`,
type: "number",
required: false,
},
Expand Down
Loading