mysql_list_databases
Retrieve a list of all available databases from a MySQL server to view existing data structures and plan database operations.
Instructions
列出所有数据库
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/server.ts:304-315 (handler)MCP tool handler for 'mysql_list_databases' that delegates to DatabaseManager.listDatabases() and formats the response as MCP content.
private async handleListDatabases(): Promise<any> { const databases = await this.dbManager.listDatabases(); return { content: [ { type: 'text', text: `数据库列表:\n${JSON.stringify(databases, null, 2)}`, }, ], }; } - src/server.ts:63-70 (schema)Tool schema definition: name, description, and empty input schema for mysql_list_databases.
{ name: 'mysql_list_databases', description: '列出所有数据库', inputSchema: { type: 'object', properties: {}, }, }, - src/server.ts:237-238 (registration)Dispatch registration in CallToolRequest handler switch statement mapping tool name to handler.
case 'mysql_list_databases': return await this.handleListDatabases(); - src/database.ts:82-94 (helper)Core helper method in DatabaseManager that executes SQL query to list databases, excluding system 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[]; }