@@ -27,13 +27,12 @@ export abstract class ToolBase {
27
27
protected constructor ( protected session : Session ) { }
28
28
29
29
public register ( server : McpServer ) : void {
30
+ if ( ! this . verifyAllowed ( ) ) {
31
+ return ;
32
+ }
33
+
30
34
const callback : ToolCallback < typeof this . argsShape > = async ( ...args ) => {
31
35
try {
32
- const preventionResult = this . verifyAllowed ( ) ;
33
- if ( preventionResult ) {
34
- return preventionResult ;
35
- }
36
-
37
36
// TODO: add telemetry here
38
37
logger . debug (
39
38
mongoLogId ( 1_000_006 ) ,
@@ -53,7 +52,7 @@ export abstract class ToolBase {
53
52
}
54
53
55
54
// Checks if a tool is allowed to run based on the config
56
- private verifyAllowed ( ) : CallToolResult | undefined {
55
+ private verifyAllowed ( ) : boolean {
57
56
let errorClarification : string | undefined ;
58
57
if ( config . disabledTools . includes ( this . category ) ) {
59
58
errorClarification = `its category, \`${ this . category } \`,` ;
@@ -67,18 +66,13 @@ export abstract class ToolBase {
67
66
logger . debug (
68
67
mongoLogId ( 1_000_010 ) ,
69
68
"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`
71
70
) ;
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 ;
81
73
}
74
+
75
+ return true ;
82
76
}
83
77
84
78
// This method is intended to be overridden by subclasses to handle errors
0 commit comments