@@ -98,29 +98,28 @@ export async function resolveTools(opts: ResolveToolsOpts) {
9898 ...mcpTools ,
9999 ] ;
100100
101- const toolsConfig = opts . context . config . tools ;
102- let availableTools = ( ( ) => {
103- if ( ! toolsConfig || Object . keys ( toolsConfig ) . length === 0 ) {
104- return allTools ;
105- }
106- return allTools . filter ( ( tool ) => {
107- // Check if the tool is disabled (only explicitly set to false will disable)
108- const isDisabled = toolsConfig [ tool . name ] === false ;
109- return ! isDisabled ;
110- } ) ;
111- } ) ( ) ;
112-
101+ // 1. First, execute plugin hook to allow plugins to add/modify tools
102+ let availableTools = allTools ;
113103 try {
114104 availableTools = await opts . context . apply ( {
115105 hook : 'tool' ,
116106 args : [ { isPlan : opts . isPlan , sessionId : opts . sessionId } ] ,
117- memo : availableTools ,
107+ memo : allTools ,
118108 type : PluginHookType . SeriesMerge ,
119109 } ) ;
120110 } catch ( error ) {
121111 console . warn ( '[resolveTools] Plugin tool hook failed:' , error ) ;
122112 }
123113
114+ // 2. Then, filter all tools (including plugin-injected ones) by config
115+ const toolsConfig = opts . context . config . tools ;
116+ if ( toolsConfig && Object . keys ( toolsConfig ) . length > 0 ) {
117+ availableTools = availableTools . filter ( ( tool ) => {
118+ // Only explicitly set to false will disable the tool
119+ return toolsConfig [ tool . name ] !== false ;
120+ } ) ;
121+ }
122+
124123 const taskTools = ( ( ) => {
125124 // Task tool is only available in quiet mode
126125 if ( ! opts . task ) return [ ] ;
0 commit comments