@@ -16,6 +16,7 @@ import {
1616import * as constants from "../../../../../src/helpers/constants.js" ;
1717import { freshInsertDocuments } from "./find.test.js" ;
1818import { BSON } from "bson" ;
19+ import { DOCUMENT_EMBEDDINGS } from "./vyai/embeddings.js" ;
1920
2021describeWithMongoDB ( "aggregate tool" , ( integration ) => {
2122 afterEach ( ( ) => {
@@ -384,8 +385,6 @@ describeWithMongoDB(
384385 }
385386) ;
386387
387- import { DOCUMENT_EMBEDDINGS } from "./vyai/embeddings.js" ;
388-
389388describeWithMongoDB (
390389 "aggregate tool with atlas search enabled" ,
391390 ( integration ) => {
@@ -921,6 +920,69 @@ If the user requests additional filtering, include filters in \`$vectorSearch.fi
921920 ) ;
922921 } ) ;
923922 } ) ;
923+
924+ describe ( "outputDimension transformation" , ( ) => {
925+ it . each ( [
926+ { numDimensions : 2048 , outputDimension : "2048" } ,
927+ { numDimensions : 4096 , outputDimension : "4096" } ,
928+ ] ) (
929+ "should successfully transform outputDimension string '$outputDimension' to number" ,
930+ async ( { numDimensions, outputDimension } ) => {
931+ await waitUntilSearchIsReady ( integration . mongoClient ( ) ) ;
932+
933+ const collection = integration . mongoClient ( ) . db ( integration . randomDbName ( ) ) . collection ( "databases" ) ;
934+ await collection . insertOne ( { name : "mongodb" , description_embedding : DOCUMENT_EMBEDDINGS . float } ) ;
935+
936+ await createVectorSearchIndexAndWait (
937+ integration . mongoClient ( ) ,
938+ integration . randomDbName ( ) ,
939+ "databases" ,
940+ [
941+ {
942+ type : "vector" ,
943+ path : "description_embedding" ,
944+ numDimensions,
945+ similarity : "cosine" ,
946+ quantization : "none" ,
947+ } ,
948+ ]
949+ ) ;
950+
951+ await integration . connectMcpClient ( ) ;
952+ const response = await integration . mcpClient ( ) . callTool ( {
953+ name : "aggregate" ,
954+ arguments : {
955+ database : integration . randomDbName ( ) ,
956+ collection : "databases" ,
957+ pipeline : [
958+ {
959+ $vectorSearch : {
960+ index : "default" ,
961+ path : "description_embedding" ,
962+ queryVector : "example query" ,
963+ numCandidates : 10 ,
964+ limit : 10 ,
965+ embeddingParameters : {
966+ model : "voyage-3-large" ,
967+ outputDimension, // Pass as string literal
968+ } ,
969+ } ,
970+ } ,
971+ {
972+ $project : {
973+ description_embedding : 0 ,
974+ } ,
975+ } ,
976+ ] ,
977+ } ,
978+ } ) ;
979+
980+ const responseContent = getResponseContent ( response ) ;
981+ // String should succeed and be transformed to number internally
982+ expect ( responseContent ) . toContain ( "The aggregation resulted in" ) ;
983+ }
984+ ) ;
985+ } ) ;
924986 } ,
925987 {
926988 getUserConfig : ( ) => ( {
0 commit comments