file_delete
Delete a single file by absolute path or multiple files using a regular expression. Optionally preview deletions without executing.
Instructions
Delete a file from server
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | No | Delete file with match on absolute path/filename. Use this or 'match'. | |
| match | No | Delete multiple files that match regular expression to a file path. Use this or 'filename'. | |
| dryrun | No | Output files to delete without performing the action |
Implementation Reference
- src/index.ts:88-92 (schema)Zod schema defining the input validation for file_delete. Accepts optional filename, match (regex), and dryrun fields.
const fileDeleteSchema = z.object({ filename: z.string().optional().describe("Delete file with match on absolute path/filename. Use this or 'match'."), match: z.string().optional().describe("Delete multiple files that match regular expression to a file path. Use this or 'filename'."), dryrun: z.boolean().optional().describe("Output files to delete without performing the action") }); - src/index.ts:278-290 (registration)Registration of the 'file_delete' tool in the tools array with its name, description, and input JSON schema.
{ name: "file_delete", description: "Delete a file from server", schema: fileDeleteSchema, inputSchema: { type: "object", properties: { filename: { type: "string", description: "Delete file with match on absolute path/filename. Use this or 'match'." }, match: { type: "string", description: "Delete multiple files that match regular expression to a file path. Use this or 'filename'." }, dryrun: { type: "boolean", description: "Output files to delete without performing the action" } } } }, - src/index.ts:886-913 (handler)Handler implementation for file_delete. Extracts filename, match, and dryrun args, builds a 'file-delete' CLI command, and executes it via the Codehooks (coho) CLI helper.
case "file_delete": { const { filename, match, dryrun } = args as FileDeleteArgs; if (!filename && !match) { throw new McpError(ErrorCode.InvalidRequest, "Either 'filename' or 'match' must be provided."); } const deleteArgs = [ 'file-delete', '--projectname', config.projectId, '--space', config.space ]; if (filename) deleteArgs.push('--filename', filename); if (match) deleteArgs.push('--match', match); if (dryrun) deleteArgs.push('--dryrun'); const result = await executeCohoCommand(deleteArgs); return { content: [ { type: "text", text: result } ], isError: false }; }