@@ -459,7 +459,7 @@ const AVAILABLE_CONNECTIONS = {
459459// connected to.
460460class ListConnectionsTool extends ToolBase {
461461 override name = " list-connections" ;
462- override category: ToolCategory = " mongodb" ;
462+ static category: ToolCategory = " mongodb" ;
463463 static operationType: OperationType = " metadata" ;
464464 protected override description =
465465 " Lists all available pre-configured MongoDB connections" ;
@@ -501,7 +501,7 @@ class ListConnectionsTool extends ToolBase {
501501// effective communication using opaque connection identifiers.
502502class SelectConnectionTool extends ToolBase {
503503 override name = " select-connection" ;
504- override category: ToolCategory = " mongodb" ;
504+ static category: ToolCategory = " mongodb" ;
505505 static operationType: OperationType = " metadata" ;
506506 protected override description =
507507 " Select and connect to a pre-configured MongoDB connection by ID" ;
@@ -583,9 +583,7 @@ const runner = new StdioRunner({
583583 }),
584584 // Register all internal tools except the default connect tools, plus our custom tools
585585 tools: [
586- ... Object .values (AllTools ).filter (
587- (tool ) => tool .operationType !== " connect"
588- ),
586+ ... AllTools .filter ((tool ) => tool .operationType !== " connect" ),
589587 ListConnectionsTool ,
590588 SelectConnectionTool ,
591589 ],
@@ -619,7 +617,7 @@ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
619617// Custom tool to fetch ticket details from your application
620618class GetTicketDetailsTool extends ToolBase {
621619 override name = " get-ticket-details" ;
622- override category: ToolCategory = " mongodb" ;
620+ static category: ToolCategory = " mongodb" ;
623621 static operationType: OperationType = " read" ;
624622
625623 protected override description =
@@ -741,7 +739,7 @@ See the TypeScript documentation in [`src/tools/tool.ts`](./src/tools/tool.ts) f
741739
742740** Important:** All custom tools must conform to the ` ToolClass ` type, which requires:
743741
744- - A ** static ** ` operationType ` property (not an instance property )
742+ - ** Static ** ` category ` and ` operationType ` properties (not instance properties )
745743- Implementation of all abstract members from ` ToolBase `
746744
747745### ToolClass
@@ -751,90 +749,41 @@ The type that all tool classes must conform to when implementing custom tools.
751749This type enforces that tool classes have:
752750
753751- A constructor that accepts ` ToolConstructorParams `
754- - A ** static ** ` operationType ` property
752+ - ** Static ** ` category ` and ` operationType ` properties
755753
756- The static ` operationType ` is automatically injected as an instance property during tool construction by the server.
754+ The static properties are automatically injected as instance properties during tool construction by the server.
757755
758756See the TypeScript documentation in [ ` src/tools/tool.ts ` ] ( ./src/tools/tool.ts ) for complete details and examples.
759757
760758### Tool Collections
761759
762760The library exports collections of internal tool classes that can be used for selective tool registration or extension.
763761
764- #### AllTools
765-
766- An object containing all internal tool classes (MongoDB, Atlas, and Atlas Local tools combined).
767-
768762``` typescript
769- import { AllTools , MongoDbTools , AtlasTools } from " mongodb-mcp-server/tools" ;
763+ import { AllTools , AggregateTool , FindTool } from " mongodb-mcp-server/tools" ;
770764
771- // Pick a specific tool
772- const MyTool = AllTools .AggregateTool ;
765+ // Use all internal tools
766+ // An array containing all internal tool constructors (MongoDB, Atlas, and Atlas Local tools combined).
767+ const allTools = AllTools ;
773768
774- // Create a list of hand picked tools
775- const selectedInternalTools = [
776- AllTools .AggregateTool ,
777- AllTools .ConnectTool ,
778- AllTools .SwitchConnectionTool ,
779- ];
769+ // Pick specific tools by importing them directly
770+ const selectedInternalTools = [AggregateTool , FindTool ];
780771
781- // Create a list of all internal tools except a few
782- const filteredTools = Object .values (AllTools ).filter (
783- (tool ) =>
784- tool !== AllTools .ConnectTool && tool !== AllTools .SwitchConnectionTool
772+ // Create a list of all internal tools except a few by filtering
773+ const filteredTools = AllTools .filter (
774+ (tool ) => tool !== AggregateTool && tool !== FindTool
785775);
786776
787777// Filter tools by operationType (static property)
788- const connectionRelatedTools = Object . values ( AllTools ) .filter (
778+ const connectionRelatedTools = AllTools .filter (
789779 (tool ) => tool .operationType === " connect"
790780);
791- ```
792-
793- #### MongoDbTools
794-
795- An object containing only MongoDB-specific tool classes (tools that interact with MongoDB deployments).
796-
797- ``` typescript
798- import { MongoDbTools } from " mongodb-mcp-server/tools" ;
799-
800- // Get all MongoDB tools as an array
801- const mongoTools = Object .values (MongoDbTools );
802-
803- // You can check static properties like operationType
804- const readOnlyMongoTools = mongoTools .filter (
805- (tool ) => tool .operationType === " read" || tool .operationType === " metadata"
806- );
807- ```
808-
809- #### AtlasTools
810-
811- An object containing only MongoDB Atlas-specific tool classes (tools that interact with Atlas API).
812-
813- ``` typescript
814- import { AtlasTools } from " mongodb-mcp-server/tools" ;
815-
816- // Get all Atlas tools as an array
817- const atlasTools = Object .values (AtlasTools );
818781
819- // You can check static properties like operationType
820- const atlasCreationTools = atlasTools .filter (
821- (tool ) => tool .operationType === " create"
822- );
823- ```
824-
825- #### AtlasLocalTools
826-
827- An object containing only Atlas Local-specific tool classes (tools that interact with local Atlas deployments).
828-
829- ``` typescript
830- import { AtlasLocalTools } from " mongodb-mcp-server/tools" ;
831-
832- // Get all Atlas Local tools as an array
833- const atlasLocalTools = Object .values (AtlasLocalTools );
834-
835- // You can check static properties like operationType
836- const atlasLocalConnectionTools = atlasLocalTools .filter (
837- (tool ) => tool .operationType === " connect"
782+ // Filter tools by category
783+ const mongodbTools = AllTools .filter ((tool ) => tool .category === " mongodb" );
784+ const atlasTools = AllTools .filter ((tool ) => tool .category === " atlas" );
785+ const atlasLocalTools = AllTools .filter (
786+ (tool ) => tool .category === " atlas-local"
838787);
839788```
840789
@@ -1101,7 +1050,7 @@ For complete working examples of embedding and extending the MongoDB MCP Server,
11011050** Problem:** Custom tools not appearing in the tool list
11021051
11031052- ** Solution:** Ensure the tool class extends ` ToolBase ` and is passed in the ` tools ` array
1104- - ** Solution:** If you want both internal and custom tools, spread ` AllTools ` in the array: ` tools: [...Object.values( AllTools) , MyCustomTool] `
1053+ - ** Solution:** If you want both internal and custom tools, spread ` AllTools ` in the array: ` tools: [...AllTools, MyCustomTool] `
11051054- ** Solution:** Check that the tool's ` verifyAllowed() ` returns true and the tool is not accidentally disabled by config (disabledTools)
11061055
11071056** Problem:** Configuration overrides not working
0 commit comments