Skip to main content
Glama
bvisible

MCP SSH Manager

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
NameRequiredDescriptionDefault
serverYesServer name
typeYesDatabase type
databaseNoDatabase name (if provided, lists tables/collections; if omitted, lists databases)
dbUserNoDatabase user
dbPasswordNoDatabase password
dbHostNoDatabase host (default: localhost)
dbPortNoDatabase port

Implementation Reference

  • 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'
    ],
  • 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;
    }
  • 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;
      });
    }
  • 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'
    };
  • Default ports for each database type, used in command construction.
    export const DB_PORTS = {
      mysql: 3306,
      postgresql: 5432,
      mongodb: 27017
    };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bvisible/mcp-ssh-manager'

If you have feedback or need assistance with the MCP directory API, please join our Discord server