delete_instruction
Remove a VS Code instruction file from the prompts directory to manage your development environment's custom commands and workflows.
Instructions
Delete a VS Code .instructions.md file from the prompts directory.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instruction_name | Yes | The name of the instruction to delete (with or without extension) |
Implementation Reference
- The primary MCP tool handler for 'delete_instruction'. It performs read-only checks, delegates to InstructionManager.delete_instruction(), and formats the response message.def delete_instruction( instruction_name: Annotated[str, "The name of the instruction to delete (with or without extension)"], ) -> str: """Delete a VS Code .instructions.md file from the prompts directory.""" if read_only: return "Error: Server is running in read-only mode" try: success = instruction_manager.delete_instruction(instruction_name) if success: return f"Successfully deleted VS Code instruction: {instruction_name}" else: return f"Failed to delete VS Code instruction: {instruction_name}" except Exception as e: return f"Error deleting VS Code instruction '{instruction_name}': {str(e)}"
- The schema definition in the tool annotations, specifying input parameters (instruction_name) and return description.annotations={ "idempotentHint": False, "readOnlyHint": False, "title": "Delete Instruction", "parameters": { "instruction_name": "The name of the instruction to delete. If a full filename is provided, it will be used as-is. Otherwise, .instructions.md will be appended automatically. You can provide just the name (e.g. my-instruction) or the full filename (e.g. my-instruction.instructions.md)." }, "returns": "Returns a success message if the instruction was deleted, or an error message if the operation failed or the file was not found.", },
- src/mode_manager_mcp/tools/instruction_tools.py:152-168 (registration)The @app.tool decorator that registers the delete_instruction tool with the MCP server, including name, description, tags, and metadata.@app.tool( name="delete_instruction", description="Delete a VS Code .instructions.md file from the prompts directory.", tags={"public", "instruction"}, annotations={ "idempotentHint": False, "readOnlyHint": False, "title": "Delete Instruction", "parameters": { "instruction_name": "The name of the instruction to delete. If a full filename is provided, it will be used as-is. Otherwise, .instructions.md will be appended automatically. You can provide just the name (e.g. my-instruction) or the full filename (e.g. my-instruction.instructions.md)." }, "returns": "Returns a success message if the instruction was deleted, or an error message if the operation failed or the file was not found.", }, meta={ "category": "instruction", }, )
- Core helper method in InstructionManager class that implements the file deletion logic: ensures extension, constructs path, checks existence, and calls safe_delete_file with backup.def delete_instruction(self, instruction_name: str) -> bool: """ Delete an instruction file with automatic backup. Args: instruction_name: Name of the .instructions.md file Returns: True if successful Raises: FileOperationError: If file cannot be deleted """ # Ensure filename has correct extension instruction_name = self._ensure_instruction_extension(instruction_name) file_path = self.prompts_dir / instruction_name if not file_path.exists(): raise FileOperationError(f"Instruction file not found: {instruction_name}") try: # Use safe delete which creates backup automatically safe_delete_file(file_path, create_backup=True) logger.info(f"Deleted instruction file with backup: {instruction_name}") return True except Exception as e: raise FileOperationError(f"Error deleting instruction file {instruction_name}: {e}")
- src/mode_manager_mcp/tools/__init__.py:18-25 (registration)Top-level registration function that calls register_instruction_tools(), which in turn defines and registers the delete_instruction tool.def register_all_tools() -> None: """Register all tools with the server.""" register_instruction_tools() register_chatmode_tools() register_library_tools() register_memory_tools() register_remember_tools()