we already have an interface in the form of "admin port" (primarily aimed at network servers). it would be nice if we could provide a ready-made script to handle the connection.
Is the admin port usable (or useful) when you are on the main menu? In a singleplayer game? Joined as a client in multiplayer?
The goal here is not to query information about a multiplayer game you are hosting, but to query information about which game you are playing, possibly including server address of a multiplayer session you have joined. Also, from within the IM client (be it Discord or anything else) instruct a running OpenTTD to join a specific server, or to allow friends to request to join your game, still from within their IM client.
The admin port only works when OpenTTD runs in server mode (why would you externally control your single-player session?). As such: it is not useful nor even usable at all in main menu as in that case no server is running.
In server mode it can query many game states, including player and map info as well as interactions between them. It is possible to use it as some kind of command-logging; while it does not have every game action available, it can get those via a game script which can have an interface to the admin port as well.