Scripting access to passwords stored in iCloud keychains

I am working on an automation tool to filter my email, and would like to use the email account credentials already in Mac Mail. I’ve been able to obtain most of the required information using AppleScript, but passwords are write only properties. I happen to have all the required passwords in my iCloud keychain, And confined and manipulate them easily in the GUI keychain app, But the CLI, security tool and Python libraries fail to find any of my web or email passwords. How can I retrieve my email and/or web passwords to use my python scripts?

I’m using macOS Sonoma on a 16”’intel MBP