mysql_list_databases
Retrieve all database names from a MySQL server to identify available data sources for read-only queries.
Instructions
List all available databases
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/index.ts:155-165 (handler)Tool handler for 'mysql_list_databases' that invokes MySQLConnection.listDatabases() and formats the result as JSON response.case 'mysql_list_databases': { const result = await mysqlConnection.listDatabases(); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/index.ts:77-84 (registration)Registration of the 'mysql_list_databases' tool in the listTools response, including name, description, and input schema.{ name: 'mysql_list_databases', description: 'List all available databases', inputSchema: { type: 'object', properties: {}, }, },
- src/mysql-connection.ts:111-123 (helper)Core implementation logic for listing databases: executes 'SHOW DATABASES', extracts names, and filters out system databases.async listDatabases(): Promise<string[]> { const query = 'SHOW DATABASES'; const result = await this.executeQuery(query); // Extract database names from result return result.rows.map((row: any) => { const key = Object.keys(row)[0]; // Get the first column name return row[key]; }).filter((db: string) => { // Filter out system databases return !['information_schema', 'mysql', 'performance_schema', 'sys'].includes(db); }); }