Toolserver has the local table toolserver.wiki on all databases that provides metadata about the wikis including the server the wiki's database is kept on:
| mysql> SELECT * FROM toolserver.wiki LIMIT 5; | +----------------+------+------------+------------------+------+---------+-----------+--------------+--------------+---------------+--------+-------------+ | | dbname | lang | family | domain | size | is_meta | is_closed | is_multilang | is_sensitive | root_category | server | script_path | | +----------------+------+------------+------------------+------+---------+-----------+--------------+--------------+---------------+--------+-------------+ | | aawikibooks_p | aa | wikibooks | NULL | 3 | 0 | 1 | 0 | 0 | NULL | 3 | /w/ | | | aawiki_p | aa | wikipedia | NULL | 6 | 0 | 1 | 0 | 0 | NULL | 3 | /w/ | | | aawiktionary_p | aa | wiktionary | NULL | 1 | 0 | 1 | 0 | 1 | NULL | 3 | /w/ | | | abwiki_p | ab | wikipedia | ab.wikipedia.org | 807 | 0 | 0 | 0 | 0 | NULL | 3 | /w/ | | | abwiktionary_p | ab | wiktionary | NULL | 0 | 0 | 1 | 0 | 1 | NULL | 3 | /w/ | | +----------------+------+------------+------------------+------+---------+-----------+--------------+--------------+---------------+--------+-------------+ | 5 rows in set (0.00 sec) | mysql>
Most of the information can probably be extracted from operations/mediawiki-config, but I don't know which sources there are authoritative.
See also: T50625: Provide namespace IDs and names in the databases similar to toolserver.namespace