Toolserver used to provide script_path as part of its toolserver.wiki meta database (T50626). I'd like the meta_p database to provide this as well.
Perhaps we can do it better by making it a full url (including protocol and domain) to discourage any string manipulation. For now it would default to {url}/w. (Note, no trailing slash - per MediaWiki convention).
Alternatively, we could go one step further and also discourage creation of other entry points by tools and instead encourage them to always query the API, by adding api_url instead (e.g. they shouldn't use script_path for other urls).
By only maintaining dbname, slice, api_url tools can boostrap everything they need. Fields lang and project would be good to keep for better discovery of related wikis without having to query 800 API endpoints. Everything else can be queried from the API endpoint (or, if not, should be added to the siteinfo API).
Even just auto-populating it with a meaningless {url}/w/api.php would make the separation of concerns closer to where it should be, so that at least it isn't duplicated in every single tool.