In order to interact with native osx applications, AppleScript support is a plus.
Here is a patch that makes LyX respond to a simple command (run) and that allows to communicate with LyX as with the LyX client.
Example of use:
tell application "LyX" to run "server-get-filename" with argument ""'
returns
message:/Users/bpiwowar/newfile1.lyx, code:0
with a message and the error code