Skip to main content
Glama

MongoDB MCP Server

Official
by mongodb-js
find.test.ts5.97 kB
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: { database: "mflix", collection: "movies", filter: Matcher.emptyObjectOrUndefined, }, }, ], }, { prompt: "List all the documents in 'comics.books' namespace.", expectedToolCalls: [ ...optionalListCalls("comics"), { toolName: "find", parameters: { database: "comics", collection: "books", filter: Matcher.emptyObjectOrUndefined, }, }, ], }, { prompt: "Find all the movies in 'mflix.movies' namespace with runtime less than 100.", expectedToolCalls: [ ...optionalListCalls("mflix"), { toolName: "find", parameters: { database: "mflix", collection: "movies", filter: { runtime: { $lt: 100 }, }, }, }, ], }, { prompt: "Find all movies in 'mflix.movies' collection where director is 'Christina Collins'", expectedToolCalls: [ ...optionalListCalls("mflix"), { toolName: "find", parameters: { database: "mflix", collection: "movies", filter: { director: "Christina Collins", }, }, }, ], }, { prompt: "Give me all the movie titles available in 'mflix.movies' namespace", expectedToolCalls: [ ...optionalListCalls("mflix"), { toolName: "find", parameters: { database: "mflix", collection: "movies", projection: { title: 1, _id: Matcher.anyOf( Matcher.undefined, Matcher.number((value) => value === 0) ), }, filter: Matcher.emptyObjectOrUndefined, }, }, ], }, { prompt: "Use 'mflix.movies' namespace to answer who were casted in the movie 'Certain Fish'", expectedToolCalls: [ ...optionalListCalls("mflix"), { toolName: "find", parameters: { database: "mflix", collection: "movies", filter: { title: "Certain Fish" }, projection: { cast: 1, _id: Matcher.anyValue, }, limit: Matcher.anyValue, }, }, ], }, { 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: { database: "mflix", collection: "movies", filter: { genres: "Horror" }, sort: { runtime: 1 }, limit: 2, }, }, ], }, { prompt: "I want an exported COMPLETE list of all the movies ONLY from 'mflix.movies' namespace.", expectedToolCalls: [ ...optionalListCalls("mflix"), { toolName: "find", parameters: { database: "mflix", collection: "movies", filter: Matcher.anyValue, projection: Matcher.anyValue, limit: Matcher.anyValue, sort: Matcher.anyValue, }, optional: true, }, { toolName: "export", parameters: { database: "mflix", collection: "movies", exportTitle: Matcher.string(), exportTarget: [ { name: "find", arguments: Matcher.anyOf( Matcher.emptyObjectOrUndefined, Matcher.value({ filter: Matcher.emptyObjectOrUndefined, projection: Matcher.anyValue, limit: Matcher.anyValue, sort: Matcher.anyValue, }) ), }, ], jsonExportFormat: Matcher.anyOf( Matcher.undefined, Matcher.value("relaxed"), Matcher.value("canonical") ), }, }, ], }, ]);

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mongodb-js/mongodb-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server