@wonderwhy-er/desktop-commander 0.2.52 → 0.3.1-alpha.1
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/LICENSE +20 -20
- package/README.md +1152 -1152
- package/dist/bootstrap.js +0 -0
- package/dist/command-manager.d.ts +7 -2
- package/dist/command-manager.js +16 -11
- package/dist/config-field-definitions.js +0 -0
- package/dist/config-manager.d.ts +55 -3
- package/dist/config-manager.js +329 -87
- package/dist/config-recovery.d.ts +28 -0
- package/dist/config-recovery.js +81 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +9 -0
- package/dist/custom-stdio.js +0 -0
- package/dist/data/onboarding-prompts.json +70 -70
- package/dist/error-handlers.js +0 -0
- package/dist/handlers/filesystem-handlers.d.ts +1 -1
- package/dist/handlers/filesystem-handlers.js +28 -18
- package/dist/handlers/search-answers.d.ts +58 -0
- package/dist/handlers/search-answers.js +172 -0
- package/dist/handlers/search-handlers.js +4 -92
- package/dist/index.js +14 -7
- package/dist/npm-scripts/remote.js +36 -22
- package/dist/remote-device/desktop-commander-integration.js +19 -25
- package/dist/remote-device/device.d.ts +14 -0
- package/dist/remote-device/device.js +137 -30
- package/dist/remote-device/diagnostics/device-log.d.ts +63 -0
- package/dist/remote-device/diagnostics/device-log.js +219 -0
- package/dist/remote-device/diagnostics/redact.d.ts +1 -0
- package/dist/remote-device/diagnostics/redact.js +76 -0
- package/dist/remote-device/diagnostics/report.d.ts +118 -0
- package/dist/remote-device/diagnostics/report.js +748 -0
- package/dist/remote-device/diagnostics/upload.d.ts +11 -0
- package/dist/remote-device/diagnostics/upload.js +59 -0
- package/dist/remote-device/remote-channel.d.ts +12 -0
- package/dist/remote-device/remote-channel.js +55 -8
- package/dist/remote-device/scripts/blocking-offline-update.js +133 -96
- package/dist/remote-device/transport-telemetry.d.ts +32 -0
- package/dist/remote-device/transport-telemetry.js +48 -0
- package/dist/search-manager.d.ts +239 -27
- package/dist/search-manager.js +746 -312
- package/dist/server.js +654 -621
- package/dist/setup-claude-server.js +942 -942
- package/dist/terminal-manager.d.ts +138 -21
- package/dist/terminal-manager.js +300 -215
- package/dist/tools/config.d.ts +1 -1
- package/dist/tools/config.js +21 -70
- package/dist/tools/edit.js +14 -6
- package/dist/tools/filesystem.d.ts +30 -6
- package/dist/tools/filesystem.js +246 -140
- package/dist/tools/fuzzySearch.js +9 -9
- package/dist/tools/improved-process-tools.d.ts +9 -3
- package/dist/tools/improved-process-tools.js +181 -78
- package/dist/tools/pdf/extract-images.d.ts +2 -0
- package/dist/tools/pdf/extract-images.js +4 -1
- package/dist/tools/pdf/index.d.ts +5 -3
- package/dist/tools/pdf/index.js +4 -3
- package/dist/tools/pdf/lib/pdf2md.d.ts +8 -1
- package/dist/tools/pdf/lib/pdf2md.js +12 -5
- package/dist/tools/pdf/manipulations.d.ts +12 -1
- package/dist/tools/pdf/manipulations.js +17 -4
- package/dist/tools/pdf/markdown.d.ts +96 -0
- package/dist/tools/pdf/markdown.js +485 -20
- package/dist/tools/pdf/utils.d.ts +2 -2
- package/dist/tools/pdf/utils.js +4 -4
- package/dist/tools/process.js +8 -5
- package/dist/tools/prompts.js +1 -1
- package/dist/tools/schemas.d.ts +1 -1
- package/dist/tools/schemas.js +15 -6
- package/dist/track-installation.js +387 -387
- package/dist/types.d.ts +1 -1
- package/dist/types.js +0 -0
- package/dist/ui/config-editor/config-editor-runtime.js +6 -6
- package/dist/ui/config-editor/index.html +13 -13
- package/dist/ui/config-editor/src/app.js +32 -45
- package/dist/ui/config-editor/src/array-modal.js +32 -32
- package/dist/ui/config-editor/styles.css +586 -586
- package/dist/ui/file-preview/index.html +16 -16
- package/dist/ui/file-preview/src/app.js +8 -8
- package/dist/ui/file-preview/src/document-layout.js +31 -31
- package/dist/ui/file-preview/src/document-outline.js +8 -8
- package/dist/ui/file-preview/src/markdown/conflict-dialog.js +33 -33
- package/dist/ui/file-preview/src/markdown/controller.js +9 -9
- package/dist/ui/file-preview/src/markdown/editor.js +31 -31
- package/dist/ui/file-preview/styles.css +1630 -1630
- package/dist/uninstall-claude-server.js +745 -745
- package/dist/utils/ab-test.js +27 -9
- package/dist/utils/atomic-write.d.ts +14 -0
- package/dist/utils/atomic-write.js +80 -0
- package/dist/utils/capture.d.ts +17 -1
- package/dist/utils/capture.js +177 -68
- package/dist/utils/exit-process.d.ts +24 -0
- package/dist/utils/exit-process.js +31 -0
- package/dist/utils/feature-flags.js +2 -1
- package/dist/utils/files/base.d.ts +3 -1
- package/dist/utils/files/binary.js +4 -4
- package/dist/utils/files/docx.d.ts +3 -0
- package/dist/utils/files/docx.js +24 -9
- package/dist/utils/files/excel.d.ts +10 -0
- package/dist/utils/files/excel.js +96 -36
- package/dist/utils/files/factory.d.ts +22 -1
- package/dist/utils/files/factory.js +59 -4
- package/dist/utils/files/image.d.ts +12 -4
- package/dist/utils/files/image.js +19 -8
- package/dist/utils/files/index.d.ts +5 -3
- package/dist/utils/files/index.js +4 -3
- package/dist/utils/files/pdf.js +18 -36
- package/dist/utils/files/text.d.ts +21 -5
- package/dist/utils/files/text.js +90 -86
- package/dist/utils/internal-facts.d.ts +3 -0
- package/dist/utils/internal-facts.js +23 -0
- package/dist/utils/lazy-package.d.ts +23 -0
- package/dist/utils/lazy-package.js +42 -0
- package/dist/utils/open-browser.js +2 -1
- package/dist/utils/process-detection.d.ts +24 -5
- package/dist/utils/process-detection.js +199 -89
- package/dist/utils/process-tree.d.ts +14 -0
- package/dist/utils/process-tree.js +223 -0
- package/dist/utils/rename.d.ts +9 -0
- package/dist/utils/rename.js +74 -0
- package/dist/utils/ripgrep-resolver.js +9 -14
- package/dist/utils/shell.d.ts +42 -0
- package/dist/utils/shell.js +187 -0
- package/dist/utils/system-info.js +99 -97
- package/dist/utils/trackTools.js +2 -1
- package/dist/utils/usageTracker.js +49 -49
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/node_modules/@desktop-commander/telemetry-contract/README.md +56 -0
- package/node_modules/@desktop-commander/telemetry-contract/package.json +32 -0
- package/node_modules/@desktop-commander/telemetry-contract/transport.d.ts +38 -0
- package/node_modules/@desktop-commander/telemetry-contract/transport.js +164 -0
- package/package.json +10 -3
- package/vendor/telemetry-contract/README.md +56 -0
- package/vendor/telemetry-contract/package.json +32 -0
- package/vendor/telemetry-contract/transport.d.ts +38 -0
- package/vendor/telemetry-contract/transport.js +164 -0
- package/vendor/telemetry-contract/transport.test.js +39 -0
package/dist/server.js
CHANGED
|
@@ -21,7 +21,7 @@ import { processDockerPrompt } from './utils/dockerPrompt.js';
|
|
|
21
21
|
import { toolHistory } from './utils/toolHistory.js';
|
|
22
22
|
import { handleWelcomePageOnboarding, skipWelcomePageOnboarding } from './utils/welcome-onboarding.js';
|
|
23
23
|
import { VERSION } from './version.js';
|
|
24
|
-
import { capture, capture_call_tool, runInUiOriginCallContext } from "./utils/capture.js";
|
|
24
|
+
import { addToolCallPaths, capture, capture_call_tool, runInUiOriginCallContext, runWithToolCallPaths } from "./utils/capture.js";
|
|
25
25
|
import { logToStderr, logger } from './utils/logger.js';
|
|
26
26
|
import { buildUiToolMeta, CONFIG_EDITOR_RESOURCE_URI, FILE_PREVIEW_RESOURCE_URI, } from './ui/contracts.js';
|
|
27
27
|
import { listUiResources, readUiResource } from './ui/resources.js';
|
|
@@ -223,18 +223,18 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
223
223
|
// Configuration tools
|
|
224
224
|
{
|
|
225
225
|
name: "get_config",
|
|
226
|
-
description: `
|
|
227
|
-
Get the complete server configuration as JSON. Config includes fields for:
|
|
228
|
-
- blockedCommands (array of blocked shell commands)
|
|
229
|
-
- defaultShell (shell to use for commands)
|
|
230
|
-
- allowedDirectories (paths the server can access)
|
|
231
|
-
- fileReadLineLimit (max lines for read_file, default 1000)
|
|
232
|
-
- fileWriteLineLimit (max lines per write_file call, default 50)
|
|
233
|
-
- telemetryEnabled (boolean for telemetry opt-in/out)
|
|
234
|
-
- currentClient (information about the currently connected MCP client)
|
|
235
|
-
- clientHistory (history of all clients that have connected)
|
|
236
|
-
- version (version of the DesktopCommander)
|
|
237
|
-
- systemInfo (operating system and environment details)
|
|
226
|
+
description: `
|
|
227
|
+
Get the complete server configuration as JSON. Config includes fields for:
|
|
228
|
+
- blockedCommands (array of blocked shell commands)
|
|
229
|
+
- defaultShell (shell to use for commands)
|
|
230
|
+
- allowedDirectories (paths the server can access)
|
|
231
|
+
- fileReadLineLimit (max lines for read_file, default 1000)
|
|
232
|
+
- fileWriteLineLimit (max lines per write_file call, default 50)
|
|
233
|
+
- telemetryEnabled (boolean for telemetry opt-in/out)
|
|
234
|
+
- currentClient (information about the currently connected MCP client)
|
|
235
|
+
- clientHistory (history of all clients that have connected)
|
|
236
|
+
- version (version of the DesktopCommander)
|
|
237
|
+
- systemInfo (operating system and environment details)
|
|
238
238
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
239
239
|
inputSchema: zodToJsonSchema(GetConfigArgsSchema),
|
|
240
240
|
_meta: buildUiToolMeta(CONFIG_EDITOR_RESOURCE_URI, true, showMcpUiPreviews),
|
|
@@ -245,23 +245,23 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
245
245
|
},
|
|
246
246
|
{
|
|
247
247
|
name: "set_config_value",
|
|
248
|
-
description: `
|
|
249
|
-
Set a specific configuration value by key.
|
|
250
|
-
|
|
251
|
-
WARNING: Should be used in a separate chat from file operations and
|
|
252
|
-
command execution to prevent security issues.
|
|
253
|
-
|
|
254
|
-
Config keys include:
|
|
255
|
-
- blockedCommands (array)
|
|
256
|
-
- defaultShell (string)
|
|
257
|
-
- allowedDirectories (array of paths)
|
|
258
|
-
- fileReadLineLimit (number, max lines for read_file)
|
|
259
|
-
- fileWriteLineLimit (number, max lines per write_file call)
|
|
260
|
-
- telemetryEnabled (boolean)
|
|
261
|
-
|
|
262
|
-
IMPORTANT: Setting allowedDirectories to an empty array ([]) allows full access
|
|
263
|
-
to the entire file system, regardless of the operating system.
|
|
264
|
-
|
|
248
|
+
description: `
|
|
249
|
+
Set a specific configuration value by key.
|
|
250
|
+
|
|
251
|
+
WARNING: Should be used in a separate chat from file operations and
|
|
252
|
+
command execution to prevent security issues.
|
|
253
|
+
|
|
254
|
+
Config keys include:
|
|
255
|
+
- blockedCommands (array)
|
|
256
|
+
- defaultShell (string)
|
|
257
|
+
- allowedDirectories (array of paths)
|
|
258
|
+
- fileReadLineLimit (number, max lines for read_file)
|
|
259
|
+
- fileWriteLineLimit (number, max lines per write_file call)
|
|
260
|
+
- telemetryEnabled (boolean)
|
|
261
|
+
|
|
262
|
+
IMPORTANT: Setting allowedDirectories to an empty array ([]) allows full access
|
|
263
|
+
to the entire file system, regardless of the operating system.
|
|
264
|
+
|
|
265
265
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
266
266
|
inputSchema: zodToJsonSchema(SetConfigValueArgsSchema),
|
|
267
267
|
annotations: {
|
|
@@ -274,60 +274,60 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
274
274
|
// Filesystem tools
|
|
275
275
|
{
|
|
276
276
|
name: "read_file",
|
|
277
|
-
description: `
|
|
278
|
-
Read contents from files and URLs.
|
|
279
|
-
Read PDF files and extract content as markdown and images.
|
|
280
|
-
|
|
281
|
-
Suitable for reading authorized local files directly without starting a shell command.
|
|
282
|
-
|
|
283
|
-
Supports partial file reading with:
|
|
284
|
-
- 'offset' (start line, default: 0)
|
|
285
|
-
* Positive: Start from line N (0-based indexing)
|
|
286
|
-
* Negative: Read last N lines from end (tail behavior)
|
|
287
|
-
- 'length' (max lines to read, default: configurable via 'fileReadLineLimit' setting, initially 1000)
|
|
288
|
-
* Used with positive offsets for range reading
|
|
289
|
-
* Ignored when offset is negative (reads all requested tail lines)
|
|
290
|
-
|
|
291
|
-
Examples:
|
|
292
|
-
- offset: 0, length: 10 → First 10 lines
|
|
293
|
-
- offset: 100, length: 5 → Lines 100-104
|
|
294
|
-
- offset: -20 → Last 20 lines
|
|
295
|
-
- offset: -5, length: 10 → Last 5 lines (length ignored)
|
|
296
|
-
|
|
297
|
-
Performance optimizations:
|
|
298
|
-
- Large files with negative offsets use reverse reading for efficiency
|
|
299
|
-
- Large files with deep positive offsets use byte estimation
|
|
300
|
-
- Small files use fast readline streaming
|
|
301
|
-
|
|
302
|
-
When reading from the file system, only works within allowed directories.
|
|
303
|
-
Can fetch content from URLs when isUrl parameter is set to true
|
|
304
|
-
(URLs are always read in full regardless of offset/length).
|
|
305
|
-
|
|
306
|
-
FORMAT HANDLING (by extension):
|
|
307
|
-
- Text: Uses offset/length for line-based pagination
|
|
308
|
-
- Excel (.xlsx, .xls, .xlsm): Returns JSON 2D array
|
|
309
|
-
* sheet: "Sheet1" (name) or "0" (index as string, 0-based)
|
|
310
|
-
* range: ALWAYS use FROM:TO format (e.g., "A1:D100", "C1:C1", "B2:B50")
|
|
311
|
-
* offset/length work as row pagination (optional fallback)
|
|
312
|
-
- Images (PNG, JPEG, GIF, WebP): Base64 encoded viewable content
|
|
313
|
-
- PDF: Extracts text content as markdown with page structure
|
|
314
|
-
* offset/length work as page pagination (0-based)
|
|
315
|
-
* Includes embedded images when available
|
|
316
|
-
- DOCX (.docx): Two modes depending on parameters:
|
|
317
|
-
* DEFAULT (no offset/length): Returns a text-bearing outline — shows paragraphs with text,
|
|
318
|
-
tables with cell content, styles, image refs. Skips shapes/drawings/SVG noise.
|
|
319
|
-
Each element shows its body index [0], [1], etc.
|
|
320
|
-
* WITH offset/length: Returns raw pretty-printed XML with line pagination.
|
|
321
|
-
Use this to drill into specific sections or see the actual XML for editing.
|
|
322
|
-
* EDITING WORKFLOW: 1) read_file to get outline, 2) read_file with offset/length
|
|
323
|
-
to see raw XML around what you want to edit, 3) edit_block with old_string/new_string
|
|
324
|
-
using XML fragments copied from the read output.
|
|
325
|
-
* IMPORTANT: offset MUST be non-zero to get raw XML (use offset=1 to start from line 1).
|
|
326
|
-
offset=0 always returns the outline regardless of length.
|
|
327
|
-
* For BULK changes (translation, mass replacements): use start_process with Python
|
|
328
|
-
zipfile module to find/replace all <w:t> elements at once.
|
|
329
|
-
|
|
330
|
-
${PATH_GUIDANCE}
|
|
277
|
+
description: `
|
|
278
|
+
Read contents from files and URLs.
|
|
279
|
+
Read PDF files and extract content as markdown and images.
|
|
280
|
+
|
|
281
|
+
Suitable for reading authorized local files directly without starting a shell command.
|
|
282
|
+
|
|
283
|
+
Supports partial file reading with:
|
|
284
|
+
- 'offset' (start line, default: 0)
|
|
285
|
+
* Positive: Start from line N (0-based indexing)
|
|
286
|
+
* Negative: Read last N lines from end (tail behavior)
|
|
287
|
+
- 'length' (max lines to read, default: configurable via 'fileReadLineLimit' setting, initially 1000)
|
|
288
|
+
* Used with positive offsets for range reading
|
|
289
|
+
* Ignored when offset is negative (reads all requested tail lines)
|
|
290
|
+
|
|
291
|
+
Examples:
|
|
292
|
+
- offset: 0, length: 10 → First 10 lines
|
|
293
|
+
- offset: 100, length: 5 → Lines 100-104
|
|
294
|
+
- offset: -20 → Last 20 lines
|
|
295
|
+
- offset: -5, length: 10 → Last 5 lines (length ignored)
|
|
296
|
+
|
|
297
|
+
Performance optimizations:
|
|
298
|
+
- Large files with negative offsets use reverse reading for efficiency
|
|
299
|
+
- Large files with deep positive offsets use byte estimation
|
|
300
|
+
- Small files use fast readline streaming
|
|
301
|
+
|
|
302
|
+
When reading from the file system, only works within allowed directories.
|
|
303
|
+
Can fetch content from URLs when isUrl parameter is set to true
|
|
304
|
+
(URLs are always read in full regardless of offset/length).
|
|
305
|
+
|
|
306
|
+
FORMAT HANDLING (by extension):
|
|
307
|
+
- Text: Uses offset/length for line-based pagination
|
|
308
|
+
- Excel (.xlsx, .xls, .xlsm): Returns JSON 2D array
|
|
309
|
+
* sheet: "Sheet1" (name) or "0" (index as string, 0-based)
|
|
310
|
+
* range: ALWAYS use FROM:TO format (e.g., "A1:D100", "C1:C1", "B2:B50")
|
|
311
|
+
* offset/length work as row pagination (optional fallback)
|
|
312
|
+
- Images (PNG, JPEG, GIF, WebP): Base64 encoded viewable content
|
|
313
|
+
- PDF: Extracts text content as markdown with page structure
|
|
314
|
+
* offset/length work as page pagination (0-based)
|
|
315
|
+
* Includes embedded images when available
|
|
316
|
+
- DOCX (.docx): Two modes depending on parameters:
|
|
317
|
+
* DEFAULT (no offset/length): Returns a text-bearing outline — shows paragraphs with text,
|
|
318
|
+
tables with cell content, styles, image refs. Skips shapes/drawings/SVG noise.
|
|
319
|
+
Each element shows its body index [0], [1], etc.
|
|
320
|
+
* WITH offset/length: Returns raw pretty-printed XML with line pagination.
|
|
321
|
+
Use this to drill into specific sections or see the actual XML for editing.
|
|
322
|
+
* EDITING WORKFLOW: 1) read_file to get outline, 2) read_file with offset/length
|
|
323
|
+
to see raw XML around what you want to edit, 3) edit_block with old_string/new_string
|
|
324
|
+
using XML fragments copied from the read output.
|
|
325
|
+
* IMPORTANT: offset MUST be non-zero to get raw XML (use offset=1 to start from line 1).
|
|
326
|
+
offset=0 always returns the outline regardless of length.
|
|
327
|
+
* For BULK changes (translation, mass replacements): use start_process with Python
|
|
328
|
+
zipfile module to find/replace all <w:t> elements at once.
|
|
329
|
+
|
|
330
|
+
${PATH_GUIDANCE}
|
|
331
331
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
332
332
|
inputSchema: zodToJsonSchema(ReadFileArgsSchema),
|
|
333
333
|
_meta: buildUiToolMeta(FILE_PREVIEW_RESOURCE_URI, true, showMcpUiPreviews),
|
|
@@ -339,17 +339,17 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
339
339
|
},
|
|
340
340
|
{
|
|
341
341
|
name: "read_multiple_files",
|
|
342
|
-
description: `
|
|
343
|
-
Read the contents of multiple files simultaneously.
|
|
344
|
-
|
|
345
|
-
Each file's content is returned with its path as a reference.
|
|
346
|
-
Handles text files normally and renders images as viewable content.
|
|
347
|
-
Recognized image types: PNG, JPEG, GIF, WebP.
|
|
348
|
-
|
|
349
|
-
Failed reads for individual files won't stop the entire operation.
|
|
350
|
-
Only works within allowed directories.
|
|
351
|
-
|
|
352
|
-
${PATH_GUIDANCE}
|
|
342
|
+
description: `
|
|
343
|
+
Read the contents of multiple files simultaneously.
|
|
344
|
+
|
|
345
|
+
Each file's content is returned with its path as a reference.
|
|
346
|
+
Handles text files normally and renders images as viewable content.
|
|
347
|
+
Recognized image types: PNG, JPEG, GIF, WebP.
|
|
348
|
+
|
|
349
|
+
Failed reads for individual files won't stop the entire operation.
|
|
350
|
+
Only works within allowed directories.
|
|
351
|
+
|
|
352
|
+
${PATH_GUIDANCE}
|
|
353
353
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
354
354
|
inputSchema: zodToJsonSchema(ReadMultipleFilesArgsSchema),
|
|
355
355
|
annotations: {
|
|
@@ -359,43 +359,43 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
359
359
|
},
|
|
360
360
|
{
|
|
361
361
|
name: "write_file",
|
|
362
|
-
description: `
|
|
363
|
-
Write or append to file contents.
|
|
364
|
-
|
|
365
|
-
IMPORTANT: DO NOT use this tool to create PDF files. Use 'write_pdf' for all PDF creation tasks.
|
|
366
|
-
DO NOT use this tool to edit DOCX files. Use 'edit_block' with old_string/new_string instead.
|
|
367
|
-
To CREATE a new DOCX, use write_file with .docx extension — text content with markdown headings (#, ##, ###) is converted to styled DOCX paragraphs.
|
|
368
|
-
|
|
369
|
-
CHUNKING IS STANDARD PRACTICE: Always write files in chunks of 25-30 lines maximum.
|
|
370
|
-
This is the normal, recommended way to write files - not an emergency measure.
|
|
371
|
-
|
|
372
|
-
STANDARD PROCESS FOR ANY FILE:
|
|
373
|
-
1. FIRST → write_file(filePath, firstChunk, {mode: 'rewrite'}) [≤30 lines]
|
|
374
|
-
2. THEN → write_file(filePath, secondChunk, {mode: 'append'}) [≤30 lines]
|
|
375
|
-
3. CONTINUE → write_file(filePath, nextChunk, {mode: 'append'}) [≤30 lines]
|
|
376
|
-
|
|
377
|
-
ALWAYS CHUNK PROACTIVELY - don't wait for performance warnings!
|
|
378
|
-
|
|
379
|
-
WHEN TO CHUNK (always be proactive):
|
|
380
|
-
1. Any file expected to be longer than 25-30 lines
|
|
381
|
-
2. When writing multiple files in sequence
|
|
382
|
-
3. When creating documentation, code files, or configuration files
|
|
383
|
-
|
|
384
|
-
HANDLING CONTINUATION ("Continue" prompts):
|
|
385
|
-
If user asks to "Continue" after an incomplete operation:
|
|
386
|
-
1. Read the file to see what was successfully written
|
|
387
|
-
2. Continue writing ONLY the remaining content using {mode: 'append'}
|
|
388
|
-
3. Keep chunks to 25-30 lines each
|
|
389
|
-
|
|
390
|
-
FORMAT HANDLING (by extension):
|
|
391
|
-
- Text files: String content
|
|
392
|
-
- Excel (.xlsx, .xls, .xlsm): JSON 2D array or {"SheetName": [[...]]}
|
|
393
|
-
Example: '[["Name","Age"],["Alice",30]]'
|
|
394
|
-
|
|
395
|
-
Files over 50 lines will generate performance notes but are still written successfully.
|
|
396
|
-
Only works within allowed directories.
|
|
397
|
-
|
|
398
|
-
${PATH_GUIDANCE}
|
|
362
|
+
description: `
|
|
363
|
+
Write or append to file contents.
|
|
364
|
+
|
|
365
|
+
IMPORTANT: DO NOT use this tool to create PDF files. Use 'write_pdf' for all PDF creation tasks.
|
|
366
|
+
DO NOT use this tool to edit DOCX files. Use 'edit_block' with old_string/new_string instead.
|
|
367
|
+
To CREATE a new DOCX, use write_file with .docx extension — text content with markdown headings (#, ##, ###) is converted to styled DOCX paragraphs.
|
|
368
|
+
|
|
369
|
+
CHUNKING IS STANDARD PRACTICE: Always write files in chunks of 25-30 lines maximum.
|
|
370
|
+
This is the normal, recommended way to write files - not an emergency measure.
|
|
371
|
+
|
|
372
|
+
STANDARD PROCESS FOR ANY FILE:
|
|
373
|
+
1. FIRST → write_file(filePath, firstChunk, {mode: 'rewrite'}) [≤30 lines]
|
|
374
|
+
2. THEN → write_file(filePath, secondChunk, {mode: 'append'}) [≤30 lines]
|
|
375
|
+
3. CONTINUE → write_file(filePath, nextChunk, {mode: 'append'}) [≤30 lines]
|
|
376
|
+
|
|
377
|
+
ALWAYS CHUNK PROACTIVELY - don't wait for performance warnings!
|
|
378
|
+
|
|
379
|
+
WHEN TO CHUNK (always be proactive):
|
|
380
|
+
1. Any file expected to be longer than 25-30 lines
|
|
381
|
+
2. When writing multiple files in sequence
|
|
382
|
+
3. When creating documentation, code files, or configuration files
|
|
383
|
+
|
|
384
|
+
HANDLING CONTINUATION ("Continue" prompts):
|
|
385
|
+
If user asks to "Continue" after an incomplete operation:
|
|
386
|
+
1. Read the file to see what was successfully written
|
|
387
|
+
2. Continue writing ONLY the remaining content using {mode: 'append'}
|
|
388
|
+
3. Keep chunks to 25-30 lines each
|
|
389
|
+
|
|
390
|
+
FORMAT HANDLING (by extension):
|
|
391
|
+
- Text files: String content
|
|
392
|
+
- Excel (.xlsx, .xls, .xlsm): JSON 2D array or {"SheetName": [[...]]}
|
|
393
|
+
Example: '[["Name","Age"],["Alice",30]]'
|
|
394
|
+
|
|
395
|
+
Files over 50 lines will generate performance notes but are still written successfully.
|
|
396
|
+
Only works within allowed directories.
|
|
397
|
+
|
|
398
|
+
${PATH_GUIDANCE}
|
|
399
399
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
400
400
|
inputSchema: zodToJsonSchema(WriteFileArgsSchema),
|
|
401
401
|
_meta: buildUiToolMeta(FILE_PREVIEW_RESOURCE_URI, true, showMcpUiPreviews),
|
|
@@ -408,57 +408,57 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
408
408
|
},
|
|
409
409
|
{
|
|
410
410
|
name: "write_pdf",
|
|
411
|
-
description: `
|
|
412
|
-
Create a new PDF file or modify an existing one.
|
|
413
|
-
|
|
414
|
-
THIS IS THE ONLY TOOL FOR CREATING AND MODIFYING PDF FILES.
|
|
415
|
-
|
|
416
|
-
RULES ABOUT FILENAMES:
|
|
417
|
-
- When creating a new PDF, 'outputPath' MUST be provided and MUST use a new unique filename (e.g., "result_01.pdf", "analysis_2025_01.pdf", etc.).
|
|
418
|
-
|
|
419
|
-
MODES:
|
|
420
|
-
1. CREATE NEW PDF:
|
|
421
|
-
- Pass a markdown string as 'content'.
|
|
422
|
-
write_pdf(path="doc.pdf", content="# Title\\n\\nBody text...")
|
|
423
|
-
|
|
424
|
-
2. MODIFY EXISTING PDF:
|
|
425
|
-
- Pass array of operations as 'content'.
|
|
426
|
-
- NEVER overwrite the original file.
|
|
427
|
-
- ALWAYS provide a new filename in 'outputPath'.
|
|
428
|
-
- After modifying, show original file path and new file path to user.
|
|
429
|
-
|
|
430
|
-
write_pdf(path="doc.pdf", content=[
|
|
431
|
-
{ type: "delete", pageIndexes: [0, 2] },
|
|
432
|
-
{ type: "insert", pageIndex: 1, markdown: "# New Page" }
|
|
433
|
-
])
|
|
434
|
-
|
|
435
|
-
OPERATIONS:
|
|
436
|
-
- delete: Remove pages by 0-based index.
|
|
437
|
-
{ type: "delete", pageIndexes: [0, 1, 5] }
|
|
438
|
-
|
|
439
|
-
- insert: Add pages at a specific 0-based index.
|
|
440
|
-
{ type: "insert", pageIndex: 0, markdown: "..." }
|
|
441
|
-
{ type: "insert", pageIndex: 5, sourcePdfPath: "/path/to/source.pdf" }
|
|
442
|
-
|
|
443
|
-
PAGE BREAKS:
|
|
444
|
-
To force a page break, use this HTML element:
|
|
445
|
-
<div style="page-break-before: always;"></div>
|
|
446
|
-
|
|
447
|
-
Example:
|
|
448
|
-
"# Page 1\\n\\n<div style=\\"page-break-before: always;\\"></div>\\n\\n# Page 2"
|
|
449
|
-
|
|
450
|
-
ADVANCED STYLING:
|
|
451
|
-
HTML/CSS and inline SVG are supported for:
|
|
452
|
-
- Text styling: colors, sizes, alignment, highlights
|
|
453
|
-
- Boxes: borders, backgrounds, padding, rounded corners
|
|
454
|
-
- SVG graphics: charts, diagrams, icons, shapes
|
|
455
|
-
- Images: <img src="/absolute/path/image.jpg" width="300" /> or 
|
|
456
|
-
|
|
457
|
-
Supports standard markdown features including headers, lists, code blocks, tables, and basic formatting.
|
|
458
|
-
|
|
459
|
-
Only works within allowed directories.
|
|
460
|
-
|
|
461
|
-
${PATH_GUIDANCE}
|
|
411
|
+
description: `
|
|
412
|
+
Create a new PDF file or modify an existing one.
|
|
413
|
+
|
|
414
|
+
THIS IS THE ONLY TOOL FOR CREATING AND MODIFYING PDF FILES.
|
|
415
|
+
|
|
416
|
+
RULES ABOUT FILENAMES:
|
|
417
|
+
- When creating a new PDF, 'outputPath' MUST be provided and MUST use a new unique filename (e.g., "result_01.pdf", "analysis_2025_01.pdf", etc.).
|
|
418
|
+
|
|
419
|
+
MODES:
|
|
420
|
+
1. CREATE NEW PDF:
|
|
421
|
+
- Pass a markdown string as 'content'.
|
|
422
|
+
write_pdf(path="doc.pdf", content="# Title\\n\\nBody text...")
|
|
423
|
+
|
|
424
|
+
2. MODIFY EXISTING PDF:
|
|
425
|
+
- Pass array of operations as 'content'.
|
|
426
|
+
- NEVER overwrite the original file.
|
|
427
|
+
- ALWAYS provide a new filename in 'outputPath'.
|
|
428
|
+
- After modifying, show original file path and new file path to user.
|
|
429
|
+
|
|
430
|
+
write_pdf(path="doc.pdf", content=[
|
|
431
|
+
{ type: "delete", pageIndexes: [0, 2] },
|
|
432
|
+
{ type: "insert", pageIndex: 1, markdown: "# New Page" }
|
|
433
|
+
])
|
|
434
|
+
|
|
435
|
+
OPERATIONS:
|
|
436
|
+
- delete: Remove pages by 0-based index.
|
|
437
|
+
{ type: "delete", pageIndexes: [0, 1, 5] }
|
|
438
|
+
|
|
439
|
+
- insert: Add pages at a specific 0-based index.
|
|
440
|
+
{ type: "insert", pageIndex: 0, markdown: "..." }
|
|
441
|
+
{ type: "insert", pageIndex: 5, sourcePdfPath: "/path/to/source.pdf" }
|
|
442
|
+
|
|
443
|
+
PAGE BREAKS:
|
|
444
|
+
To force a page break, use this HTML element:
|
|
445
|
+
<div style="page-break-before: always;"></div>
|
|
446
|
+
|
|
447
|
+
Example:
|
|
448
|
+
"# Page 1\\n\\n<div style=\\"page-break-before: always;\\"></div>\\n\\n# Page 2"
|
|
449
|
+
|
|
450
|
+
ADVANCED STYLING:
|
|
451
|
+
HTML/CSS and inline SVG are supported for:
|
|
452
|
+
- Text styling: colors, sizes, alignment, highlights
|
|
453
|
+
- Boxes: borders, backgrounds, padding, rounded corners
|
|
454
|
+
- SVG graphics: charts, diagrams, icons, shapes
|
|
455
|
+
- Images: <img src="/absolute/path/image.jpg" width="300" /> or 
|
|
456
|
+
|
|
457
|
+
Supports standard markdown features including headers, lists, code blocks, tables, and basic formatting.
|
|
458
|
+
|
|
459
|
+
Only works within allowed directories.
|
|
460
|
+
|
|
461
|
+
${PATH_GUIDANCE}
|
|
462
462
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
463
463
|
inputSchema: zodToJsonSchema(WritePdfArgsSchema),
|
|
464
464
|
annotations: {
|
|
@@ -470,13 +470,13 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
470
470
|
},
|
|
471
471
|
{
|
|
472
472
|
name: "create_directory",
|
|
473
|
-
description: `
|
|
474
|
-
Create a new directory or ensure a directory exists.
|
|
475
|
-
|
|
476
|
-
Can create multiple nested directories in one operation.
|
|
477
|
-
Only works within allowed directories.
|
|
478
|
-
|
|
479
|
-
${PATH_GUIDANCE}
|
|
473
|
+
description: `
|
|
474
|
+
Create a new directory or ensure a directory exists.
|
|
475
|
+
|
|
476
|
+
Can create multiple nested directories in one operation.
|
|
477
|
+
Only works within allowed directories.
|
|
478
|
+
|
|
479
|
+
${PATH_GUIDANCE}
|
|
480
480
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
481
481
|
inputSchema: zodToJsonSchema(CreateDirectoryArgsSchema),
|
|
482
482
|
annotations: {
|
|
@@ -487,36 +487,36 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
487
487
|
},
|
|
488
488
|
{
|
|
489
489
|
name: "list_directory",
|
|
490
|
-
description: `
|
|
491
|
-
Get a detailed listing of all files and directories in a specified path.
|
|
492
|
-
|
|
493
|
-
Use this instead of 'execute_command' with ls/dir commands.
|
|
494
|
-
Results distinguish between files and directories with [FILE] and [DIR] prefixes.
|
|
495
|
-
|
|
496
|
-
Supports recursive listing with the 'depth' parameter (default: 2):
|
|
497
|
-
- depth=1: Only direct contents of the directory
|
|
498
|
-
- depth=2: Contents plus one level of subdirectories
|
|
499
|
-
- depth=3+: Multiple levels deep
|
|
500
|
-
|
|
501
|
-
CONTEXT OVERFLOW PROTECTION:
|
|
502
|
-
- Top-level directory shows ALL items
|
|
503
|
-
- Nested directories are limited to 100 items maximum per directory
|
|
504
|
-
- When a nested directory has more than 100 items, you'll see a warning like:
|
|
505
|
-
[WARNING] node_modules: 500 items hidden (showing first 100 of 600 total)
|
|
506
|
-
- This prevents overwhelming the context with large directories like node_modules
|
|
507
|
-
|
|
508
|
-
Results show full relative paths from the root directory being listed.
|
|
509
|
-
Example output with depth=2:
|
|
510
|
-
[DIR] src
|
|
511
|
-
[FILE] src/index.ts
|
|
512
|
-
[DIR] src/tools
|
|
513
|
-
[FILE] src/tools/filesystem.ts
|
|
514
|
-
|
|
515
|
-
If a directory cannot be accessed, it will show [DENIED] instead.
|
|
516
|
-
If a path does not exist, it will show [NOT_FOUND] instead.
|
|
517
|
-
Only works within allowed directories.
|
|
518
|
-
|
|
519
|
-
${PATH_GUIDANCE}
|
|
490
|
+
description: `
|
|
491
|
+
Get a detailed listing of all files and directories in a specified path.
|
|
492
|
+
|
|
493
|
+
Use this instead of 'execute_command' with ls/dir commands.
|
|
494
|
+
Results distinguish between files and directories with [FILE] and [DIR] prefixes.
|
|
495
|
+
|
|
496
|
+
Supports recursive listing with the 'depth' parameter (default: 2):
|
|
497
|
+
- depth=1: Only direct contents of the directory
|
|
498
|
+
- depth=2: Contents plus one level of subdirectories
|
|
499
|
+
- depth=3+: Multiple levels deep
|
|
500
|
+
|
|
501
|
+
CONTEXT OVERFLOW PROTECTION:
|
|
502
|
+
- Top-level directory shows ALL items
|
|
503
|
+
- Nested directories are limited to 100 items maximum per directory
|
|
504
|
+
- When a nested directory has more than 100 items, you'll see a warning like:
|
|
505
|
+
[WARNING] node_modules: 500 items hidden (showing first 100 of 600 total)
|
|
506
|
+
- This prevents overwhelming the context with large directories like node_modules
|
|
507
|
+
|
|
508
|
+
Results show full relative paths from the root directory being listed.
|
|
509
|
+
Example output with depth=2:
|
|
510
|
+
[DIR] src
|
|
511
|
+
[FILE] src/index.ts
|
|
512
|
+
[DIR] src/tools
|
|
513
|
+
[FILE] src/tools/filesystem.ts
|
|
514
|
+
|
|
515
|
+
If a directory cannot be accessed, it will show [DENIED] instead.
|
|
516
|
+
If a path does not exist, it will show [NOT_FOUND] instead.
|
|
517
|
+
Only works within allowed directories.
|
|
518
|
+
|
|
519
|
+
${PATH_GUIDANCE}
|
|
520
520
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
521
521
|
inputSchema: zodToJsonSchema(ListDirectoryArgsSchema),
|
|
522
522
|
_meta: buildUiToolMeta(FILE_PREVIEW_RESOURCE_URI, true, showMcpUiPreviews),
|
|
@@ -527,13 +527,13 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
527
527
|
},
|
|
528
528
|
{
|
|
529
529
|
name: "move_file",
|
|
530
|
-
description: `
|
|
531
|
-
Move or rename files and directories.
|
|
532
|
-
|
|
533
|
-
Can move files between directories and rename them in a single operation.
|
|
534
|
-
Both source and destination must be within allowed directories.
|
|
535
|
-
|
|
536
|
-
${PATH_GUIDANCE}
|
|
530
|
+
description: `
|
|
531
|
+
Move or rename files and directories.
|
|
532
|
+
|
|
533
|
+
Can move files between directories and rename them in a single operation.
|
|
534
|
+
Both source and destination must be within allowed directories.
|
|
535
|
+
|
|
536
|
+
${PATH_GUIDANCE}
|
|
537
537
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
538
538
|
inputSchema: zodToJsonSchema(MoveFileArgsSchema),
|
|
539
539
|
annotations: {
|
|
@@ -545,84 +545,84 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
545
545
|
},
|
|
546
546
|
{
|
|
547
547
|
name: "start_search",
|
|
548
|
-
description: `
|
|
549
|
-
Start a streaming search that can return results progressively.
|
|
550
|
-
|
|
551
|
-
SEARCH STRATEGY GUIDE:
|
|
552
|
-
Choose the right search type based on what the user is looking for:
|
|
553
|
-
|
|
554
|
-
USE searchType="files" WHEN:
|
|
555
|
-
- User asks for specific files: "find package.json", "locate config files"
|
|
556
|
-
- Pattern looks like a filename: "*.js", "README.md", "test-*.tsx"
|
|
557
|
-
- User wants to find files by name/extension: "all TypeScript files", "Python scripts"
|
|
558
|
-
- Looking for configuration/setup files: ".env", "dockerfile", "tsconfig.json"
|
|
559
|
-
|
|
560
|
-
USE searchType="content" WHEN:
|
|
561
|
-
- User asks about code/logic: "authentication logic", "error handling", "API calls"
|
|
562
|
-
- Looking for functions/variables: "getUserData function", "useState hook"
|
|
563
|
-
- Searching for text/comments: "TODO items", "FIXME comments", "documentation"
|
|
564
|
-
- Finding patterns in code: "console.log statements", "import statements"
|
|
565
|
-
- User describes functionality: "components that handle login", "files with database queries"
|
|
566
|
-
|
|
567
|
-
WHEN UNSURE OR USER REQUEST IS AMBIGUOUS:
|
|
568
|
-
Run TWO searches in parallel - one for files and one for content:
|
|
569
|
-
|
|
570
|
-
Example approach for ambiguous queries like "find authentication stuff":
|
|
571
|
-
1. Start file search: searchType="files", pattern="auth"
|
|
572
|
-
2. Simultaneously start content search: searchType="content", pattern="authentication"
|
|
573
|
-
3. Present combined results: "Found 3 auth-related files and 8 files containing authentication code"
|
|
574
|
-
|
|
575
|
-
SEARCH TYPES:
|
|
576
|
-
- searchType="files": Find files by name (pattern matches file names)
|
|
577
|
-
- searchType="content": Search inside files for text patterns
|
|
578
|
-
|
|
579
|
-
PATTERN MATCHING MODES:
|
|
580
|
-
- Default (literalSearch=false): Patterns are treated as regular expressions
|
|
581
|
-
- Literal (literalSearch=true): Patterns are treated as exact strings
|
|
582
|
-
|
|
583
|
-
WHEN TO USE literalSearch=true:
|
|
584
|
-
Use literal search when searching for code patterns with special characters:
|
|
585
|
-
- Function calls with parentheses and quotes
|
|
586
|
-
- Array access with brackets
|
|
587
|
-
- Object methods with dots and parentheses
|
|
588
|
-
- File paths with backslashes
|
|
589
|
-
- Any pattern containing: . * + ? ^ $ { } [ ] | \\ ( )
|
|
590
|
-
|
|
591
|
-
IMPORTANT PARAMETERS:
|
|
592
|
-
- pattern: What to search for (file names OR content text)
|
|
593
|
-
- literalSearch: Use exact string matching instead of regex (default: false)
|
|
594
|
-
- filePattern: Optional filter to limit search to specific file types (e.g., "*.js", "package.json")
|
|
595
|
-
- ignoreCase: Case-insensitive search (default: true). Works for both file names and content.
|
|
596
|
-
- earlyTermination: Stop search early when exact filename match is found (optional: defaults to true for file searches, false for content searches)
|
|
597
|
-
|
|
598
|
-
DECISION EXAMPLES:
|
|
599
|
-
- "find package.json" → searchType="files", pattern="package.json" (specific file)
|
|
600
|
-
- "find authentication components" → searchType="content", pattern="authentication" (looking for functionality)
|
|
601
|
-
- "locate all React components" → searchType="files", pattern="*.tsx" or "*.jsx" (file pattern)
|
|
602
|
-
- "find TODO comments" → searchType="content", pattern="TODO" (text in files)
|
|
603
|
-
- "show me login files" → AMBIGUOUS → run both: files with "login" AND content with "login"
|
|
604
|
-
- "find config" → AMBIGUOUS → run both: config files AND files containing config code
|
|
605
|
-
|
|
606
|
-
COMPREHENSIVE SEARCH EXAMPLES:
|
|
607
|
-
- Find package.json files: searchType="files", pattern="package.json"
|
|
608
|
-
- Find all JS files: searchType="files", pattern="*.js"
|
|
609
|
-
- Search for TODO in code: searchType="content", pattern="TODO", filePattern="*.js|*.ts"
|
|
610
|
-
- Search for exact code: searchType="content", pattern="toast.error('test')", literalSearch=true
|
|
611
|
-
- Ambiguous request "find auth stuff": Run two searches:
|
|
612
|
-
1. searchType="files", pattern="auth"
|
|
613
|
-
2. searchType="content", pattern="authentication"
|
|
614
|
-
|
|
615
|
-
PRO TIP: When user requests are ambiguous about whether they want files or content,
|
|
616
|
-
run both searches concurrently and combine results for comprehensive coverage.
|
|
617
|
-
|
|
618
|
-
Unlike regular search tools, this starts a background search process and returns
|
|
619
|
-
immediately with a session ID. Use get_more_search_results to get results as they
|
|
620
|
-
come in, and stop_search to stop the search early if needed.
|
|
621
|
-
|
|
622
|
-
Perfect for large directories where you want to see results immediately and
|
|
623
|
-
have the option to cancel if the search takes too long or you find what you need.
|
|
624
|
-
|
|
625
|
-
${PATH_GUIDANCE}
|
|
548
|
+
description: `
|
|
549
|
+
Start a streaming search that can return results progressively.
|
|
550
|
+
|
|
551
|
+
SEARCH STRATEGY GUIDE:
|
|
552
|
+
Choose the right search type based on what the user is looking for:
|
|
553
|
+
|
|
554
|
+
USE searchType="files" WHEN:
|
|
555
|
+
- User asks for specific files: "find package.json", "locate config files"
|
|
556
|
+
- Pattern looks like a filename: "*.js", "README.md", "test-*.tsx"
|
|
557
|
+
- User wants to find files by name/extension: "all TypeScript files", "Python scripts"
|
|
558
|
+
- Looking for configuration/setup files: ".env", "dockerfile", "tsconfig.json"
|
|
559
|
+
|
|
560
|
+
USE searchType="content" WHEN:
|
|
561
|
+
- User asks about code/logic: "authentication logic", "error handling", "API calls"
|
|
562
|
+
- Looking for functions/variables: "getUserData function", "useState hook"
|
|
563
|
+
- Searching for text/comments: "TODO items", "FIXME comments", "documentation"
|
|
564
|
+
- Finding patterns in code: "console.log statements", "import statements"
|
|
565
|
+
- User describes functionality: "components that handle login", "files with database queries"
|
|
566
|
+
|
|
567
|
+
WHEN UNSURE OR USER REQUEST IS AMBIGUOUS:
|
|
568
|
+
Run TWO searches in parallel - one for files and one for content:
|
|
569
|
+
|
|
570
|
+
Example approach for ambiguous queries like "find authentication stuff":
|
|
571
|
+
1. Start file search: searchType="files", pattern="auth"
|
|
572
|
+
2. Simultaneously start content search: searchType="content", pattern="authentication"
|
|
573
|
+
3. Present combined results: "Found 3 auth-related files and 8 files containing authentication code"
|
|
574
|
+
|
|
575
|
+
SEARCH TYPES:
|
|
576
|
+
- searchType="files": Find files by name (pattern matches file names)
|
|
577
|
+
- searchType="content": Search inside files for text patterns
|
|
578
|
+
|
|
579
|
+
PATTERN MATCHING MODES:
|
|
580
|
+
- Default (literalSearch=false): Patterns are treated as regular expressions
|
|
581
|
+
- Literal (literalSearch=true): Patterns are treated as exact strings
|
|
582
|
+
|
|
583
|
+
WHEN TO USE literalSearch=true:
|
|
584
|
+
Use literal search when searching for code patterns with special characters:
|
|
585
|
+
- Function calls with parentheses and quotes
|
|
586
|
+
- Array access with brackets
|
|
587
|
+
- Object methods with dots and parentheses
|
|
588
|
+
- File paths with backslashes
|
|
589
|
+
- Any pattern containing: . * + ? ^ $ { } [ ] | \\ ( )
|
|
590
|
+
|
|
591
|
+
IMPORTANT PARAMETERS:
|
|
592
|
+
- pattern: What to search for (file names OR content text)
|
|
593
|
+
- literalSearch: Use exact string matching instead of regex (default: false)
|
|
594
|
+
- filePattern: Optional filter to limit search to specific file types (e.g., "*.js", "package.json")
|
|
595
|
+
- ignoreCase: Case-insensitive search (default: true). Works for both file names and content.
|
|
596
|
+
- earlyTermination: Stop search early when exact filename match is found (optional: defaults to true for file searches, false for content searches)
|
|
597
|
+
|
|
598
|
+
DECISION EXAMPLES:
|
|
599
|
+
- "find package.json" → searchType="files", pattern="package.json" (specific file)
|
|
600
|
+
- "find authentication components" → searchType="content", pattern="authentication" (looking for functionality)
|
|
601
|
+
- "locate all React components" → searchType="files", pattern="*.tsx" or "*.jsx" (file pattern)
|
|
602
|
+
- "find TODO comments" → searchType="content", pattern="TODO" (text in files)
|
|
603
|
+
- "show me login files" → AMBIGUOUS → run both: files with "login" AND content with "login"
|
|
604
|
+
- "find config" → AMBIGUOUS → run both: config files AND files containing config code
|
|
605
|
+
|
|
606
|
+
COMPREHENSIVE SEARCH EXAMPLES:
|
|
607
|
+
- Find package.json files: searchType="files", pattern="package.json"
|
|
608
|
+
- Find all JS files: searchType="files", pattern="*.js"
|
|
609
|
+
- Search for TODO in code: searchType="content", pattern="TODO", filePattern="*.js|*.ts"
|
|
610
|
+
- Search for exact code: searchType="content", pattern="toast.error('test')", literalSearch=true
|
|
611
|
+
- Ambiguous request "find auth stuff": Run two searches:
|
|
612
|
+
1. searchType="files", pattern="auth"
|
|
613
|
+
2. searchType="content", pattern="authentication"
|
|
614
|
+
|
|
615
|
+
PRO TIP: When user requests are ambiguous about whether they want files or content,
|
|
616
|
+
run both searches concurrently and combine results for comprehensive coverage.
|
|
617
|
+
|
|
618
|
+
Unlike regular search tools, this starts a background search process and returns
|
|
619
|
+
immediately with a session ID. Use get_more_search_results to get results as they
|
|
620
|
+
come in, and stop_search to stop the search early if needed.
|
|
621
|
+
|
|
622
|
+
Perfect for large directories where you want to see results immediately and
|
|
623
|
+
have the option to cancel if the search takes too long or you find what you need.
|
|
624
|
+
|
|
625
|
+
${PATH_GUIDANCE}
|
|
626
626
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
627
627
|
inputSchema: zodToJsonSchema(StartSearchArgsSchema),
|
|
628
628
|
annotations: {
|
|
@@ -632,27 +632,27 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
632
632
|
},
|
|
633
633
|
{
|
|
634
634
|
name: "get_more_search_results",
|
|
635
|
-
description: `
|
|
636
|
-
Get more results from an active search with offset-based pagination.
|
|
637
|
-
|
|
638
|
-
Supports partial result reading with:
|
|
639
|
-
- 'offset' (start result index, default: 0)
|
|
640
|
-
* Positive: Start from result N (0-based indexing)
|
|
641
|
-
* Negative: Read last N results from end (tail behavior)
|
|
642
|
-
- 'length' (max results to read, default: 100)
|
|
643
|
-
* Used with positive offsets for range reading
|
|
644
|
-
* Ignored when offset is negative (reads all requested tail results)
|
|
645
|
-
|
|
646
|
-
Examples:
|
|
647
|
-
- offset: 0, length: 100 → First 100 results
|
|
648
|
-
- offset: 200, length: 50 → Results 200-249
|
|
649
|
-
- offset: -20 → Last 20 results
|
|
650
|
-
- offset: -5, length: 10 → Last 5 results (length ignored)
|
|
651
|
-
|
|
652
|
-
Returns only results in the specified range, along with search status.
|
|
653
|
-
Works like read_process_output - call this repeatedly to get progressive
|
|
654
|
-
results from a search started with start_search.
|
|
655
|
-
|
|
635
|
+
description: `
|
|
636
|
+
Get more results from an active search with offset-based pagination.
|
|
637
|
+
|
|
638
|
+
Supports partial result reading with:
|
|
639
|
+
- 'offset' (start result index, default: 0)
|
|
640
|
+
* Positive: Start from result N (0-based indexing)
|
|
641
|
+
* Negative: Read last N results from end (tail behavior)
|
|
642
|
+
- 'length' (max results to read, default: 100)
|
|
643
|
+
* Used with positive offsets for range reading
|
|
644
|
+
* Ignored when offset is negative (reads all requested tail results)
|
|
645
|
+
|
|
646
|
+
Examples:
|
|
647
|
+
- offset: 0, length: 100 → First 100 results
|
|
648
|
+
- offset: 200, length: 50 → Results 200-249
|
|
649
|
+
- offset: -20 → Last 20 results
|
|
650
|
+
- offset: -5, length: 10 → Last 5 results (length ignored)
|
|
651
|
+
|
|
652
|
+
Returns only results in the specified range, along with search status.
|
|
653
|
+
Works like read_process_output - call this repeatedly to get progressive
|
|
654
|
+
results from a search started with start_search.
|
|
655
|
+
|
|
656
656
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
657
657
|
inputSchema: zodToJsonSchema(GetMoreSearchResultsArgsSchema),
|
|
658
658
|
annotations: {
|
|
@@ -662,16 +662,16 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
662
662
|
},
|
|
663
663
|
{
|
|
664
664
|
name: "stop_search",
|
|
665
|
-
description: `
|
|
666
|
-
Stop an active search.
|
|
667
|
-
|
|
668
|
-
Stops the background search process gracefully. Use this when you've found
|
|
669
|
-
what you need or if a search is taking too long. Similar to force_terminate
|
|
670
|
-
for terminal processes.
|
|
671
|
-
|
|
672
|
-
The search will still be available for reading final results until it's
|
|
673
|
-
automatically cleaned up after 5 minutes.
|
|
674
|
-
|
|
665
|
+
description: `
|
|
666
|
+
Stop an active search.
|
|
667
|
+
|
|
668
|
+
Stops the background search process gracefully. Use this when you've found
|
|
669
|
+
what you need or if a search is taking too long. Similar to force_terminate
|
|
670
|
+
for terminal processes.
|
|
671
|
+
|
|
672
|
+
The search will still be available for reading final results until it's
|
|
673
|
+
automatically cleaned up after 5 minutes.
|
|
674
|
+
|
|
675
675
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
676
676
|
inputSchema: zodToJsonSchema(StopSearchArgsSchema),
|
|
677
677
|
annotations: {
|
|
@@ -682,13 +682,13 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
682
682
|
},
|
|
683
683
|
{
|
|
684
684
|
name: "list_searches",
|
|
685
|
-
description: `
|
|
686
|
-
List all active searches.
|
|
687
|
-
|
|
688
|
-
Shows search IDs, search types, patterns, status, and runtime.
|
|
689
|
-
Similar to list_sessions for terminal processes. Useful for managing
|
|
690
|
-
multiple concurrent searches.
|
|
691
|
-
|
|
685
|
+
description: `
|
|
686
|
+
List all active searches.
|
|
687
|
+
|
|
688
|
+
Shows search IDs, search types, patterns, status, and runtime.
|
|
689
|
+
Similar to list_sessions for terminal processes. Useful for managing
|
|
690
|
+
multiple concurrent searches.
|
|
691
|
+
|
|
692
692
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
693
693
|
inputSchema: zodToJsonSchema(ListSearchesArgsSchema),
|
|
694
694
|
annotations: {
|
|
@@ -698,21 +698,21 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
698
698
|
},
|
|
699
699
|
{
|
|
700
700
|
name: "get_file_info",
|
|
701
|
-
description: `
|
|
702
|
-
Retrieve detailed metadata about a file or directory including:
|
|
703
|
-
- size
|
|
704
|
-
- creation time
|
|
705
|
-
- last modified time
|
|
706
|
-
- permissions
|
|
707
|
-
- type
|
|
708
|
-
- lineCount (for text files)
|
|
709
|
-
- lastLine (zero-indexed number of last line, for text files)
|
|
710
|
-
- appendPosition (line number for appending, for text files)
|
|
711
|
-
- sheets (for Excel files - array of {name, rowCount, colCount})
|
|
712
|
-
|
|
713
|
-
Only works within allowed directories.
|
|
714
|
-
|
|
715
|
-
${PATH_GUIDANCE}
|
|
701
|
+
description: `
|
|
702
|
+
Retrieve detailed metadata about a file or directory including:
|
|
703
|
+
- size
|
|
704
|
+
- creation time
|
|
705
|
+
- last modified time
|
|
706
|
+
- permissions
|
|
707
|
+
- type
|
|
708
|
+
- lineCount (for text files)
|
|
709
|
+
- lastLine (zero-indexed number of last line, for text files)
|
|
710
|
+
- appendPosition (line number for appending, for text files)
|
|
711
|
+
- sheets (for Excel files - array of {name, rowCount, colCount})
|
|
712
|
+
|
|
713
|
+
Only works within allowed directories.
|
|
714
|
+
|
|
715
|
+
${PATH_GUIDANCE}
|
|
716
716
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
717
717
|
inputSchema: zodToJsonSchema(GetFileInfoArgsSchema),
|
|
718
718
|
annotations: {
|
|
@@ -724,58 +724,58 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
724
724
|
// Editing tools
|
|
725
725
|
{
|
|
726
726
|
name: "edit_block",
|
|
727
|
-
description: `
|
|
728
|
-
Apply surgical edits to files.
|
|
729
|
-
|
|
730
|
-
BEST PRACTICE: Make multiple small, focused edits rather than one large edit.
|
|
731
|
-
Each edit_block call should change only what needs to be changed - include just enough
|
|
732
|
-
context to uniquely identify the text being modified.
|
|
733
|
-
|
|
734
|
-
FORMAT HANDLING (by extension):
|
|
735
|
-
|
|
736
|
-
EXCEL FILES (.xlsx, .xls, .xlsm) - Range Update mode:
|
|
737
|
-
Takes:
|
|
738
|
-
- file_path: Path to the Excel file
|
|
739
|
-
- range: ALWAYS use FROM:TO format - "SheetName!A1:C10" or "SheetName!C1:C1"
|
|
740
|
-
- content: 2D array, e.g., [["H1","H2"],["R1","R2"]]
|
|
741
|
-
|
|
742
|
-
TEXT FILES - Find/Replace mode:
|
|
743
|
-
Takes:
|
|
744
|
-
- file_path: Path to the file to edit
|
|
745
|
-
- old_string: Text to replace
|
|
746
|
-
- new_string: Replacement text
|
|
747
|
-
- expected_replacements: Optional number of replacements (default: 1)
|
|
748
|
-
|
|
749
|
-
DOCX FILES (.docx) - XML Find/Replace mode:
|
|
750
|
-
Takes same parameters as text files (old_string, new_string, expected_replacements).
|
|
751
|
-
Operates on the pretty-printed XML inside the DOCX — the same XML you see from
|
|
752
|
-
read_file with offset/length. Copy XML fragments from read output as old_string.
|
|
753
|
-
After editing, the XML is repacked into a valid DOCX.
|
|
754
|
-
Also searches headers/footers if not found in document body.
|
|
755
|
-
Examples:
|
|
756
|
-
- Replace text: old_string="<w:t>Old Text</w:t>" new_string="<w:t>New Text</w:t>"
|
|
757
|
-
- Change style: old_string='<w:pStyle w:val="Normal"/>' new_string='<w:pStyle w:val="Heading1"/>'
|
|
758
|
-
- Add content: include surrounding XML context in old_string, add new elements in new_string
|
|
759
|
-
|
|
760
|
-
By default, replaces only ONE occurrence of the search text.
|
|
761
|
-
To replace multiple occurrences, provide expected_replacements with
|
|
762
|
-
the exact number of matches expected.
|
|
763
|
-
|
|
764
|
-
UNIQUENESS REQUIREMENT: When expected_replacements=1 (default), include the minimal
|
|
765
|
-
amount of context necessary (typically 1-3 lines) before and after the change point,
|
|
766
|
-
with exact whitespace and indentation.
|
|
767
|
-
|
|
768
|
-
When editing multiple sections, make separate edit_block calls for each distinct change
|
|
769
|
-
rather than one large replacement.
|
|
770
|
-
|
|
771
|
-
When a close but non-exact match is found, a character-level diff is shown in the format:
|
|
772
|
-
common_prefix{-removed-}{+added+}common_suffix to help you identify what's different.
|
|
773
|
-
|
|
774
|
-
Similar to write_file, there is a configurable line limit (fileWriteLineLimit) that warns
|
|
775
|
-
if the edited file exceeds this limit. If this happens, consider breaking your edits into
|
|
776
|
-
smaller, more focused changes.
|
|
777
|
-
|
|
778
|
-
${PATH_GUIDANCE}
|
|
727
|
+
description: `
|
|
728
|
+
Apply surgical edits to files.
|
|
729
|
+
|
|
730
|
+
BEST PRACTICE: Make multiple small, focused edits rather than one large edit.
|
|
731
|
+
Each edit_block call should change only what needs to be changed - include just enough
|
|
732
|
+
context to uniquely identify the text being modified.
|
|
733
|
+
|
|
734
|
+
FORMAT HANDLING (by extension):
|
|
735
|
+
|
|
736
|
+
EXCEL FILES (.xlsx, .xls, .xlsm) - Range Update mode:
|
|
737
|
+
Takes:
|
|
738
|
+
- file_path: Path to the Excel file
|
|
739
|
+
- range: ALWAYS use FROM:TO format - "SheetName!A1:C10" or "SheetName!C1:C1"
|
|
740
|
+
- content: 2D array, e.g., [["H1","H2"],["R1","R2"]]
|
|
741
|
+
|
|
742
|
+
TEXT FILES - Find/Replace mode:
|
|
743
|
+
Takes:
|
|
744
|
+
- file_path: Path to the file to edit
|
|
745
|
+
- old_string: Text to replace
|
|
746
|
+
- new_string: Replacement text
|
|
747
|
+
- expected_replacements: Optional number of replacements (default: 1)
|
|
748
|
+
|
|
749
|
+
DOCX FILES (.docx) - XML Find/Replace mode:
|
|
750
|
+
Takes same parameters as text files (old_string, new_string, expected_replacements).
|
|
751
|
+
Operates on the pretty-printed XML inside the DOCX — the same XML you see from
|
|
752
|
+
read_file with offset/length. Copy XML fragments from read output as old_string.
|
|
753
|
+
After editing, the XML is repacked into a valid DOCX.
|
|
754
|
+
Also searches headers/footers if not found in document body.
|
|
755
|
+
Examples:
|
|
756
|
+
- Replace text: old_string="<w:t>Old Text</w:t>" new_string="<w:t>New Text</w:t>"
|
|
757
|
+
- Change style: old_string='<w:pStyle w:val="Normal"/>' new_string='<w:pStyle w:val="Heading1"/>'
|
|
758
|
+
- Add content: include surrounding XML context in old_string, add new elements in new_string
|
|
759
|
+
|
|
760
|
+
By default, replaces only ONE occurrence of the search text.
|
|
761
|
+
To replace multiple occurrences, provide expected_replacements with
|
|
762
|
+
the exact number of matches expected.
|
|
763
|
+
|
|
764
|
+
UNIQUENESS REQUIREMENT: When expected_replacements=1 (default), include the minimal
|
|
765
|
+
amount of context necessary (typically 1-3 lines) before and after the change point,
|
|
766
|
+
with exact whitespace and indentation.
|
|
767
|
+
|
|
768
|
+
When editing multiple sections, make separate edit_block calls for each distinct change
|
|
769
|
+
rather than one large replacement.
|
|
770
|
+
|
|
771
|
+
When a close but non-exact match is found, a character-level diff is shown in the format:
|
|
772
|
+
common_prefix{-removed-}{+added+}common_suffix to help you identify what's different.
|
|
773
|
+
|
|
774
|
+
Similar to write_file, there is a configurable line limit (fileWriteLineLimit) that warns
|
|
775
|
+
if the edited file exceeds this limit. If this happens, consider breaking your edits into
|
|
776
|
+
smaller, more focused changes.
|
|
777
|
+
|
|
778
|
+
${PATH_GUIDANCE}
|
|
779
779
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
780
780
|
inputSchema: zodToJsonSchema(EditBlockArgsSchema),
|
|
781
781
|
_meta: buildUiToolMeta(FILE_PREVIEW_RESOURCE_URI, true, showMcpUiPreviews),
|
|
@@ -789,44 +789,44 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
789
789
|
// Terminal tools
|
|
790
790
|
{
|
|
791
791
|
name: "start_process",
|
|
792
|
-
description: `
|
|
793
|
-
Start a terminal process on the authorized device with intelligent state detection.
|
|
794
|
-
|
|
795
|
-
Suitable for shell commands, interactive REPL sessions, data-processing scripts,
|
|
796
|
-
programmatic file analysis, and other long-running terminal work.
|
|
797
|
-
|
|
798
|
-
${OS_GUIDANCE}
|
|
799
|
-
|
|
800
|
-
Examples:
|
|
801
|
-
• start_process("python3 -i") → Start an interactive Python REPL
|
|
802
|
-
• start_process("node -i") → Start an interactive Node.js REPL
|
|
803
|
-
• start_process("node:local") → Run stateless Node.js code on the MCP server
|
|
804
|
-
• start_process("wc -l /path/file.csv") → Run a one-shot shell command
|
|
805
|
-
|
|
806
|
-
Interactive process sessions support follow-up input after they are started.
|
|
807
|
-
Long-running process sessions expose newly available output while they remain active.
|
|
808
|
-
Binary files can be processed with appropriate command-line tools or libraries available
|
|
809
|
-
in the selected process environment.
|
|
810
|
-
|
|
811
|
-
SMART DETECTION:
|
|
812
|
-
- Detects REPL prompts (>>>, >, $, etc.)
|
|
813
|
-
- Identifies when a process is waiting for input
|
|
814
|
-
- Recognizes process completion vs timeout
|
|
815
|
-
- Early exit prevents unnecessary waiting
|
|
816
|
-
|
|
817
|
-
STATES DETECTED:
|
|
818
|
-
Process waiting for input (shows prompt)
|
|
819
|
-
Process finished execution
|
|
820
|
-
Process running (use read_process_output)
|
|
821
|
-
|
|
822
|
-
PERFORMANCE DEBUGGING (verbose_timing parameter):
|
|
823
|
-
Set verbose_timing: true to get detailed timing information including:
|
|
824
|
-
- Exit reason (early_exit_quick_pattern, early_exit_periodic_check, process_exit, timeout)
|
|
825
|
-
- Total duration and time to first output
|
|
826
|
-
- Complete timeline of all output events with timestamps
|
|
827
|
-
- Which detection mechanism triggered early exit
|
|
828
|
-
|
|
829
|
-
${PATH_GUIDANCE}
|
|
792
|
+
description: `
|
|
793
|
+
Start a terminal process on the authorized device with intelligent state detection.
|
|
794
|
+
|
|
795
|
+
Suitable for shell commands, interactive REPL sessions, data-processing scripts,
|
|
796
|
+
programmatic file analysis, and other long-running terminal work.
|
|
797
|
+
|
|
798
|
+
${OS_GUIDANCE}
|
|
799
|
+
|
|
800
|
+
Examples:
|
|
801
|
+
• start_process("python3 -i") → Start an interactive Python REPL
|
|
802
|
+
• start_process("node -i") → Start an interactive Node.js REPL
|
|
803
|
+
• start_process("node:local") → Run stateless Node.js code on the MCP server
|
|
804
|
+
• start_process("wc -l /path/file.csv") → Run a one-shot shell command
|
|
805
|
+
|
|
806
|
+
Interactive process sessions support follow-up input after they are started.
|
|
807
|
+
Long-running process sessions expose newly available output while they remain active.
|
|
808
|
+
Binary files can be processed with appropriate command-line tools or libraries available
|
|
809
|
+
in the selected process environment.
|
|
810
|
+
|
|
811
|
+
SMART DETECTION:
|
|
812
|
+
- Detects REPL prompts (>>>, >, $, etc.)
|
|
813
|
+
- Identifies when a process is waiting for input
|
|
814
|
+
- Recognizes process completion vs timeout
|
|
815
|
+
- Early exit prevents unnecessary waiting
|
|
816
|
+
|
|
817
|
+
STATES DETECTED:
|
|
818
|
+
Process waiting for input (shows prompt)
|
|
819
|
+
Process finished execution
|
|
820
|
+
Process running (use read_process_output)
|
|
821
|
+
|
|
822
|
+
PERFORMANCE DEBUGGING (verbose_timing parameter):
|
|
823
|
+
Set verbose_timing: true to get detailed timing information including:
|
|
824
|
+
- Exit reason (early_exit_quick_pattern, early_exit_periodic_check, process_exit, timeout)
|
|
825
|
+
- Total duration and time to first output
|
|
826
|
+
- Complete timeline of all output events with timestamps
|
|
827
|
+
- Which detection mechanism triggered early exit
|
|
828
|
+
|
|
829
|
+
${PATH_GUIDANCE}
|
|
830
830
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
831
831
|
inputSchema: zodToJsonSchema(StartProcessArgsSchema),
|
|
832
832
|
annotations: {
|
|
@@ -838,38 +838,38 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
838
838
|
},
|
|
839
839
|
{
|
|
840
840
|
name: "read_process_output",
|
|
841
|
-
description: `
|
|
842
|
-
Read output from a running process with file-like pagination support.
|
|
843
|
-
|
|
844
|
-
Supports partial output reading with offset and length parameters (like read_file):
|
|
845
|
-
- 'offset' (start line, default: 0)
|
|
846
|
-
* offset=0: Read NEW output since last read (default, like old behavior)
|
|
847
|
-
* Positive: Read from absolute line position
|
|
848
|
-
* Negative: Read last N lines from end (tail behavior)
|
|
849
|
-
- 'length' (max lines to read, default: configurable via 'fileReadLineLimit' setting)
|
|
850
|
-
|
|
851
|
-
Examples:
|
|
852
|
-
- offset: 0, length: 100 → First 100 NEW lines since last read
|
|
853
|
-
- offset: 0 → All new lines (respects config limit)
|
|
854
|
-
- offset: 500, length: 50 → Lines 500-549 (absolute position)
|
|
855
|
-
- offset: -20 → Last 20 lines (tail)
|
|
856
|
-
- offset: -50, length: 10 → Start 50 from end, read 10 lines
|
|
857
|
-
|
|
858
|
-
OUTPUT PROTECTION:
|
|
859
|
-
- Uses same fileReadLineLimit as read_file (default: 1000 lines)
|
|
860
|
-
- Returns status like: [Reading 100 lines from line 0 (total: 5000 lines, 4900 remaining)]
|
|
861
|
-
- Prevents context overflow from verbose processes
|
|
862
|
-
|
|
863
|
-
SMART FEATURES:
|
|
864
|
-
- For offset=0, waits up to timeout_ms for new output to arrive
|
|
865
|
-
- Detects REPL prompts and process completion
|
|
866
|
-
- Shows process state (waiting for input, finished, etc.)
|
|
867
|
-
|
|
868
|
-
DETECTION STATES:
|
|
869
|
-
Process waiting for input (ready for interact_with_process)
|
|
870
|
-
Process finished execution
|
|
871
|
-
Timeout reached (may still be running)
|
|
872
|
-
|
|
841
|
+
description: `
|
|
842
|
+
Read output from a running process with file-like pagination support.
|
|
843
|
+
|
|
844
|
+
Supports partial output reading with offset and length parameters (like read_file):
|
|
845
|
+
- 'offset' (start line, default: 0)
|
|
846
|
+
* offset=0: Read NEW output since last read (default, like old behavior)
|
|
847
|
+
* Positive: Read from absolute line position
|
|
848
|
+
* Negative: Read last N lines from end (tail behavior)
|
|
849
|
+
- 'length' (max lines to read, default: configurable via 'fileReadLineLimit' setting)
|
|
850
|
+
|
|
851
|
+
Examples:
|
|
852
|
+
- offset: 0, length: 100 → First 100 NEW lines since last read
|
|
853
|
+
- offset: 0 → All new lines (respects config limit)
|
|
854
|
+
- offset: 500, length: 50 → Lines 500-549 (absolute position)
|
|
855
|
+
- offset: -20 → Last 20 lines (tail)
|
|
856
|
+
- offset: -50, length: 10 → Start 50 from end, read 10 lines
|
|
857
|
+
|
|
858
|
+
OUTPUT PROTECTION:
|
|
859
|
+
- Uses same fileReadLineLimit as read_file (default: 1000 lines)
|
|
860
|
+
- Returns status like: [Reading 100 lines from line 0 (total: 5000 lines, 4900 remaining)]
|
|
861
|
+
- Prevents context overflow from verbose processes
|
|
862
|
+
|
|
863
|
+
SMART FEATURES:
|
|
864
|
+
- For offset=0, waits up to timeout_ms for new output to arrive
|
|
865
|
+
- Detects REPL prompts and process completion
|
|
866
|
+
- Shows process state (waiting for input, finished, etc.)
|
|
867
|
+
|
|
868
|
+
DETECTION STATES:
|
|
869
|
+
Process waiting for input (ready for interact_with_process)
|
|
870
|
+
Process finished execution
|
|
871
|
+
Timeout reached (may still be running)
|
|
872
|
+
|
|
873
873
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
874
874
|
inputSchema: zodToJsonSchema(ReadProcessOutputArgsSchema),
|
|
875
875
|
annotations: {
|
|
@@ -879,38 +879,38 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
879
879
|
},
|
|
880
880
|
{
|
|
881
881
|
name: "interact_with_process",
|
|
882
|
-
description: `
|
|
883
|
-
Send input to an existing terminal or REPL process and return newly available output.
|
|
884
|
-
|
|
885
|
-
Useful for interactive shells, Python/Node/R/Julia REPLs, database consoles,
|
|
886
|
-
and long-running commands started with start_process().
|
|
887
|
-
|
|
888
|
-
Examples:
|
|
889
|
-
- Interactive Python REPL sessions can be started with \`python3 -i\`.
|
|
890
|
-
- Existing interactive sessions accept additional input such as imports or analysis commands.
|
|
891
|
-
- Interactive sessions can return newly available output while they remain active.
|
|
892
|
-
|
|
893
|
-
SMART DETECTION:
|
|
894
|
-
- Automatically waits for a recognized prompt when requested
|
|
895
|
-
- Detects errors and completion states
|
|
896
|
-
- Early exit prevents unnecessary waiting
|
|
897
|
-
- Cleans common REPL prompt text from returned output
|
|
898
|
-
|
|
899
|
-
PARAMETERS:
|
|
900
|
-
- pid: Process ID returned by start_process
|
|
901
|
-
- input: Text or command to send to the process
|
|
902
|
-
- timeout_ms: Maximum wait time (default: 8000ms)
|
|
903
|
-
- wait_for_prompt: Whether to wait for a prompt before returning (default: true)
|
|
904
|
-
- verbose_timing: Include detailed timing telemetry (default: false)
|
|
905
|
-
|
|
906
|
-
Returns execution result with status indicators.
|
|
907
|
-
|
|
908
|
-
PERFORMANCE DEBUGGING (verbose_timing parameter):
|
|
909
|
-
When enabled, detailed timing includes:
|
|
910
|
-
- Exit reason
|
|
911
|
-
- Total duration and time to first output
|
|
912
|
-
- Timeline of output events
|
|
913
|
-
|
|
882
|
+
description: `
|
|
883
|
+
Send input to an existing terminal or REPL process and return newly available output.
|
|
884
|
+
|
|
885
|
+
Useful for interactive shells, Python/Node/R/Julia REPLs, database consoles,
|
|
886
|
+
and long-running commands started with start_process().
|
|
887
|
+
|
|
888
|
+
Examples:
|
|
889
|
+
- Interactive Python REPL sessions can be started with \`python3 -i\`.
|
|
890
|
+
- Existing interactive sessions accept additional input such as imports or analysis commands.
|
|
891
|
+
- Interactive sessions can return newly available output while they remain active.
|
|
892
|
+
|
|
893
|
+
SMART DETECTION:
|
|
894
|
+
- Automatically waits for a recognized prompt when requested
|
|
895
|
+
- Detects errors and completion states
|
|
896
|
+
- Early exit prevents unnecessary waiting
|
|
897
|
+
- Cleans common REPL prompt text from returned output
|
|
898
|
+
|
|
899
|
+
PARAMETERS:
|
|
900
|
+
- pid: Process ID returned by start_process
|
|
901
|
+
- input: Text or command to send to the process
|
|
902
|
+
- timeout_ms: Maximum wait time (default: 8000ms)
|
|
903
|
+
- wait_for_prompt: Whether to wait for a prompt before returning (default: true)
|
|
904
|
+
- verbose_timing: Include detailed timing telemetry (default: false)
|
|
905
|
+
|
|
906
|
+
Returns execution result with status indicators.
|
|
907
|
+
|
|
908
|
+
PERFORMANCE DEBUGGING (verbose_timing parameter):
|
|
909
|
+
When enabled, detailed timing includes:
|
|
910
|
+
- Exit reason
|
|
911
|
+
- Total duration and time to first output
|
|
912
|
+
- Timeline of output events
|
|
913
|
+
|
|
914
914
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
915
915
|
inputSchema: zodToJsonSchema(InteractWithProcessArgsSchema),
|
|
916
916
|
annotations: {
|
|
@@ -922,9 +922,9 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
922
922
|
},
|
|
923
923
|
{
|
|
924
924
|
name: "force_terminate",
|
|
925
|
-
description: `
|
|
926
|
-
Force terminate a running terminal session.
|
|
927
|
-
|
|
925
|
+
description: `
|
|
926
|
+
Force terminate a running terminal session.
|
|
927
|
+
|
|
928
928
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
929
929
|
inputSchema: zodToJsonSchema(ForceTerminateArgsSchema),
|
|
930
930
|
annotations: {
|
|
@@ -936,19 +936,19 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
936
936
|
},
|
|
937
937
|
{
|
|
938
938
|
name: "list_sessions",
|
|
939
|
-
description: `
|
|
940
|
-
List all active terminal sessions.
|
|
941
|
-
|
|
942
|
-
Shows session status including:
|
|
943
|
-
- PID: Process identifier
|
|
944
|
-
- Blocked: Whether session is waiting for input
|
|
945
|
-
- Runtime: How long the session has been running
|
|
946
|
-
|
|
947
|
-
DEBUGGING REPLs:
|
|
948
|
-
- "Blocked: true" often means REPL is waiting for input
|
|
949
|
-
- Use this to verify sessions are running before sending input
|
|
950
|
-
- Long runtime with blocked status may indicate stuck process
|
|
951
|
-
|
|
939
|
+
description: `
|
|
940
|
+
List all active terminal sessions.
|
|
941
|
+
|
|
942
|
+
Shows session status including:
|
|
943
|
+
- PID: Process identifier
|
|
944
|
+
- Blocked: Whether session is waiting for input
|
|
945
|
+
- Runtime: How long the session has been running
|
|
946
|
+
|
|
947
|
+
DEBUGGING REPLs:
|
|
948
|
+
- "Blocked: true" often means REPL is waiting for input
|
|
949
|
+
- Use this to verify sessions are running before sending input
|
|
950
|
+
- Long runtime with blocked status may indicate stuck process
|
|
951
|
+
|
|
952
952
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
953
953
|
inputSchema: zodToJsonSchema(ListSessionsArgsSchema),
|
|
954
954
|
annotations: {
|
|
@@ -958,11 +958,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
958
958
|
},
|
|
959
959
|
{
|
|
960
960
|
name: "list_processes",
|
|
961
|
-
description: `
|
|
962
|
-
List all running processes.
|
|
963
|
-
|
|
964
|
-
Returns process information including PID, command name, CPU usage, and memory usage.
|
|
965
|
-
|
|
961
|
+
description: `
|
|
962
|
+
List all running processes.
|
|
963
|
+
|
|
964
|
+
Returns process information including PID, command name, CPU usage, and memory usage.
|
|
965
|
+
|
|
966
966
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
967
967
|
inputSchema: zodToJsonSchema(ListProcessesArgsSchema),
|
|
968
968
|
annotations: {
|
|
@@ -972,11 +972,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
972
972
|
},
|
|
973
973
|
{
|
|
974
974
|
name: "kill_process",
|
|
975
|
-
description: `
|
|
976
|
-
Terminate a running process by PID.
|
|
977
|
-
|
|
978
|
-
Use with caution as this will forcefully terminate the specified process.
|
|
979
|
-
|
|
975
|
+
description: `
|
|
976
|
+
Terminate a running process by PID.
|
|
977
|
+
|
|
978
|
+
Use with caution as this will forcefully terminate the specified process.
|
|
979
|
+
|
|
980
980
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
981
981
|
inputSchema: zodToJsonSchema(KillProcessArgsSchema),
|
|
982
982
|
annotations: {
|
|
@@ -988,11 +988,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
988
988
|
},
|
|
989
989
|
{
|
|
990
990
|
name: "get_usage_stats",
|
|
991
|
-
description: `
|
|
992
|
-
Get usage statistics for debugging and analysis.
|
|
993
|
-
|
|
994
|
-
Returns summary of tool usage, success/failure rates, and performance metrics.
|
|
995
|
-
|
|
991
|
+
description: `
|
|
992
|
+
Get usage statistics for debugging and analysis.
|
|
993
|
+
|
|
994
|
+
Returns summary of tool usage, success/failure rates, and performance metrics.
|
|
995
|
+
|
|
996
996
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
997
997
|
inputSchema: zodToJsonSchema(GetUsageStatsArgsSchema),
|
|
998
998
|
annotations: {
|
|
@@ -1002,20 +1002,20 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
1002
1002
|
},
|
|
1003
1003
|
{
|
|
1004
1004
|
name: "get_recent_tool_calls",
|
|
1005
|
-
description: `
|
|
1006
|
-
Get recent local tool call history with arguments and outputs.
|
|
1007
|
-
Returns a chronological list of recent calls loaded from the local history file.
|
|
1008
|
-
|
|
1009
|
-
Useful for:
|
|
1010
|
-
- Onboarding new chats about work already done
|
|
1011
|
-
- Recovering context after chat history loss
|
|
1012
|
-
- Debugging tool call sequences
|
|
1013
|
-
|
|
1014
|
-
Note: Does not track its own calls or track_ui_event.
|
|
1015
|
-
History is persisted locally in tool-history.jsonl, keeps up to the last 1000
|
|
1016
|
-
calls in memory, and trims older on-disk history. Stored outputs over 4 KiB
|
|
1017
|
-
are replaced with an omission marker.
|
|
1018
|
-
|
|
1005
|
+
description: `
|
|
1006
|
+
Get recent local tool call history with arguments and outputs.
|
|
1007
|
+
Returns a chronological list of recent calls loaded from the local history file.
|
|
1008
|
+
|
|
1009
|
+
Useful for:
|
|
1010
|
+
- Onboarding new chats about work already done
|
|
1011
|
+
- Recovering context after chat history loss
|
|
1012
|
+
- Debugging tool call sequences
|
|
1013
|
+
|
|
1014
|
+
Note: Does not track its own calls or track_ui_event.
|
|
1015
|
+
History is persisted locally in tool-history.jsonl, keeps up to the last 1000
|
|
1016
|
+
calls in memory, and trims older on-disk history. Stored outputs over 4 KiB
|
|
1017
|
+
are replaced with an omission marker.
|
|
1018
|
+
|
|
1019
1019
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
1020
1020
|
inputSchema: zodToJsonSchema(GetRecentToolCallsArgsSchema),
|
|
1021
1021
|
annotations: {
|
|
@@ -1025,38 +1025,38 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
1025
1025
|
},
|
|
1026
1026
|
{
|
|
1027
1027
|
name: "give_feedback_to_desktop_commander",
|
|
1028
|
-
description: `
|
|
1029
|
-
Open feedback form in browser to provide feedback about Desktop Commander.
|
|
1030
|
-
|
|
1031
|
-
IMPORTANT: This tool simply opens the feedback form - no pre-filling available.
|
|
1032
|
-
The user will fill out the form manually in their browser.
|
|
1033
|
-
|
|
1034
|
-
WORKFLOW:
|
|
1035
|
-
1. When user agrees to give feedback, just call this tool immediately
|
|
1036
|
-
2. No need to ask questions or collect information
|
|
1037
|
-
3. Tool opens form with only usage statistics pre-filled automatically:
|
|
1038
|
-
- tool_call_count: Number of commands they've made
|
|
1039
|
-
- days_using: How many days they've used Desktop Commander
|
|
1040
|
-
- platform: Their operating system (Mac/Windows/Linux)
|
|
1041
|
-
- client_id: Analytics identifier
|
|
1042
|
-
|
|
1043
|
-
All survey questions will be answered directly in the form:
|
|
1044
|
-
- Job title and technical comfort level
|
|
1045
|
-
- Company URL for industry context
|
|
1046
|
-
- Other AI tools they use
|
|
1047
|
-
- Desktop Commander's biggest advantage
|
|
1048
|
-
- How they typically use it
|
|
1049
|
-
- Recommendation likelihood (0-10)
|
|
1050
|
-
- User study participation interest
|
|
1051
|
-
- Email and any additional feedback
|
|
1052
|
-
|
|
1053
|
-
EXAMPLE INTERACTION:
|
|
1054
|
-
User: "sure, I'll give feedback"
|
|
1055
|
-
Claude: "Perfect! Let me open the feedback form for you."
|
|
1056
|
-
[calls tool immediately]
|
|
1057
|
-
|
|
1058
|
-
No parameters are needed - just call the tool to open the form.
|
|
1059
|
-
|
|
1028
|
+
description: `
|
|
1029
|
+
Open feedback form in browser to provide feedback about Desktop Commander.
|
|
1030
|
+
|
|
1031
|
+
IMPORTANT: This tool simply opens the feedback form - no pre-filling available.
|
|
1032
|
+
The user will fill out the form manually in their browser.
|
|
1033
|
+
|
|
1034
|
+
WORKFLOW:
|
|
1035
|
+
1. When user agrees to give feedback, just call this tool immediately
|
|
1036
|
+
2. No need to ask questions or collect information
|
|
1037
|
+
3. Tool opens form with only usage statistics pre-filled automatically:
|
|
1038
|
+
- tool_call_count: Number of commands they've made
|
|
1039
|
+
- days_using: How many days they've used Desktop Commander
|
|
1040
|
+
- platform: Their operating system (Mac/Windows/Linux)
|
|
1041
|
+
- client_id: Analytics identifier
|
|
1042
|
+
|
|
1043
|
+
All survey questions will be answered directly in the form:
|
|
1044
|
+
- Job title and technical comfort level
|
|
1045
|
+
- Company URL for industry context
|
|
1046
|
+
- Other AI tools they use
|
|
1047
|
+
- Desktop Commander's biggest advantage
|
|
1048
|
+
- How they typically use it
|
|
1049
|
+
- Recommendation likelihood (0-10)
|
|
1050
|
+
- User study participation interest
|
|
1051
|
+
- Email and any additional feedback
|
|
1052
|
+
|
|
1053
|
+
EXAMPLE INTERACTION:
|
|
1054
|
+
User: "sure, I'll give feedback"
|
|
1055
|
+
Claude: "Perfect! Let me open the feedback form for you."
|
|
1056
|
+
[calls tool immediately]
|
|
1057
|
+
|
|
1058
|
+
No parameters are needed - just call the tool to open the form.
|
|
1059
|
+
|
|
1060
1060
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
1061
1061
|
inputSchema: zodToJsonSchema(GiveFeedbackArgsSchema),
|
|
1062
1062
|
annotations: {
|
|
@@ -1067,28 +1067,28 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
1067
1067
|
},
|
|
1068
1068
|
{
|
|
1069
1069
|
name: "get_prompts",
|
|
1070
|
-
description: `
|
|
1071
|
-
Retrieve a specific Desktop Commander onboarding prompt by ID and execute it.
|
|
1072
|
-
|
|
1073
|
-
SIMPLIFIED ONBOARDING V2: This tool only supports direct prompt retrieval.
|
|
1074
|
-
The onboarding system presents 5 options as a simple numbered list:
|
|
1075
|
-
|
|
1076
|
-
1. Organize my Downloads folder (promptId: 'onb2_01')
|
|
1077
|
-
2. Explain a codebase or repository (promptId: 'onb2_02')
|
|
1078
|
-
3. Create organized knowledge base (promptId: 'onb2_03')
|
|
1079
|
-
4. Analyze a data file (promptId: 'onb2_04')
|
|
1080
|
-
5. Check system health and resources (promptId: 'onb2_05')
|
|
1081
|
-
|
|
1082
|
-
USAGE:
|
|
1083
|
-
When user says "1", "2", "3", "4", or "5" from onboarding:
|
|
1084
|
-
- "1" → get_prompts(action='get_prompt', promptId='onb2_01')
|
|
1085
|
-
- "2" → get_prompts(action='get_prompt', promptId='onb2_02')
|
|
1086
|
-
- "3" → get_prompts(action='get_prompt', promptId='onb2_03')
|
|
1087
|
-
- "4" → get_prompts(action='get_prompt', promptId='onb2_04')
|
|
1088
|
-
- "5" → get_prompts(action='get_prompt', promptId='onb2_05')
|
|
1089
|
-
|
|
1090
|
-
The prompt content will be injected and execution begins immediately.
|
|
1091
|
-
|
|
1070
|
+
description: `
|
|
1071
|
+
Retrieve a specific Desktop Commander onboarding prompt by ID and execute it.
|
|
1072
|
+
|
|
1073
|
+
SIMPLIFIED ONBOARDING V2: This tool only supports direct prompt retrieval.
|
|
1074
|
+
The onboarding system presents 5 options as a simple numbered list:
|
|
1075
|
+
|
|
1076
|
+
1. Organize my Downloads folder (promptId: 'onb2_01')
|
|
1077
|
+
2. Explain a codebase or repository (promptId: 'onb2_02')
|
|
1078
|
+
3. Create organized knowledge base (promptId: 'onb2_03')
|
|
1079
|
+
4. Analyze a data file (promptId: 'onb2_04')
|
|
1080
|
+
5. Check system health and resources (promptId: 'onb2_05')
|
|
1081
|
+
|
|
1082
|
+
USAGE:
|
|
1083
|
+
When user says "1", "2", "3", "4", or "5" from onboarding:
|
|
1084
|
+
- "1" → get_prompts(action='get_prompt', promptId='onb2_01')
|
|
1085
|
+
- "2" → get_prompts(action='get_prompt', promptId='onb2_02')
|
|
1086
|
+
- "3" → get_prompts(action='get_prompt', promptId='onb2_03')
|
|
1087
|
+
- "4" → get_prompts(action='get_prompt', promptId='onb2_04')
|
|
1088
|
+
- "5" → get_prompts(action='get_prompt', promptId='onb2_05')
|
|
1089
|
+
|
|
1090
|
+
The prompt content will be injected and execution begins immediately.
|
|
1091
|
+
|
|
1092
1092
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
1093
1093
|
inputSchema: zodToJsonSchema(GetPromptsArgsSchema),
|
|
1094
1094
|
annotations: {
|
|
@@ -1110,6 +1110,19 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
1110
1110
|
}
|
|
1111
1111
|
});
|
|
1112
1112
|
import * as handlers from './handlers/index.js';
|
|
1113
|
+
import { withoutInternalFacts } from './utils/internal-facts.js';
|
|
1114
|
+
import { stillLoadingError } from './utils/files/index.js';
|
|
1115
|
+
/**
|
|
1116
|
+
* A tool call on an Excel, DOCX or PDF file whose package is still loading
|
|
1117
|
+
* after initialize answers at once with this error (utils/files/factory.ts)
|
|
1118
|
+
* instead of loading it inside the call. Not sent to telemetry, unlike other
|
|
1119
|
+
* errors: it names the file. read_multiple_files answers per file;
|
|
1120
|
+
* get_file_info waits for the load, or loads it itself, and so does a search.
|
|
1121
|
+
*/
|
|
1122
|
+
function stillLoading(filePath, action, options) {
|
|
1123
|
+
const error = typeof filePath === 'string' ? stillLoadingError(filePath, action, options) : undefined;
|
|
1124
|
+
return error === undefined ? undefined : { content: [{ type: 'text', text: `Error: ${error}` }], isError: true };
|
|
1125
|
+
}
|
|
1113
1126
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
1114
1127
|
const args = request.params.arguments;
|
|
1115
1128
|
// Calls fired programmatically by the widget UIs (file preview, config
|
|
@@ -1119,11 +1132,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1119
1132
|
// (server_call_tool, server_read_file, server_edit_block, ...). Deliberate
|
|
1120
1133
|
// UI interactions are tracked separately via mcp_ui_event.
|
|
1121
1134
|
const isUiOriginCall = !!(args && typeof args === 'object' && args.origin === 'ui');
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1135
|
+
// Each call keeps the paths it works on, starting with its path arguments,
|
|
1136
|
+
// so telemetry can replace them whole in any error text the call produces
|
|
1137
|
+
return runWithToolCallPaths(() => {
|
|
1138
|
+
addToolCallPaths(...pathArguments(args));
|
|
1139
|
+
if (isUiOriginCall) {
|
|
1140
|
+
return runInUiOriginCallContext(() => handleCallToolRequest(request));
|
|
1141
|
+
}
|
|
1142
|
+
return handleCallToolRequest(request);
|
|
1143
|
+
});
|
|
1126
1144
|
});
|
|
1145
|
+
/** The values of the tool arguments that hold paths (path, paths, file_path, outputPath, source, destination, shell, ...). */
|
|
1146
|
+
function pathArguments(args) {
|
|
1147
|
+
if (!args || typeof args !== 'object')
|
|
1148
|
+
return [];
|
|
1149
|
+
return Object.entries(args)
|
|
1150
|
+
.filter(([key]) => /path/i.test(key) || key === 'source' || key === 'destination' || key === 'shell')
|
|
1151
|
+
.map(([, value]) => value);
|
|
1152
|
+
}
|
|
1127
1153
|
async function handleCallToolRequest(request) {
|
|
1128
1154
|
const { name, arguments: args } = request.params;
|
|
1129
1155
|
const startTime = Date.now();
|
|
@@ -1324,17 +1350,22 @@ async function handleCallToolRequest(request) {
|
|
|
1324
1350
|
// Note: REPL functionality removed in favor of using general terminal commands
|
|
1325
1351
|
// Filesystem tools
|
|
1326
1352
|
case "read_file":
|
|
1327
|
-
result = await handlers.handleReadFile(args);
|
|
1353
|
+
result = stillLoading(args?.path, 'read', { isUrl: args?.isUrl === true }) ?? await handlers.handleReadFile(args);
|
|
1328
1354
|
break;
|
|
1329
1355
|
case "read_multiple_files":
|
|
1330
|
-
result = await handlers.handleReadMultipleFiles(args);
|
|
1356
|
+
result = await handlers.handleReadMultipleFiles(args, (filePath) => stillLoadingError(filePath, 'read'));
|
|
1331
1357
|
break;
|
|
1332
1358
|
case "write_file":
|
|
1333
|
-
result = await handlers.handleWriteFile(args);
|
|
1359
|
+
result = stillLoading(args?.path, 'write') ?? await handlers.handleWriteFile(args);
|
|
1334
1360
|
break;
|
|
1335
|
-
case "write_pdf":
|
|
1336
|
-
|
|
1361
|
+
case "write_pdf": {
|
|
1362
|
+
// Markdown (a new PDF) or page edits, read as the tool reads them;
|
|
1363
|
+
// arguments the tool refuses get its own error
|
|
1364
|
+
const parsed = WritePdfArgsSchema.safeParse(args);
|
|
1365
|
+
const action = parsed.success && typeof parsed.data.content === 'string' ? 'write' : 'edit';
|
|
1366
|
+
result = (parsed.success ? stillLoading(parsed.data.path, action, { isPdf: true }) : undefined) ?? await handlers.handleWritePdf(args);
|
|
1337
1367
|
break;
|
|
1368
|
+
}
|
|
1338
1369
|
case "create_directory":
|
|
1339
1370
|
result = await handlers.handleCreateDirectory(args);
|
|
1340
1371
|
break;
|
|
@@ -1360,7 +1391,7 @@ async function handleCallToolRequest(request) {
|
|
|
1360
1391
|
result = await handlers.handleGetFileInfo(args);
|
|
1361
1392
|
break;
|
|
1362
1393
|
case "edit_block":
|
|
1363
|
-
result = await handlers.handleEditBlock(args);
|
|
1394
|
+
result = stillLoading(args?.file_path, 'edit') ?? await handlers.handleEditBlock(args);
|
|
1364
1395
|
break;
|
|
1365
1396
|
default:
|
|
1366
1397
|
capture('server_unknown_tool', { name });
|
|
@@ -1369,6 +1400,8 @@ async function handleCallToolRequest(request) {
|
|
|
1369
1400
|
isError: true,
|
|
1370
1401
|
};
|
|
1371
1402
|
}
|
|
1403
|
+
// What the client receives (and the history records): facts kept internal are dropped
|
|
1404
|
+
result = withoutInternalFacts(name, result);
|
|
1372
1405
|
// Add tool call to history (exclude only get_recent_tool_calls to prevent recursion)
|
|
1373
1406
|
const duration = Date.now() - startTime;
|
|
1374
1407
|
isError = !!result.isError;
|