Analyzing the levels of anticancer medications in biological samples and body fluids reveals important details on the course and effects of chemotherapy. p (L-Cys)/graphitic-carbon nitride (g-C3N4)/GCE, a modified glassy carbon electrode, was created for the current study's electrochemical detection of methotrexate (MTX), a drug used to treat breast cancer, in pharmaceutical fluid samples. l-Cysteine was electro-polymerized on the surface of the g-C3N4/GCE after the g-C3N4 was first modified to prepare the p (L-Cys)/g-C3N4/GCE. Analyses of morphology and structure showed that well-crystalline p (L-Cys) on g-C3N4/GCE was successfully electropolymerized. Studying the electrochemical characteristics of p (L-Cys)/g-C3N4/GCE using CV and DPV techniques revealed a synergistic impact between g-C3N4 and l-cysteine that improved the stability and selectivity of the electrochemical oxidation of MTX while enhancing the electrochemical signal. Results showed that 7.5–780 μM was the linear range, and that 0.11841 μA/μM and 6 nM, respectively, were the sensitivity and limit of detection. The applicability of the suggested sensors was assessed using real pharmaceutical preparations, and the results showed that p (L-Cys)/g-C3N4/GCE had a high degree of precision. Five breast cancer patients who volunteered and provided prepared blood serum samples between the ages of 35 and 50 were used to examine the validity and accuracy of the proposed sensor in the current work for the determination of MTX. The results showed good recovery values (greater than 97.20%), appropriate accuracy (RSD less than 5.11%), and good agreement between the ELISA and DPV analysis results. These findings showed that p (L-Cys)/g-C3N4/GCE can be applied as a trustworthy MTX sensor for MTX level monitoring in blood samples and pharmaceutical samples.