@@ -16,7 +16,7 @@ import {
1616 UnsubscribeRequestSchema ,
1717} from "@modelcontextprotocol/sdk/types.js" ;
1818import assert from "assert" ;
19- import type { ToolBase , ToolCategory , ToolConstructorParams } from "./tools/tool.js" ;
19+ import type { ToolBase , ToolCategory , ToolClass } from "./tools/tool.js" ;
2020import { validateConnectionString } from "./helpers/connectionOptions.js" ;
2121import { packageInfo } from "./common/packageInfo.js" ;
2222import { type ConnectionErrorHandler } from "./common/connectionErrorHandler.js" ;
@@ -35,10 +35,19 @@ export interface ServerOptions {
3535 * This will override any default tools. You can use both existing and custom tools by using the `mongodb-mcp-server/tools` export.
3636 *
3737 * ```ts
38- * import { AllTools, ToolBase } from "mongodb-mcp-server/tools";
38+ * import { AllTools, ToolBase, type ToolCategory, type OperationType } from "mongodb-mcp-server/tools";
3939 * class CustomTool extends ToolBase {
40- * name = "custom_tool";
41- * // ...
40+ * override name = "custom_tool";
41+ * static category: ToolCategory = "mongodb";
42+ * static operationType: OperationType = "read";
43+ * protected description = "Custom tool description";
44+ * protected argsShape = {};
45+ * protected async execute() {
46+ * return { content: [{ type: "text", text: "Result" }] };
47+ * }
48+ * protected resolveTelemetryMetadata() {
49+ * return {};
50+ * }
4251 * }
4352 * const server = new Server({
4453 * session: mySession,
@@ -51,7 +60,7 @@ export interface ServerOptions {
5160 * });
5261 * ```
5362 */
54- tools ?: ( new ( params : ToolConstructorParams ) => ToolBase ) [ ] ;
63+ tools ?: ToolClass [ ] ;
5564}
5665
5766export class Server {
@@ -60,7 +69,7 @@ export class Server {
6069 private readonly telemetry : Telemetry ;
6170 public readonly userConfig : UserConfig ;
6271 public readonly elicitation : Elicitation ;
63- private readonly toolConstructors : ( new ( params : ToolConstructorParams ) => ToolBase ) [ ] ;
72+ private readonly toolConstructors : ToolClass [ ] ;
6473 public readonly tools : ToolBase [ ] = [ ] ;
6574 public readonly connectionErrorHandler : ConnectionErrorHandler ;
6675
@@ -242,6 +251,8 @@ export class Server {
242251 private registerTools ( ) : void {
243252 for ( const toolConstructor of this . toolConstructors ) {
244253 const tool = new toolConstructor ( {
254+ category : toolConstructor . category ,
255+ operationType : toolConstructor . operationType ,
245256 session : this . session ,
246257 config : this . userConfig ,
247258 telemetry : this . telemetry ,
0 commit comments