import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
import { Matcher } from "./sdk/matcher.js";
import { mockListKnowledgeSourcesResult } from "./listKnowledgeSources.test.js";
import { SearchKnowledgeToolName } from "../../src/tools/assistant/searchKnowledge.js";
import { ListKnowledgeSourcesToolName } from "../../src/tools/assistant/listKnowledgeSources.js";
import type { MockedTools } from "./sdk/accuracyTestingClient.js";
export const mockSearchKnowledgeResult: CallToolResult = {
content: [
{
type: "text",
text: "Found 2 results in the MongoDB Assistant knowledge base.",
},
{
type: "text",
text: `<untrusted-user-data-mock>{"results":[{"url":"mongodb.com/try/download/community","title":"MongoDB Community Server Download","text":"---\ncontentType: article\nsiteTitle: MongoDB\ndescription: Download MongoDB Community Server non-relational database to take\n your next big project to a higher level!\ntype: Products\npageTitle: MongoDB Community Server Download\nhasCodeBlock: false\n---\n\n## Try MongoDB Community Edition\n\nThe community version of our distributed document database provides powerful ways to query and analyze your data.\n\n### MongoDB Community Server\n\n# MongoDB Community Server Download\n\nThe Community version of our distributed database offers a flexible document data model along with support for ad-hoc queries, secondary indexing, and real-time aggregations to provide powerful ways to access and analyze your data.\n\n* * *\n\n \n\nTo download MongoDB Community Server, use the download link below, and read the installation documentation.\n\nOr get started with MongoDB Atlas (on macOS) from your MongoDB terminal with the following two commands:\n\nCode Snippet$ brew install mongodb-atlas\n$ atlas setup\n\n$ brew install mongodb\\-atlas\n\n$ atlas setup\n\ncopy\n\nNot on macOS? See installation options.\n\nThe database is also offered as a fully managed service with MongoDB Atlas. Get access to advanced functionality such as auto-scale, full-text search, and data distribution across regions and clouds. Deploy in minutes on AWS, Google Cloud, and/or Azure, with no downloads necessary.\n\n8.2.5 (current)Versionchevron-down\n\n- 8.2.5 (current)check\n- 8.0.19\n- 7.0.30\n- 6.0.27\n- 5.0.32\n- 4.4.30\n\nAmazon Linux 2023 x64Platformchevron-down\n\n- Amazon Linux 2023 ARM 64\n- Amazon Linux 2023 x64check\n- Debian 12.0 x64\n- macOS ARM 64\n- macOS x64\n- RedHat / CentOS 8.0 ARM 64\n- RedHat / CentOS 8.0 x64\n- RedHat / CentOS 9.3 ARM 64\n- RedHat / CentOS 9.3 x64\n- SUSE 15 x64\n- Ubuntu 20.04 ARM 64\n- Ubuntu 20.04 x64\n- Ubuntu 22.04 ARM 64\n- Ubuntu 22.04 x64\n- Ubuntu 24.04 ARM 64\n- Ubuntu 24.04 x64\n- Windows x64\n\nserverPackagechevron-down\n\n- mongos\n- servercheck\n- tgz\n\nDownload\n\ncopy\n\nCopy link\n\nMore Options\n\nmenu-horizontal\n\nclose\n\nCurrent releases & packages\n\nDevelopment releases\n\nArchived releases\n\nChangelog\n\nRelease Notes","metadata":{"contentType":"article","siteTitle":"MongoDB","description":"Download MongoDB Community Server non-relational database to take your next big project to a higher level!","type":"Products","pageTitle":"MongoDB Community Server Download","hasCodeBlock":false}},{"url":"mongodb.com/docs/mongocli/current/install/compatibility","title":"Compatibility","text":"---\ntags:\n - docs\n - cli\n - mongocli\nproductName: MongoDB CLI\nversion:\n label: 2.0.6 (current)\n isCurrent: true\nsiteTitle: MongoCLI\npageTitle: Compatibility\nhasCodeBlock: false\n---\n\n## MongoDB Service Versions\n\nMongoDB CLI versions 1.0 and later are compatible with the following versions of Atlas, Cloud Manager, Ops Manager, and MongoDB server.\n\n<table>\n<tr>\n<th id="MongoDB%20Service">\nMongoDB Service\n\n</th>\n<th id="MongoDB%20Service%20Version">\nMongoDB Service Version\n\n</th>\n</tr>\n<tr>\n<td headers="MongoDB%20Service">\nAtlas\n\n</td>\n<td headers="MongoDB%20Service%20Version">\nCurrent\n\n</td>\n</tr>\n<tr>\n<td headers="MongoDB%20Service">\nCloud Manager\n\n</td>\n<td headers="MongoDB%20Service%20Version">\nCurrent\n\n</td>\n</tr>\n<tr>\n<td headers="MongoDB%20Service">\nOps Manager\n\n</td>\n<td headers="MongoDB%20Service%20Version">\n6.0\n\n</td>\n</tr>\n<tr>\n<td headers="MongoDB%20Service">\nMongoDB server\n\n</td>\n<td headers="MongoDB%20Service%20Version">\nAny released and stable version that has not reached its End of Life date. MongoDB CLI doesn't support rapid release MongoDB versions.\n\n</td>\n</tr>\n</table>","metadata":{"tags":["docs","cli","mongocli"],"productName":"MongoDB CLI","version":{"label":"2.0.6 (current)","isCurrent":true},"siteTitle":"MongoCLI","pageTitle":"Compatibility","hasCodeBlock":false}},{"url":"mongoosejs.com/docs/compatibility.html","title":"MongoDB Server Version Compatibility","text":"---\nproductName: Mongoose ODM\ntags:\n - node.js\n - community library\n - mongoose\n - odm\nversionLabel: v7.x (current)\npageTitle: MongoDB Server Version Compatibility\nhasCodeBlock: false\n---\n\n| MongoDB Server | Mongoose |\n| :------------: | :--------------------------------------------: |\n| \`8.x\` | \`^8.7.0 \\| ^9.0.0\` |\n| \`7.x\` | \`^7.4.0 \\| ^8.0.0 \\| ^9.0.0\` |\n| \`6.x\` | \`^7.0.0 \\| ^8.0.0 \\| ^9.0.0\` |\n| \`5.x\` | \`^6.0.0 \\| ^7.0.0 \\| ^8.0.0\` |\n| \`4.4.x\` | \`^6.0.0 \\| ^7.0.0 \\| ^8.0.0\` |\n| \`4.2.x\` | \`^6.0.0 \\| ^7.0.0 \\| ^8.0.0\` |\n| \`4.0.x\` | \`^6.0.0 \\| ^7.0.0 \\| ^8.0.0 <8.16.0\` |\n| \`3.6.x\` | \`^6.0.0 \\| ^7.0.0 \\| ^8.0.0 <8.8.0\` |","metadata":{"productName":"Mongoose ODM","tags":["node.js","community library","mongoose","odm"],"versionLabel":"v7.x (current)","pageTitle":"MongoDB Server Version Compatibility","hasCodeBlock":false}},{"url":"mongodb.com/docs/manual","title":"What is MongoDB?","text":"---\ntags:\n - docs\n - manual\nproductName: MongoDB Server\nversion:\n label: 8.2 (Current)\n isCurrent: true\nsiteTitle: Database Manual\npageTitle: What is MongoDB?\nhasCodeBlock: false\n---\n\n# What is MongoDB?\n\nMongoDB is a document database designed to help developers build modern applications faster. It stores data in flexible, JSON-like documents, making it easy to model data the same way your application code uses it. The flexible schema lets you evolve your data model without downtime, iterate quickly, and easily handle non-uniform data.\n\nMongoDB provides a powerful query engine, horizontal scaling, and built-in high availability so you can support everything from rapid prototyping to large, mission-critical workloads.\n\nMongoDB is a fully-transactional operational database that supports a wide range of workload types including:\n\n- Document-based structured search (OLTP)\n\n- Data aggregation\n\n- Full-text search\n\n- Vector search\n\n- Geospatial search\n\n- Time series","metadata":{"tags":["docs","manual"],"productName":"MongoDB Server","version":{"label":"8.2 (Current)","isCurrent":true},"siteTitle":"Database Manual","pageTitle":"What is MongoDB?","hasCodeBlock":false}},{"url":"mongodb.com/docs/manual/installation","title":"Install MongoDB","text":"---\ntags:\n - docs\n - manual\nproductName: MongoDB Server\nversion:\n label: 8.2 (Current)\n isCurrent: true\nsiteTitle: Database Manual\npageTitle: Install MongoDB\nhasCodeBlock: false\n---\n\n<tr>\n<td headers="Platform">\nWindows Server 2019\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nCommunity\n\n</td>\n<td headers="8.0">\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nmacOS 14\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nEnterprise\n\n</td>\n<td headers="8.0">\n✓\n\n</td>\n<td headers="7.0">\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nmacOS 14\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nCommunity\n\n</td>\n<td headers="8.0">\n✓\n\n</td>\n<td headers="7.0">\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nmacOS 13\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nEnterprise\n\n</td>\n<td headers="8.0">\n✓\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nmacOS 13\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nCommunity\n\n</td>\n<td headers="8.0">\n✓\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nmacOS 12\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nEnterprise\n\n</td>\n<td headers="8.0">\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>","metadata":{"tags":["docs","manual"],"productName":"MongoDB Server","version":{"label":"8.2 (Current)","isCurrent":true},"siteTitle":"Database Manual","pageTitle":"Install MongoDB","hasCodeBlock":false}},{"url":"mongodb.com/docs/manual/administration/production-notes","title":"Production Notes for Self-Managed Deployments","text":"---\ntags:\n - docs\n - manual\nproductName: MongoDB Server\nversion:\n label: 8.2 (Current)\n isCurrent: true\nsiteTitle: Database Manual\npageTitle: Production Notes for Self-Managed Deployments\nhasCodeBlock: false\n---\n\n### Recommended Platforms\n\nWhile MongoDB supports a variety of platforms, the following operating systems are recommended for production use on \`x86_64\` architecture:\n\n- Amazon Linux\n\n- Debian\n\n- RHEL (Red Hat Enterprise Linux)\n\n- SLES\n\n- Ubuntu LTS\n\n- Windows Server\n\nFor best results, run the latest version of your platform. If you run an older version, make sure that your version is supported by its provider.\n\nMongoDB on-premises products released for RHEL version 8.0+ are compatible with Rocky Linux version 8.0+ and AlmaLinux version 8.0+, contingent upon those distributions meeting their obligation to deliver full RHEL compatibility.\n\nPlatform Specific Considerations\n\n### Use the Latest Stable Packages\n\nBe sure you have the latest stable release.\n\nMongoDB releases are available on the MongoDB Download Center:\n\n- MongoDB Enterprise Advanced\n\n- MongoDB Community Edition\n\nFor details on upgrading to the most current minor release, see Upgrade to the Latest Self-Managed Patch Release of MongoDB.\n\nThe following related packages are also available on the MongoDB Download Center:\n\n- Tools\n\n- Atlas SQL Interface\n\n- Mobile & Edge\n\nFor other MongoDB products, see their respective documentation.","metadata":{"tags":["docs","manual"],"productName":"MongoDB Server","version":{"label":"8.2 (Current)","isCurrent":true},"siteTitle":"Database Manual","pageTitle":"Production Notes for Self-Managed Deployments","hasCodeBlock":false}},{"url":"mongodb.com/docs/manual/administration/production-notes","title":"Production Notes for Self-Managed Deployments","text":"---\ntags:\n - docs\n - manual\nproductName: MongoDB Server\nversion:\n label: 8.2 (Current)\n isCurrent: true\nsiteTitle: Database Manual\npageTitle: Production Notes for Self-Managed Deployments\nhasCodeBlock: false\n---\n\n<tr>\n<td headers="Platform">\nWindows Server 2019\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nCommunity\n\n</td>\n<td headers="8.0">\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nmacOS 14\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nEnterprise\n\n</td>\n<td headers="8.0">\n✓\n\n</td>\n<td headers="7.0">\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nmacOS 14\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nCommunity\n\n</td>\n<td headers="8.0">\n✓\n\n</td>\n<td headers="7.0">\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nmacOS 13\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nEnterprise\n\n</td>\n<td headers="8.0">\n✓\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nmacOS 13\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nCommunity\n\n</td>\n<td headers="8.0">\n✓\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nmacOS 12\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nEnterprise\n\n</td>\n<td headers="8.0">\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>","metadata":{"tags":["docs","manual"],"productName":"MongoDB Server","version":{"label":"8.2 (Current)","isCurrent":true},"siteTitle":"Database Manual","pageTitle":"Production Notes for Self-Managed Deployments","hasCodeBlock":false}},{"url":"mongodb.com/docs/manual/administration/production-notes","title":"Production Notes for Self-Managed Deployments","text":"---\ntags:\n - docs\n - manual\nproductName: MongoDB Server\nversion:\n label: 8.2 (Current)\n isCurrent: true\nsiteTitle: Database Manual\npageTitle: Production Notes for Self-Managed Deployments\nhasCodeBlock: false\n---\n\n## Platform Support Matrix\n\nStarting in MongoDB 8.0, new MongoDB Server versions (major and minor) support the minimum operating system (OS) minor version defined by the OS vendor. After an OS minor version is no longer supported by the OS vendor, MongoDB updates the MongoDB Server to support the next OS minor version. For details, see MongoDB Platform Support Improvements.\n\nMongoDB 8.0 supports the following minimum OS minor versions:\n\n- Red Hat Enterprise Linux 8.8\n\n- Red Hat Enterprise Linux 9.3\n\n- SUSE Linux Enterprise Server 15 SP5\n\n- Amazon Linux 2023 version 2023.3\n\nv6.0 reached end of life on July 31, 2025 and is no longer supported by MongoDB.","metadata":{"tags":["docs","manual"],"productName":"MongoDB Server","version":{"label":"8.2 (Current)","isCurrent":true},"siteTitle":"Database Manual","pageTitle":"Production Notes for Self-Managed Deployments","hasCodeBlock":false}},{"url":"mongodb.com/docs/manual/reference/method/db.version","title":"db.version() (mongosh method)","text":"---\ntags:\n - docs\n - manual\nproductName: MongoDB Server\nversion:\n label: 8.2 (Current)\n isCurrent: true\nsiteTitle: Database Manual\npageTitle: db.version() (mongosh method)\nhasCodeBlock: false\n---\n\n# db.version() (mongosh method)\n\n\`db.version()\`\nThe version of the \`mongod\` or \`mongos\` instance.\n\n## Compatibility\n\nThis method is available in deployments hosted in the following environments:\n\n- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud\n\nThis command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.\n\n- MongoDB Enterprise: The subscription-based, self-managed version of MongoDB\n\n- MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB","metadata":{"tags":["docs","manual"],"productName":"MongoDB Server","version":{"label":"8.2 (Current)","isCurrent":true},"siteTitle":"Database Manual","pageTitle":"db.version() (mongosh method)","hasCodeBlock":false}},{"url":"mongodb.com/docs/manual/installation","title":"Install MongoDB","text":"---\ntags:\n - docs\n - manual\nproductName: MongoDB Server\nversion:\n label: 8.2 (Current)\n isCurrent: true\nsiteTitle: Database Manual\npageTitle: Install MongoDB\nhasCodeBlock: false\n---\n\n<tr>\n<td headers="Platform">\nUbuntu 20.04\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nCommunity\n\n</td>\n<td headers="8.0">\n✓\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nWindows 11\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nEnterprise\n\n</td>\n<td headers="8.0">\n✓\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nWindows 11\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nCommunity\n\n</td>\n<td headers="8.0">\n✓\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nWindows Server 2022\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nEnterprise\n\n</td>\n<td headers="8.0">\n✓\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nWindows Server 2022\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nCommunity\n\n</td>\n<td headers="8.0">\n✓\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>\n<tr>\n<td headers="Platform">\nWindows Server 2019\n\n</td>\n<td headers="Architecture">\nx86_64\n\n</td>\n<td headers="Edition">\nEnterprise\n\n</td>\n<td headers="8.0">\n\n</td>\n<td headers="7.0">\n✓\n\n</td>\n</tr>","metadata":{"tags":["docs","manual"],"productName":"MongoDB Server","version":{"label":"8.2 (Current)","isCurrent":true},"siteTitle":"Database Manual","pageTitle":"Install MongoDB","hasCodeBlock":false}}]}</untrusted-user-data-mock>`,
},
],
};
interface MockedSearchKnowledgeToolCall {
toolName: "search-knowledge";
parameters: {
query: Matcher;
limit: Matcher;
dataSources: Matcher;
};
}
function expectSearchKnowledgeToolCall(
args?: Partial<MockedSearchKnowledgeToolCall["parameters"]>
): MockedSearchKnowledgeToolCall {
return {
toolName: "search-knowledge",
parameters: {
query: args?.query ?? Matcher.string(),
limit: args?.limit ?? Matcher.number(),
dataSources: args?.dataSources ?? Matcher.anyOf(Matcher.undefined, Matcher.anyValue),
},
};
}
const mockedTools: MockedTools = {
[SearchKnowledgeToolName]: (): CallToolResult => mockListKnowledgeSourcesResult,
[ListKnowledgeSourcesToolName]: (): CallToolResult => mockListKnowledgeSourcesResult,
};
describeAccuracyTests([
{
prompt: "Search the MongoDB documentation for aggregation pipeline stages",
expectedToolCalls: [expectSearchKnowledgeToolCall()],
mockedTools,
},
{
prompt: "Find information about MongoDB indexes in the knowledge base",
expectedToolCalls: [expectSearchKnowledgeToolCall()],
mockedTools,
},
{
prompt: "Look up how to create a compound index in MongoDB docs",
expectedToolCalls: [expectSearchKnowledgeToolCall()],
mockedTools,
},
{
prompt: "Search the MongoDB knowledge base for information about replication",
expectedToolCalls: [expectSearchKnowledgeToolCall()],
mockedTools,
},
{
prompt: "What is the latest version of MongoDB?",
expectedToolCalls: [expectSearchKnowledgeToolCall()],
mockedTools,
},
]);