@@ -27,13 +27,12 @@ export abstract class ToolBase {
2727 protected constructor ( protected session : Session ) { }
2828
2929 public register ( server : McpServer ) : void {
30+ if ( ! this . verifyAllowed ( ) ) {
31+ return ;
32+ }
33+
3034 const callback : ToolCallback < typeof this . argsShape > = async ( ...args ) => {
3135 try {
32- const preventionResult = this . verifyAllowed ( ) ;
33- if ( preventionResult ) {
34- return preventionResult ;
35- }
36-
3736 // TODO: add telemetry here
3837 logger . debug (
3938 mongoLogId ( 1_000_006 ) ,
@@ -53,7 +52,7 @@ export abstract class ToolBase {
5352 }
5453
5554 // Checks if a tool is allowed to run based on the config
56- private verifyAllowed ( ) : CallToolResult | undefined {
55+ private verifyAllowed ( ) : boolean {
5756 let errorClarification : string | undefined ;
5857 if ( config . disabledTools . includes ( this . category ) ) {
5958 errorClarification = `its category, \`${ this . category } \`,` ;
@@ -67,18 +66,13 @@ export abstract class ToolBase {
6766 logger . debug (
6867 mongoLogId ( 1_000_010 ) ,
6968 "tool" ,
70- `Prevented execution of ${ this . name } because ${ errorClarification } is disabled in the config`
69+ `Prevented registration of ${ this . name } because ${ errorClarification } is disabled in the config`
7170 ) ;
72- return {
73- content : [
74- {
75- type : "text" ,
76- text : `Cannot execute tool \`${ this . name } \` because ${ errorClarification } is disabled in the config.` ,
77- } ,
78- ] ,
79- isError : true ,
80- } ;
71+
72+ return false ;
8173 }
74+
75+ return true ;
8276 }
8377
8478 // This method is intended to be overridden by subclasses to handle errors
0 commit comments