@wonderwhy-er/desktop-commander 0.2.15 → 0.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -8,7 +8,7 @@ const OS_GUIDANCE = getOSSpecificGuidance(SYSTEM_INFO);
8
8
  const DEV_TOOL_GUIDANCE = getDevelopmentToolGuidance(SYSTEM_INFO);
9
9
  const PATH_GUIDANCE = `IMPORTANT: ${getPathGuidance(SYSTEM_INFO)} Relative paths may fail as they depend on the current working directory. Tilde paths (~/...) might not work in all contexts. Unless the user explicitly asks for relative paths, use absolute paths.`;
10
10
  const CMD_PREFIX_DESCRIPTION = `This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.`;
11
- import { StartProcessArgsSchema, ReadProcessOutputArgsSchema, InteractWithProcessArgsSchema, ForceTerminateArgsSchema, ListSessionsArgsSchema, KillProcessArgsSchema, ReadFileArgsSchema, ReadMultipleFilesArgsSchema, WriteFileArgsSchema, CreateDirectoryArgsSchema, ListDirectoryArgsSchema, MoveFileArgsSchema, GetFileInfoArgsSchema, GetConfigArgsSchema, SetConfigValueArgsSchema, ListProcessesArgsSchema, EditBlockArgsSchema, GetUsageStatsArgsSchema, GiveFeedbackArgsSchema, StartSearchArgsSchema, GetMoreSearchResultsArgsSchema, StopSearchArgsSchema, ListSearchesArgsSchema, GetPromptsArgsSchema, } from './tools/schemas.js';
11
+ import { StartProcessArgsSchema, ReadProcessOutputArgsSchema, InteractWithProcessArgsSchema, ForceTerminateArgsSchema, ListSessionsArgsSchema, KillProcessArgsSchema, ReadFileArgsSchema, ReadMultipleFilesArgsSchema, WriteFileArgsSchema, CreateDirectoryArgsSchema, ListDirectoryArgsSchema, MoveFileArgsSchema, GetFileInfoArgsSchema, GetConfigArgsSchema, SetConfigValueArgsSchema, ListProcessesArgsSchema, EditBlockArgsSchema, GetUsageStatsArgsSchema, GiveFeedbackArgsSchema, StartSearchArgsSchema, GetMoreSearchResultsArgsSchema, StopSearchArgsSchema, ListSearchesArgsSchema, GetPromptsArgsSchema, GetRecentToolCallsArgsSchema, } from './tools/schemas.js';
12
12
  import { getConfig, setConfigValue } from './tools/config.js';
13
13
  import { getUsageStats } from './tools/usage.js';
14
14
  import { giveFeedbackToDesktopCommander } from './tools/feedback.js';
@@ -16,6 +16,7 @@ import { getPrompts } from './tools/prompts.js';
16
16
  import { trackToolCall } from './utils/trackTools.js';
17
17
  import { usageTracker } from './utils/usageTracker.js';
18
18
  import { processDockerPrompt } from './utils/dockerPrompt.js';
19
+ import { toolHistory } from './utils/toolHistory.js';
19
20
  import { VERSION } from './version.js';
20
21
  import { capture, capture_call_tool } from "./utils/capture.js";
21
22
  import { logToStderr, logger } from './utils/logger.js';
