ssh_db_list
List databases or tables/collections from MySQL, PostgreSQL, or MongoDB servers via SSH connections. Specify server and database type to retrieve available databases, or add a database name to list its tables/collections.
Instructions
List databases or tables/collections
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server | Yes | Server name | |
| type | Yes | Database type | |
| database | No | Database name (if provided, lists tables/collections; if omitted, lists databases) | |
| dbUser | No | Database user | |
| dbPassword | No | Database password | |
| dbHost | No | Database host (default: localhost) | |
| dbPort | No | Database port |
Implementation Reference
- src/tool-registry.js:48-54 (registration)The tool 'ssh_db_list' is registered in the 'database' group within the centralized tool registry. This list is used for conditional registration, validation, and grouping of all 37 MCP tools.// Database group (4 tools) - Database operations database: [ 'ssh_db_dump', 'ssh_db_import', 'ssh_db_list', 'ssh_db_query' ],
- src/database-manager.js:247-331 (helper)Helper functions to build database listing commands for MySQL, PostgreSQL, and MongoDB. These construct the shell commands executed over SSH to list databases, core to the ssh_db_list tool logic.export function buildMySQLListDatabasesCommand(options) { const { user, password, host = 'localhost', port = 3306 } = options; let command = 'mysql'; if (user) command += ` -u${user}`; if (password) command += ` -p'${password}'`; if (host) command += ` -h ${host}`; if (port) command += ` -P ${port}`; command += ' -e "SHOW DATABASES;" | tail -n +2'; return command; } /** * Build MySQL list tables command */ export function buildMySQLListTablesCommand(options) { const { database, user, password, host = 'localhost', port = 3306 } = options; let command = 'mysql'; if (user) command += ` -u${user}`; if (password) command += ` -p'${password}'`; if (host) command += ` -h ${host}`; if (port) command += ` -P ${port}`; command += ` -e "USE ${database}; SHOW TABLES;" | tail -n +2`; return command; } /** * Build PostgreSQL list databases command */ export function buildPostgreSQLListDatabasesCommand(options) { const { user, password, host = 'localhost', port = 5432 } = options; let command = ''; if (password) { command = `PGPASSWORD='${password}' `; } command += 'psql'; if (user) command += ` -U ${user}`; if (host) command += ` -h ${host}`; if (port) command += ` -p ${port}`; command += ' -t -c "SELECT datname FROM pg_database WHERE datistemplate = false;" | sed \'/^$/d\' | sed \'s/^[ \\t]*//\''; return command; } /** * Build PostgreSQL list tables command */ export function buildPostgreSQLListTablesCommand(options) { const { database, user, password, host = 'localhost', port = 5432 } = options; let command = ''; if (password) { command = `PGPASSWORD='${password}' `; } command += 'psql'; if (user) command += ` -U ${user}`; if (host) command += ` -h ${host}`; if (port) command += ` -p ${port}`; command += ` -d ${database}`; command += ' -t -c "SELECT tablename FROM pg_tables WHERE schemaname = \'public\';" | sed \'/^$/d\' | sed \'s/^[ \\t]*//\''; return command; } /** * Build MongoDB list databases command */ export function buildMongoDBListDatabasesCommand(options) { const { user, password, host = 'localhost', port = 27017 } = options; let command = 'mongo'; if (host) command += ` --host ${host}`; if (port) command += ` --port ${port}`; if (user) command += ` --username ${user}`; if (password) command += ` --password '${password}'`; command += ' --quiet --eval "db.adminCommand(\'listDatabases\').databases.forEach(function(d){print(d.name)})"'; return command; }
- src/database-manager.js:449-464 (helper)Parser function for database list output that filters system databases based on DB type, processes results from the listing commands.export function parseDatabaseList(output, type) { const lines = output.trim().split('\n').filter(l => l.trim()); // Filter out system databases return lines.filter(db => { const dbLower = db.toLowerCase(); if (type === DB_TYPES.MYSQL) { return !['information_schema', 'performance_schema', 'mysql', 'sys'].includes(dbLower); } else if (type === DB_TYPES.POSTGRESQL) { return !['template0', 'template1', 'postgres'].includes(dbLower); } else if (type === DB_TYPES.MONGODB) { return !['admin', 'config', 'local'].includes(dbLower); } return true; }); }
- src/database-manager.js:7-11 (schema)Schema/constant definitions for supported database types used by database tools including ssh_db_list.export const DB_TYPES = { MYSQL: 'mysql', POSTGRESQL: 'postgresql', MONGODB: 'mongodb' };
- src/database-manager.js:14-18 (helper)Default ports for each database type, used in command construction.export const DB_PORTS = { mysql: 3306, postgresql: 5432, mongodb: 27017 };