CherryHQ/cherry-studio · warning · Error
Invalid arguments for delete: ${parsed.error}
Error message
Invalid arguments for delete: ${parsed.error} What it means
Zod safeParse on the delete tool's arguments failed. DeleteToolSchema requires a string `path` and accepts an optional boolean `recursive`. The throw embeds parsed.error, a ZodError whose message lists each failed field and the expected shape. Wrapped by the server-level catch into an isError tool result.
Source
Thrown at src/main/ai/mcp/servers/filesystem/tools/delete.ts:32
export const deleteToolDefinition = {
name: 'delete',
description: `Deletes a file or directory from the filesystem.
CAUTION: This operation cannot be undone!
- For files: simply provide the path
- For empty directories: provide the path
- For non-empty directories: set recursive=true
- The path must resolve within the configured workspace root
- Always verify the path before deleting to avoid data loss`,
inputSchema: z.toJSONSchema(DeleteToolSchema)
}
// Handler implementation
export async function handleDeleteTool(args: unknown, baseDir: string) {
const parsed = DeleteToolSchema.safeParse(args)
if (!parsed.success) {
throw new Error(`Invalid arguments for delete: ${parsed.error}`)
}
const targetPath = parsed.data.path
const validPath = await validatePath(targetPath, baseDir)
const recursive = parsed.data.recursive || false
// Check if path exists and get stats
let stats
try {
stats = await fs.stat(validPath)
} catch (error: any) {
if (error.code === 'ENOENT') {
throw new Error(`Path not found: ${targetPath}`)
}
throw error
}
const isDirectory = stats.isDirectory()View on GitHub (pinned to 726446b54c)
Solutions
- Ensure the arguments object includes path as a string and, if present, recursive as a boolean.
- Read parsed.error in the returned message — it names the offending field and the constraint that failed.
- Cross-check the arguments against z.toJSONSchema(DeleteToolSchema) published in the ListTools response.
Example fix
// before
const parsed = DeleteToolSchema.safeParse(args)
if (!parsed.success) {
throw new Error(`Invalid arguments for delete: ${parsed.error}`)
}
// after — emit a structured, field-level error for the client
if (!parsed.success) {
const issues = parsed.error.issues.map(i => `${i.path.join('.')}: ${i.message}`).join('; ')
throw new Error(`Invalid arguments for delete: ${issues}`)
} Defensive patterns
Strategy: validation
Validate before calling
// Validate delete args on the client before dispatching.
function isValidDeleteArgs(args: unknown): args is { path: string; recursive?: boolean } {
if (typeof args !== 'object' || args === null) return false
const a = args as any
return typeof a.path === 'string' && (a.recursive === undefined || typeof a.recursive === 'boolean')
} Type guard
function isDeleteArgs(a: unknown): a is { path: string; recursive?: boolean } {
return typeof a === 'object' && a !== null && typeof (a as any).path === 'string'
&& ((a as any).recursive === undefined || typeof (a as any).recursive === 'boolean')
} Prevention
- Always send path as a string; omit recursive unless deleting a non-empty directory.
- Generate client types from z.toJSONSchema(DeleteToolSchema) to avoid shape drift.
- Read parsed.error in the returned message — it names the failing field.
- Run a local safeParse on the client before sending the request.
When it happens
Trigger: The MCP client omitted `path`, sent a non-string path (number/object/null), sent a non-boolean recursive, or sent an unparseable JSON arguments object. Also fires if the model emits an empty arguments object.
Common situations: A model forgetting the required path field; a client serializing path as a number (e.g. a port-like path '8080' coerced to number); schema drift where the client was built against an older DeleteToolSchema.
Related errors
- Invalid arguments for edit: ${parsed.error}
- Invalid arguments for glob: ${parsed.error}
- Invalid arguments for grep: ${parsed.error}
- Invalid arguments for ls: ${parsed.error}
- Invalid arguments for read: ${parsed.error}
AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12).
Data as JSON: /api/errors/050fc43ba8d77c57.
Report an issue: GitHub.