File tree Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -149,11 +149,27 @@ export { currentClient };
149149
150150deferLog ( 'info' , 'Setting up request handlers...' ) ;
151151
152+ /**
153+ * Check if a tool should be included based on current client
154+ */
155+ function shouldIncludeTool ( toolName : string ) : boolean {
156+ // Exclude give_feedback_to_desktop_commander for desktop-commander client
157+ if ( toolName === 'give_feedback_to_desktop_commander' && currentClient ?. name === 'desktop-commander' ) {
158+ return false ;
159+ }
160+
161+ // Add more conditional tool logic here as needed
162+ // Example: if (toolName === 'some_tool' && currentClient?.name === 'some_client') return false;
163+
164+ return true ;
165+ }
166+
152167server . setRequestHandler ( ListToolsRequestSchema , async ( ) => {
153168 try {
154169 logToStderr ( 'debug' , 'Generating tools list...' ) ;
155- return {
156- tools : [
170+
171+ // Build complete tools array
172+ const allTools = [
157173 // Configuration tools
158174 {
159175 name : "get_config" ,
@@ -912,7 +928,15 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
912928 ${ CMD_PREFIX_DESCRIPTION } ` ,
913929 inputSchema : zodToJsonSchema ( GetPromptsArgsSchema ) ,
914930 } ,
915- ] ,
931+ ] ;
932+
933+ // Filter tools based on current client
934+ const filteredTools = allTools . filter ( tool => shouldIncludeTool ( tool . name ) ) ;
935+
936+ logToStderr ( 'debug' , `Returning ${ filteredTools . length } tools (filtered from ${ allTools . length } total) for client: ${ currentClient ?. name || 'unknown' } ` ) ;
937+
938+ return {
939+ tools : filteredTools ,
916940 } ;
917941 } catch ( error ) {
918942 logToStderr ( 'error' , `Error in list_tools request handler: ${ error } ` ) ;
You can’t perform that action at this time.
0 commit comments