mysql_list_databases
Retrieve a list of all databases available in a MySQL server. This tool provides read-only access to database names for exploration and analysis.
Instructions
List all available databases
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "mysql_list_databases"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:155-165 (handler)Handler case for the mysql_list_databases tool. It invokes mysqlConnection.listDatabases() and returns the JSON-formatted result as text content.
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 handler, including its name, description, and empty input schema.
{ name: 'mysql_list_databases', description: 'List all available databases', inputSchema: { type: 'object', properties: {}, }, }, - src/mysql-connection.ts:111-123 (helper)Core implementation of listDatabases method in MySQLConnection class. Executes 'SHOW DATABASES' query, extracts database 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); }); }