11import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" ;
22import type { Session } from "./common/session.js" ;
33import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js" ;
4- import { AtlasTools } from "./tools/atlas/tools.js" ;
5- import { AtlasLocalTools } from "./tools/atlasLocal/tools.js" ;
6- import { MongoDbTools } from "./tools/mongodb/tools.js" ;
74import { Resources } from "./resources/resources.js" ;
85import type { LogLevel } from "./common/logger.js" ;
96import { LogId , McpLogger } from "./common/logger.js" ;
@@ -24,6 +21,7 @@ import { validateConnectionString } from "./helpers/connectionOptions.js";
2421import { packageInfo } from "./common/packageInfo.js" ;
2522import { type ConnectionErrorHandler } from "./common/connectionErrorHandler.js" ;
2623import type { Elicitation } from "./elicitation.js" ;
24+ import { AllTools } from "./tools/index.js" ;
2725
2826export interface ServerOptions {
2927 session : Session ;
@@ -32,7 +30,20 @@ export interface ServerOptions {
3230 telemetry : Telemetry ;
3331 elicitation : Elicitation ;
3432 connectionErrorHandler : ConnectionErrorHandler ;
35- toolConstructors ?: ( new ( params : ToolConstructorParams ) => ToolBase ) [ ] ;
33+ /** Custom tool constructors to register with the server.
34+ * This will override any default tools. You can use both existing and custom tools by using the `mongodb-mcp-server/tools` export.
35+ * ```ts
36+ * import { AllTools, ToolBase } from "mongodb-mcp-server/tools";
37+ * class CustomTool extends ToolBase {
38+ * name = "custom_tool";
39+ * ...
40+ * }
41+ * const server = new Server({
42+ * tools: [...AllTools, CustomTool],
43+ * });
44+ * ```
45+ */
46+ tools ?: ( new ( params : ToolConstructorParams ) => ToolBase ) [ ] ;
3647}
3748
3849export class Server {
@@ -61,7 +72,7 @@ export class Server {
6172 telemetry,
6273 connectionErrorHandler,
6374 elicitation,
64- toolConstructors ,
75+ tools ,
6576 } : ServerOptions ) {
6677 this . startTime = Date . now ( ) ;
6778 this . session = session ;
@@ -70,7 +81,7 @@ export class Server {
7081 this . userConfig = userConfig ;
7182 this . elicitation = elicitation ;
7283 this . connectionErrorHandler = connectionErrorHandler ;
73- this . toolConstructors = toolConstructors ?? [ ... AtlasTools , ... MongoDbTools , ... AtlasLocalTools ] ;
84+ this . toolConstructors = tools ?? AllTools ;
7485 }
7586
7687 async connect ( transport : Transport ) : Promise < void > {
0 commit comments