@@ -3,34 +3,32 @@ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
33import { MongoDBToolBase } from "../mongodbTool.js" ;
44import { ToolArgs } from "../../tool.js" ;
55
6- const argsShape = {
7- collection : z . string ( ) . describe ( "Collection name" ) ,
8- database : z . string ( ) . describe ( "Database name" ) ,
9- filter : z
10- . object ( { } )
11- . passthrough ( )
12- . optional ( )
13- . describe ( "The query filter, matching the syntax of the query argument of db.collection.find()" ) ,
14- projection : z
15- . object ( { } )
16- . passthrough ( )
17- . optional ( )
18- . describe ( "The projection, matching the syntax of the projection argument of db.collection.find()" ) ,
19- limit : z . number ( ) . optional ( ) . default ( 10 ) . describe ( "The maximum number of documents to return" ) ,
20- } ;
21-
22- export class FindTool extends MongoDBToolBase < typeof argsShape > {
6+ export class FindTool extends MongoDBToolBase {
237 protected name = "find" ;
248 protected description = "Run a find query against a MongoDB collection" ;
25- protected argsShape = argsShape ;
9+ protected argsShape = {
10+ collection : z . string ( ) . describe ( "Collection name" ) ,
11+ database : z . string ( ) . describe ( "Database name" ) ,
12+ filter : z
13+ . object ( { } )
14+ . passthrough ( )
15+ . optional ( )
16+ . describe ( "The query filter, matching the syntax of the query argument of db.collection.find()" ) ,
17+ projection : z
18+ . object ( { } )
19+ . passthrough ( )
20+ . optional ( )
21+ . describe ( "The projection, matching the syntax of the projection argument of db.collection.find()" ) ,
22+ limit : z . number ( ) . optional ( ) . default ( 10 ) . describe ( "The maximum number of documents to return" ) ,
23+ } ;
2624
2725 protected async execute ( {
2826 database,
2927 collection,
3028 filter,
3129 projection,
3230 limit,
33- } : ToolArgs < typeof argsShape > ) : Promise < CallToolResult > {
31+ } : ToolArgs < typeof this . argsShape > ) : Promise < CallToolResult > {
3432 const provider = this . ensureConnected ( ) ;
3533 const documents = await provider . find ( database , collection , filter , { projection, limit } ) . toArray ( ) ;
3634
0 commit comments