list_databases
Retrieve all accessible databases from a MySQL server to identify available data sources for query operations.
Instructions
List all accessible databases on the MySQL server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:135-149 (handler)Handler function for 'list_databases' tool. Executes 'SHOW DATABASES' SQL query using the shared MySQL connection pool and returns the result rows as formatted JSON.case "list_databases": { console.error('[Tool] Executing list_databases'); const { rows } = await executeQuery( pool, 'SHOW DATABASES' ); return { content: [{ type: "text", text: JSON.stringify(rows, null, 2) }] }; }
- src/index.ts:67-74 (schema)Tool schema definition including name, description, and input schema (empty object, no parameters required).name: "list_databases", description: "List all accessible databases on the MySQL server", inputSchema: { type: "object", properties: {}, required: [] } },
- src/index.ts:63-127 (registration)Registration of all tools via ListToolsRequestHandler, including 'list_databases' in the tools list.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "list_databases", description: "List all accessible databases on the MySQL server", inputSchema: { type: "object", properties: {}, required: [] } }, { name: "list_tables", description: "List all tables in a specified database", inputSchema: { type: "object", properties: { database: { type: "string", description: "Database name (optional, uses default if not specified)" } }, required: [] } }, { name: "describe_table", description: "Show the schema for a specific table", inputSchema: { type: "object", properties: { database: { type: "string", description: "Database name (optional, uses default if not specified)" }, table: { type: "string", description: "Table name" } }, required: ["table"] } }, { name: "execute_query", description: "Execute a read-only SQL query", inputSchema: { type: "object", properties: { query: { type: "string", description: "SQL query (only SELECT, SHOW, DESCRIBE, and EXPLAIN statements are allowed)" }, database: { type: "string", description: "Database name (optional, uses default if not specified)" } }, required: ["query"] } } ] }; });