@@ -95,15 +96,27 @@ server.setRequestHandler(InitializeRequestSchema, async (request) => {
95
96
  // Export current client info for access by other modules
96
97
  export { currentClient };
97
98
  deferLog('info', 'Setting up request handlers...');
99
+ /**
100
+ * Check if a tool should be included based on current client
101
+ */
102
+ function shouldIncludeTool(toolName) {
103
+ // Exclude give_feedback_to_desktop_commander for desktop-commander client
104
+ if (toolName === 'give_feedback_to_desktop_commander' && currentClient?.name === 'desktop-commander') {
105
+ return false;
106
+ }
107
+ // Add more conditional tool logic here as needed
108
+ // Example: if (toolName === 'some_tool' && currentClient?.name === 'some_client') return false;
109
+ return true;
110
+ }
98
111
  server.setRequestHandler(ListToolsRequestSchema, async () => {
99
112
  try {
100
113
  logToStderr('debug', 'Generating tools list...');
101
- return {
102
- tools: [
103
- // Configuration tools
104
- {
105
- name: "get_config",
106
- description: `
114
+ // Build complete tools array
115
+ const allTools = [
116
+ // Configuration tools
117
+ {
118
+ name: "get_config",
119
+ description: `
107
120
  Get the complete server configuration as JSON. Config includes fields for:
108
121
  - blockedCommands (array of blocked shell commands)
109
122
  - defaultShell (shell to use for commands)
@@ -116,11 +129,15 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
116
129
  - version (version of the DesktopCommander)
117
130
  - systemInfo (operating system and environment details)
118
131
  ${CMD_PREFIX_DESCRIPTION}`,
119
- inputSchema: zodToJsonSchema(GetConfigArgsSchema),
132
+ inputSchema: zodToJsonSchema(GetConfigArgsSchema),
133
+ annotations: {
134
+ title: "Get Configuration",
135
+ readOnlyHint: true,
120
136
  },
121
- {
122
- name: "set_config_value",
123
- description: `
137
+ },
138
+ {
139
+ name: "set_config_value",
140
+ description: `
124
141
  Set a specific configuration value by key.
125
142
 
126
143
  WARNING: Should be used in a separate chat from file operations and
@@ -138,12 +155,18 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
138
155
  to the entire file system, regardless of the operating system.
139
156
 
140
157
  ${CMD_PREFIX_DESCRIPTION}`,
141
- inputSchema: zodToJsonSchema(SetConfigValueArgsSchema),
158
+ inputSchema: zodToJsonSchema(SetConfigValueArgsSchema),
159
+ annotations: {
160
+ title: "Set Configuration Value",
161
+ readOnlyHint: false,
162
+ destructiveHint: true,
163
+ openWorldHint: false,
142
164
  },
143
- // Filesystem tools
144
- {
145
- name: "read_file",
146
- description: `
165
+ },
166
+ // Filesystem tools
167
+ {
168
+ name: "read_file",
169
+ description: `
147
170
  Read the contents of a file from the file system or a URL with optional offset and length parameters.
148
171
 
149
172
  Prefer this over 'execute_command' with cat/type for viewing files.
@@ -176,11 +199,16 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
176
199
 
177
200
  ${PATH_GUIDANCE}
178
201
  ${CMD_PREFIX_DESCRIPTION}`,
179
- inputSchema: zodToJsonSchema(ReadFileArgsSchema),
202
+ inputSchema: zodToJsonSchema(ReadFileArgsSchema),
203
+ annotations: {
204
+ title: "Read File or URL",
205
+ readOnlyHint: true,
206
+ openWorldHint: true,
180
207
  },
181
- {
182
- name: "read_multiple_files",
183
- description: `
208
+ },
209
+ {
210
+ name: "read_multiple_files",
211
+ description: `
184
212
  Read the contents of multiple files simultaneously.
185
213
 
186
214
  Each file's content is returned with its path as a reference.
@@ -192,11 +220,15 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
192
220
 
193
221
  ${PATH_GUIDANCE}
194
222
  ${CMD_PREFIX_DESCRIPTION}`,
195
- inputSchema: zodToJsonSchema(ReadMultipleFilesArgsSchema),
223
+ inputSchema: zodToJsonSchema(ReadMultipleFilesArgsSchema),
224
+ annotations: {
225
+ title: "Read Multiple Files",
226
+ readOnlyHint: true,
196
227
  },
197
- {
198
- name: "write_file",
199
- description: `
228
+ },
229
+ {
230
+ name: "write_file",
231
+ description: `
200
232
  Write or append to file contents.
201
233
 
202
234
  CHUNKING IS STANDARD PRACTICE: Always write files in chunks of 25-30 lines maximum.
@@ -225,11 +257,17 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
225
257
 
226
258
  ${PATH_GUIDANCE}
227
259
  ${CMD_PREFIX_DESCRIPTION}`,
228
- inputSchema: zodToJsonSchema(WriteFileArgsSchema),
260
+ inputSchema: zodToJsonSchema(WriteFileArgsSchema),
261
+ annotations: {
262
+ title: "Write File",
263
+ readOnlyHint: false,
264
+ destructiveHint: true,
265
+ openWorldHint: false,
229
266
  },
230
- {
231
- name: "create_directory",
232
- description: `
267
+ },
268
+ {
269
+ name: "create_directory",
270
+ description: `
233
271
  Create a new directory or ensure a directory exists.
234
272
 
235
273
  Can create multiple nested directories in one operation.
@@ -237,24 +275,49 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
237
275
 
238
276
  ${PATH_GUIDANCE}
239
277
  ${CMD_PREFIX_DESCRIPTION}`,
240
- inputSchema: zodToJsonSchema(CreateDirectoryArgsSchema),
241
- },
242
- {
243
- name: "list_directory",
244
- description: `
278
+ inputSchema: zodToJsonSchema(CreateDirectoryArgsSchema),
279
+ },
280
+ {
281
+ name: "list_directory",
282
+ description: `
245
283
  Get a detailed listing of all files and directories in a specified path.
246
284
 
247
285
  Use this instead of 'execute_command' with ls/dir commands.
248
286
  Results distinguish between files and directories with [FILE] and [DIR] prefixes.
287
+
288
+ Supports recursive listing with the 'depth' parameter (default: 2):
289
+ - depth=1: Only direct contents of the directory
290
+ - depth=2: Contents plus one level of subdirectories
291
+ - depth=3+: Multiple levels deep
292
+
293
+ CONTEXT OVERFLOW PROTECTION:
294
+ - Top-level directory shows ALL items
295
+ - Nested directories are limited to 100 items maximum per directory
296
+ - When a nested directory has more than 100 items, you'll see a warning like:
297
+ [WARNING] node_modules: 500 items hidden (showing first 100 of 600 total)
298
+ - This prevents overwhelming the context with large directories like node_modules
299
+
300
+ Results show full relative paths from the root directory being listed.
301
+ Example output with depth=2:
302
+ [DIR] src
303
+ [FILE] src/index.ts
304
+ [DIR] src/tools
305
+ [FILE] src/tools/filesystem.ts
306
+
307
+ If a directory cannot be accessed, it will show [DENIED] instead.
249
308
  Only works within allowed directories.
250
309
 
251
310
  ${PATH_GUIDANCE}
252
311
  ${CMD_PREFIX_DESCRIPTION}`,
253
- inputSchema: zodToJsonSchema(ListDirectoryArgsSchema),
312
+ inputSchema: zodToJsonSchema(ListDirectoryArgsSchema),
313
+ annotations: {
314
+ title: "List Directory Contents",
315
+ readOnlyHint: true,
254
316
  },
255
- {
256
- name: "move_file",
257
- description: `
317
+ },
318
+ {
319
+ name: "move_file",
320
+ description: `
258
321
  Move or rename files and directories.
259
322
 
260
323
  Can move files between directories and rename them in a single operation.
@@ -262,11 +325,17 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
262
325
 
263
326
  ${PATH_GUIDANCE}
264
327
  ${CMD_PREFIX_DESCRIPTION}`,
265
- inputSchema: zodToJsonSchema(MoveFileArgsSchema),
328
+ inputSchema: zodToJsonSchema(MoveFileArgsSchema),
329
+ annotations: {
330
+ title: "Move/Rename File",
331
+ readOnlyHint: false,
332
+ destructiveHint: true,
333
+ openWorldHint: false,
266
334
  },
267
- {
268
- name: "start_search",
269
- description: `
335
+ },
336
+ {
337
+ name: "start_search",
338
+ description: `
270
339
  Start a streaming search that can return results progressively.
271
340
 
272
341
  SEARCH STRATEGY GUIDE:
@@ -345,11 +414,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
345
414
 
346
415
  ${PATH_GUIDANCE}
347
416
  ${CMD_PREFIX_DESCRIPTION}`,
348
- inputSchema: zodToJsonSchema(StartSearchArgsSchema),
349
- },
350
- {
351
- name: "get_more_search_results",
352
- description: `
417
+ inputSchema: zodToJsonSchema(StartSearchArgsSchema),
418
+ },
419
+ {
420
+ name: "get_more_search_results",
421
+ description: `
353
422
  Get more results from an active search with offset-based pagination.
354
423
 
355
424
  Supports partial result reading with:
@@ -371,11 +440,15 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
371
440
  results from a search started with start_search.
372
441
 
373
442
  ${CMD_PREFIX_DESCRIPTION}`,
374
- inputSchema: zodToJsonSchema(GetMoreSearchResultsArgsSchema),
443
+ inputSchema: zodToJsonSchema(GetMoreSearchResultsArgsSchema),
444
+ annotations: {
445
+ title: "Get Search Results",
446
+ readOnlyHint: true,
375
447
  },
376
- {
377
- name: "stop_search",
378
- description: `
448
+ },
449
+ {
450
+ name: "stop_search",
451
+ description: `
379
452
  Stop an active search.
380
453
 
381
454
  Stops the background search process gracefully. Use this when you've found
@@ -386,11 +459,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
386
459
  automatically cleaned up after 5 minutes.
387
460
 
388
461
  ${CMD_PREFIX_DESCRIPTION}`,
389
- inputSchema: zodToJsonSchema(StopSearchArgsSchema),
390
- },
391
- {
392
- name: "list_searches",
393
- description: `
462
+ inputSchema: zodToJsonSchema(StopSearchArgsSchema),
463
+ },
464
+ {
465
+ name: "list_searches",
466
+ description: `
394
467
  List all active searches.
395
468
 
396
469
  Shows search IDs, search types, patterns, status, and runtime.
@@ -398,11 +471,15 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
398
471
  multiple concurrent searches.
399
472
 
400
473
  ${CMD_PREFIX_DESCRIPTION}`,
401
- inputSchema: zodToJsonSchema(ListSearchesArgsSchema),
474
+ inputSchema: zodToJsonSchema(ListSearchesArgsSchema),
475
+ annotations: {
476
+ title: "List Active Searches",
477
+ readOnlyHint: true,
402
478
  },
403
- {
404
- name: "get_file_info",
405
- description: `
479
+ },
480
+ {
481
+ name: "get_file_info",
482
+ description: `
406
483
  Retrieve detailed metadata about a file or directory including:
407
484
  - size
408
485
  - creation time
@@ -417,13 +494,17 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
417
494
 
418
495
  ${PATH_GUIDANCE}
419
496
  ${CMD_PREFIX_DESCRIPTION}`,
420
- inputSchema: zodToJsonSchema(GetFileInfoArgsSchema),
497
+ inputSchema: zodToJsonSchema(GetFileInfoArgsSchema),
498
+ annotations: {
499
+ title: "Get File Information",
500
+ readOnlyHint: true,
421
501
  },
422
- // Note: list_allowed_directories removed - use get_config to check allowedDirectories
423
- // Text editing tools
424
- {
425
- name: "edit_block",
426
- description: `
502
+ },
503
+ // Note: list_allowed_directories removed - use get_config to check allowedDirectories
504
+ // Text editing tools
505
+ {
506
+ name: "edit_block",
507
+ description: `
427
508
  Apply surgical text replacements to files.
428
509
 
429
510
  BEST PRACTICE: Make multiple small, focused edits rather than one large edit.
@@ -456,12 +537,18 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
456
537
 
457
538
  ${PATH_GUIDANCE}
458
539
  ${CMD_PREFIX_DESCRIPTION}`,
459
- inputSchema: zodToJsonSchema(EditBlockArgsSchema),
540
+ inputSchema: zodToJsonSchema(EditBlockArgsSchema),
541
+ annotations: {
542
+ title: "Edit Text Block",
543
+ readOnlyHint: false,
544
+ destructiveHint: true,
545
+ openWorldHint: false,
460
546
  },
461
- // Terminal tools
462
- {
463
- name: "start_process",
464
- description: `
547
+ },
548
+ // Terminal tools
549
+ {
550
+ name: "start_process",
551
+ description: `
465
552
  Start a new terminal process with intelligent state detection.
466
553
 
467
554
  PRIMARY TOOL FOR FILE ANALYSIS AND DATA PROCESSING
@@ -512,11 +599,17 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
512
599
 
513
600
  ${PATH_GUIDANCE}
514
601
  ${CMD_PREFIX_DESCRIPTION}`,
515
- inputSchema: zodToJsonSchema(StartProcessArgsSchema),
602
+ inputSchema: zodToJsonSchema(StartProcessArgsSchema),
603
+ annotations: {
604
+ title: "Start Terminal Process",
605
+ readOnlyHint: false,
606
+ destructiveHint: true,
607
+ openWorldHint: true,
516
608
  },
517
- {
518
- name: "read_process_output",
519
- description: `
609
+ },
610
+ {
611
+ name: "read_process_output",
612
+ description: `
520
613
  Read output from a running process with intelligent completion detection.
521
614
 
522
615
  Automatically detects when process is ready for more input instead of timing out.
@@ -539,11 +632,15 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
539
632
  Timeout reached (may still be running)
540
633
 
541
634
  ${CMD_PREFIX_DESCRIPTION}`,
542
- inputSchema: zodToJsonSchema(ReadProcessOutputArgsSchema),
635
+ inputSchema: zodToJsonSchema(ReadProcessOutputArgsSchema),
636
+ annotations: {
637
+ title: "Read Process Output",
638
+ readOnlyHint: true,
543
639
  },
544
- {
545
- name: "interact_with_process",
546
- description: `
640
+ },
641
+ {
642
+ name: "interact_with_process",
643
+ description: `
547
644
  Send input to a running process and automatically receive the response.
548
645
 
549
646
  CRITICAL: THIS IS THE PRIMARY TOOL FOR ALL LOCAL FILE ANALYSIS
@@ -591,19 +688,31 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
591
688
  NEVER USE ANALYSIS TOOL FOR: Local file access (it cannot read files from disk and WILL FAIL)
592
689
 
593
690
  ${CMD_PREFIX_DESCRIPTION}`,
594
- inputSchema: zodToJsonSchema(InteractWithProcessArgsSchema),
691
+ inputSchema: zodToJsonSchema(InteractWithProcessArgsSchema),
692
+ annotations: {
693
+ title: "Send Input to Process",
694
+ readOnlyHint: false,
695
+ destructiveHint: true,
696
+ openWorldHint: true,
595
697
  },
596
- {
597
- name: "force_terminate",
598
- description: `
698
+ },
699
+ {
700
+ name: "force_terminate",
701
+ description: `
599
702
  Force terminate a running terminal session.
600
703
 
601
704
  ${CMD_PREFIX_DESCRIPTION}`,
602
- inputSchema: zodToJsonSchema(ForceTerminateArgsSchema),
705
+ inputSchema: zodToJsonSchema(ForceTerminateArgsSchema),
706
+ annotations: {
707
+ title: "Force Terminate Process",
708
+ readOnlyHint: false,
709
+ destructiveHint: true,
710
+ openWorldHint: false,
603
711
  },
604
- {
605
- name: "list_sessions",
606
- description: `
712
+ },
713
+ {
714
+ name: "list_sessions",
715
+ description: `
607
716
  List all active terminal sessions.
608
717
 
609
718
  Shows session status including:
@@ -617,41 +726,80 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
617
726
  - Long runtime with blocked status may indicate stuck process
618
727
 
619
728
  ${CMD_PREFIX_DESCRIPTION}`,
620
- inputSchema: zodToJsonSchema(ListSessionsArgsSchema),
729
+ inputSchema: zodToJsonSchema(ListSessionsArgsSchema),
730
+ annotations: {
731
+ title: "List Terminal Sessions",
732
+ readOnlyHint: true,
621
733
  },
622
- {
623
- name: "list_processes",
624
- description: `
734
+ },
735
+ {
736
+ name: "list_processes",
737
+ description: `
625
738
  List all running processes.
626
739
 
627
740
  Returns process information including PID, command name, CPU usage, and memory usage.
628
741
 
629
742
  ${CMD_PREFIX_DESCRIPTION}`,
630
- inputSchema: zodToJsonSchema(ListProcessesArgsSchema),
743
+ inputSchema: zodToJsonSchema(ListProcessesArgsSchema),
744
+ annotations: {
745
+ title: "List Running Processes",
746
+ readOnlyHint: true,
631
747
  },
632
- {
633
- name: "kill_process",
634
- description: `
748
+ },
749
+ {
750
+ name: "kill_process",
751
+ description: `
635
752
  Terminate a running process by PID.
636
753
 
637
754
  Use with caution as this will forcefully terminate the specified process.
638
755
 
639
756
  ${CMD_PREFIX_DESCRIPTION}`,
640
- inputSchema: zodToJsonSchema(KillProcessArgsSchema),
757
+ inputSchema: zodToJsonSchema(KillProcessArgsSchema),
758
+ annotations: {
759
+ title: "Kill Process",
760
+ readOnlyHint: false,
761
+ destructiveHint: true,
762
+ openWorldHint: false,
641
763
  },
642
- {
643
- name: "get_usage_stats",
644
- description: `
764
+ },
765
+ {
766
+ name: "get_usage_stats",
767
+ description: `
645
768
  Get usage statistics for debugging and analysis.
646
769
 
647
770
  Returns summary of tool usage, success/failure rates, and performance metrics.
648
771
 
649
772
  ${CMD_PREFIX_DESCRIPTION}`,
650
- inputSchema: zodToJsonSchema(GetUsageStatsArgsSchema),
773
+ inputSchema: zodToJsonSchema(GetUsageStatsArgsSchema),
774
+ annotations: {
775
+ title: "Get Usage Statistics",
776
+ readOnlyHint: true,
651
777
  },
652
- {
653
- name: "give_feedback_to_desktop_commander",
654
- description: `
778
+ },
779
+ {
780
+ name: "get_recent_tool_calls",
781
+ description: `
782
+ Get recent tool call history with their arguments and outputs.
783
+ Returns chronological list of tool calls made during this session.
784
+
785
+ Useful for:
786
+ - Onboarding new chats about work already done
787
+ - Recovering context after chat history loss
788
+ - Debugging tool call sequences
789
+
790
+ Note: Does not track its own calls or other meta/query tools.
791
+ History kept in memory (last 1000 calls, lost on restart).
792
+
793
+ ${CMD_PREFIX_DESCRIPTION}`,
794
+ inputSchema: zodToJsonSchema(GetRecentToolCallsArgsSchema),
795
+ annotations: {
796
+ title: "Get Recent Tool Calls",
797
+ readOnlyHint: true,
798
+ },
799
+ },
800
+ {
801
+ name: "give_feedback_to_desktop_commander",
802
+ description: `
655
803
  Open feedback form in browser to provide feedback about Desktop Commander.
656
804
 
657
805
  IMPORTANT: This tool simply opens the feedback form - no pre-filling available.
@@ -684,11 +832,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
684
832
  No parameters are needed - just call the tool to open the form.
685
833
 
686
834
  ${CMD_PREFIX_DESCRIPTION}`,
687
- inputSchema: zodToJsonSchema(GiveFeedbackArgsSchema),
688
- },
689
- {
690
- name: "get_prompts",
691
- description: `
835
+ inputSchema: zodToJsonSchema(GiveFeedbackArgsSchema),
836
+ },
837
+ {
838
+ name: "get_prompts",
839
+ description: `
692
840
  Browse and retrieve curated Desktop Commander prompts for various tasks and workflows.
693
841
 
694
842
  IMPORTANT: When displaying prompt lists to users, do NOT show the internal prompt IDs (like 'onb_001').
@@ -718,9 +866,14 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
718
866
  Perfect for discovering proven workflows and getting started with Desktop Commander.
719
867
 
720
868
  ${CMD_PREFIX_DESCRIPTION}`,
721
- inputSchema: zodToJsonSchema(GetPromptsArgsSchema),
722
- },
723
- ],
869
+ inputSchema: zodToJsonSchema(GetPromptsArgsSchema),
870
+ },
871
+ ];
872
+ // Filter tools based on current client
873
+ const filteredTools = allTools.filter(tool => shouldIncludeTool(tool.name));
874
+ logToStderr('debug', `Returning ${filteredTools.length} tools (filtered from ${allTools.length} total) for client: ${currentClient?.name || 'unknown'}`);
875
+ return {
876
+ tools: filteredTools,
724
877
  };
725
878
  }
726
879
  catch (error) {
@@ -731,6 +884,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
731
884
  import * as handlers from './handlers/index.js';
732
885
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
733
886
  const { name, arguments: args } = request.params;
887
+ const startTime = Date.now();
734
888
  try {
735
889
  // Prepare telemetry data - add config key for set_config_value
736
890
  const telemetryData = { name };
@@ -867,6 +1021,18 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
867
1021
  };
868
1022
  }
869
1023
  break;
1024
+ case "get_recent_tool_calls":
1025
+ try {
1026
+ result = await handlers.handleGetRecentToolCalls(args);
1027
+ }
1028
+ catch (error) {
1029
+ capture('server_request_error', { message: `Error in get_recent_tool_calls handler: ${error}` });
1030
+ result = {
1031
+ content: [{ type: "text", text: `Error: Failed to get tool call history` }],
1032
+ isError: true,
1033
+ };
1034
+ }
1035
+ break;
870
1036
  case "give_feedback_to_desktop_commander":
871
1037
  try {
872
1038
  result = await giveFeedbackToDesktopCommander(args);
@@ -947,6 +1113,14 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
947
1113
  isError: true,
948
1114
  };
949
1115
  }
1116
+ // Add tool call to history (exclude only get_recent_tool_calls to prevent recursion)
1117
+ const duration = Date.now() - startTime;
1118
+ const EXCLUDED_TOOLS = [
1119
+ 'get_recent_tool_calls'
1120
+ ];
1121
+ if (!EXCLUDED_TOOLS.includes(name)) {
1122
+ toolHistory.addCall(name, args, result, duration);
1123
+ }
950
1124
  // Track success or failure based on result
951
1125
  if (result.isError) {
952
1126
  await usageTracker.trackFailure(name);
@@ -11,19 +11,21 @@ export async function getConfig() {
11
11
  const config = await configManager.getConfig();
12
12
  // Add system information and current client to the config response
13
13
  const systemInfo = getSystemInfo();
14
+ // Get memory usage
15
+ const memoryUsage = process.memoryUsage();
16
+ const memory = {
17
+ rss: `${(memoryUsage.rss / 1024 / 1024).toFixed(2)} MB`,
18
+ heapTotal: `${(memoryUsage.heapTotal / 1024 / 1024).toFixed(2)} MB`,
19
+ heapUsed: `${(memoryUsage.heapUsed / 1024 / 1024).toFixed(2)} MB`,
20
+ external: `${(memoryUsage.external / 1024 / 1024).toFixed(2)} MB`,
21
+ arrayBuffers: `${(memoryUsage.arrayBuffers / 1024 / 1024).toFixed(2)} MB`
22
+ };
14
23
  const configWithSystemInfo = {
15
24
  ...config,
16
25
  currentClient,
17
26
  systemInfo: {
18
- platform: systemInfo.platform,
19
- platformName: systemInfo.platformName,
20
- defaultShell: systemInfo.defaultShell,
21
- pathSeparator: systemInfo.pathSeparator,
22
- isWindows: systemInfo.isWindows,
23
- isMacOS: systemInfo.isMacOS,
24
- isLinux: systemInfo.isLinux,
25
- docker: systemInfo.docker,
26
- examplePaths: systemInfo.examplePaths
27
+ ...systemInfo,
28
+ memory
27
29
  }
28
30
  };
29
31
  console.error(`getConfig result: ${JSON.stringify(configWithSystemInfo, null, 2)}`);
@@ -56,7 +56,7 @@ export interface MultiFileResult {
56
56
  }
57
57
  export declare function readMultipleFiles(paths: string[]): Promise<MultiFileResult[]>;
58
58
  export declare function createDirectory(dirPath: string): Promise<void>;
59
- export declare function listDirectory(dirPath: string): Promise<string[]>;
59
+ export declare function listDirectory(dirPath: string, depth?: number): Promise<string[]>;
60
60
  export declare function moveFile(sourcePath: string, destinationPath: string): Promise<void>;
61
61
  export declare function searchFiles(rootPath: string, pattern: string): Promise<string[]>;
62
62
  export declare function getFileInfo(filePath: string): Promise<Record<string, any>>;