Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

fs_delete_directory

Remove directories and optionally delete all contents recursively to manage file system structure during development.

Instructions

Delete a directory. Can recursively delete all contents. WARNING: Use with caution as this is irreversible.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute or relative path to the directory to delete
recursiveNoDelete directory and all contents recursively

Implementation Reference

  • The core handler function that implements the fs_delete_directory tool logic. It deletes the specified directory using Node.js fs.promises.rm (recursive with force if specified) or fs.rmdir (non-recursive), and returns a standardized ToolResponse.
    export async function deleteDirectory(args: z.infer<typeof deleteDirectorySchema>): Promise<ToolResponse> { try { if (args.recursive) { await fs.rm(args.path, { recursive: true, force: true }); } else { await fs.rmdir(args.path); } return { content: [ { type: "text" as const, text: JSON.stringify({ success: true, path: args.path, message: 'Directory deleted successfully' }, null, 2) } ] }; } catch (error) { return { content: [ { type: "text" as const, text: JSON.stringify({ success: false, error: error instanceof Error ? error.message : String(error) }, null, 2) } ], isError: true }; } }
  • Zod schema used for input validation in the deleteDirectory handler and dispatch.
    export const deleteDirectorySchema = z.object({ path: z.string().describe('Absolute or relative path to the directory to delete'), recursive: z.boolean().default(false).describe('Delete directory and all contents recursively') });
  • JSON schema definition for the fs_delete_directory tool, part of the exported filesystemTools array used for MCP tool registration.
    { name: 'fs_delete_directory', description: 'Delete a directory. Can recursively delete all contents. WARNING: Use with caution as this is irreversible.', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Absolute or relative path to the directory to delete' }, recursive: { type: 'boolean', default: false, description: 'Delete directory and all contents recursively' } }, required: ['path'] } },
  • src/index.ts:329-332 (registration)
    Dispatch/registration logic in the main server handler that matches tool name 'fs_delete_directory', validates input with deleteDirectorySchema, and invokes the deleteDirectory handler.
    if (name === 'fs_delete_directory') { const validated = deleteDirectorySchema.parse(args); return await deleteDirectory(validated); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ConnorBoetig-dev/mcp2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server