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,28 @@ export interface ServerOptions {
3230 telemetry : Telemetry ;
3331 elicitation : Elicitation ;
3432 connectionErrorHandler : ConnectionErrorHandler ;
35- toolConstructors ?: ( new ( params : ToolConstructorParams ) => ToolBase ) [ ] ;
33+ /**
34+ * Custom tool constructors to register with the server.
35+ * This will override any default tools. You can use both existing and custom tools by using the `mongodb-mcp-server/tools` export.
36+ *
37+ * ```ts
38+ * import { AllTools, ToolBase } from "mongodb-mcp-server/tools";
39+ * class CustomTool extends ToolBase {
40+ * name = "custom_tool";
41+ * // ...
42+ * }
43+ * const server = new Server({
44+ * session: mySession,
45+ * userConfig: myUserConfig,
46+ * mcpServer: myMcpServer,
47+ * telemetry: myTelemetry,
48+ * elicitation: myElicitation,
49+ * connectionErrorHandler: myConnectionErrorHandler,
50+ * tools: [...AllTools, CustomTool],
51+ * });
52+ * ```
53+ */
54+ tools ?: ( new ( params : ToolConstructorParams ) => ToolBase ) [ ] ;
3655}
3756
3857export class Server {
@@ -61,7 +80,7 @@ export class Server {
6180 telemetry,
6281 connectionErrorHandler,
6382 elicitation,
64- toolConstructors ,
83+ tools ,
6584 } : ServerOptions ) {
6685 this . startTime = Date . now ( ) ;
6786 this . session = session ;
@@ -70,7 +89,7 @@ export class Server {
7089 this . userConfig = userConfig ;
7190 this . elicitation = elicitation ;
7291 this . connectionErrorHandler = connectionErrorHandler ;
73- this . toolConstructors = toolConstructors ?? [ ... AtlasTools , ... MongoDbTools , ... AtlasLocalTools ] ;
92+ this . toolConstructors = tools ?? AllTools ;
7493 }
7594
7695 async connect ( transport : Transport ) : Promise < void > {
0 commit comments