Where is stored the list of libraries and the path

Read " How to setup a project with local libs" in Library management in KiCad version 5.

Each project can have its own fp-lib-table and sym-lib-table. Each user has the global tables in their configuration. The path variables which can be used in the library tables are defined in the user configuration.

So, if you have an external script you have to read some files, i.e. you need the extra steps anyways.