A search for direct CP violation in the Cabibbo-suppressed decay Ds+→ K−K+K+ and in the doubly Cabibbo-suppressed decay D+ → K−K+K+ is reported. The analysis is performed with data collected by the LHCb experiment in proton-proton collisions at a centre-of-mass energy of 13 TeV corresponding to an integrated luminosity of 5.6 fb−1−1. The search is conducted by comparing the D(s)+ and D(s)− Dalitz-plot distributions through a model-independent binned technique, based on fits to the K−K+K+ invariant-mass distributions, with a total of 0.97 (1.27) million Ds+(D+) signal candidates. The results are given as p-values for the hypothesis of CP conservation and are found to be 13.3% for the Ds+→ K−K+K+ decay and 31.6% for the D+→ K−K+K+ decay. No evidence for CP violation is observed in these decays. [graphic not available: see fulltext]