mysql_list_databases
Retrieve a list of all databases in MySQL. This tool helps users quickly access and view database names for management or query purposes.
Instructions
列出所有数据库
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:304-315 (handler)Handler function for the 'mysql_list_databases' tool. Calls DatabaseManager.listDatabases() and formats the response as text content.private async handleListDatabases(): Promise<any> { const databases = await this.dbManager.listDatabases(); return { content: [ { type: 'text', text: `数据库列表:\n${JSON.stringify(databases, null, 2)}`, }, ], }; }
- src/database.ts:82-94 (helper)Core implementation that executes SQL query against information_schema.SCHEMATA to retrieve list of user databases.async listDatabases(): Promise<DatabaseInfo[]> { const result = await this.query(` SELECT SCHEMA_NAME as name, DEFAULT_CHARACTER_SET_NAME as charset, DEFAULT_COLLATION_NAME as collation FROM information_schema.SCHEMATA WHERE SCHEMA_NAME NOT IN ('information_schema', 'performance_schema', 'mysql', 'sys') ORDER BY SCHEMA_NAME `); return result.rows as DatabaseInfo[]; }
- src/server.ts:63-70 (schema)Tool schema definition including name, description, and empty input schema (no parameters required).{ name: 'mysql_list_databases', description: '列出所有数据库', inputSchema: { type: 'object', properties: {}, }, },
- src/server.ts:237-238 (registration)Switch case in CallToolRequestSchema handler that routes 'mysql_list_databases' calls to the handler function.case 'mysql_list_databases': return await this.handleListDatabases();