list_databases
List all accessible databases in a MariaDB server to help AI assistants explore and interact with database structures efficiently.
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": "list_databases"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:130-135 (handler)Executes the list_databases tool by creating a database connection and running 'SHOW DATABASES' query, then returns the results as formatted JSON text content.
case "list_databases": { connection = await createDbConnection(); // 특정 DB 없이 연결 const [rows] = await connection.query('SHOW DATABASES;'); // 데이터베이스 목록 조회 쿼리 // 결과를 JSON 문자열로 변환하여 반환 (가독성을 위해 null, 2 사용) return { content: [{ type: "text", text: JSON.stringify(rows, null, 2) }] }; } - src/index.ts:75-79 (registration)Registers the list_databases tool in the ListTools response, specifying its name, description, and input schema (empty object, no parameters required).
{ name: "list_databases", description: "접근 가능한 모든 데이터베이스 목록을 보여줍니다.", inputSchema: { type: "object", properties: {} } // 입력 필요 없음 }, - src/index.ts:78-79 (schema)Input schema definition for list_databases tool: an empty object with no properties.
inputSchema: { type: "object", properties: {} } // 입력 필요 없음 }, - src/index.ts:37-49 (helper)Helper function to create a MySQL connection for the database, used by the list_databases handler (called without dbName).
async function createDbConnection(dbName?: string) { try { const connection = await mysql.createConnection({ ...dbConfig, database: dbName || dbConfig.database, // 특정 DB가 제공되면 사용, 아니면 기본값 사용 }); return connection; } catch (error: any) { console.error("데이터베이스 연결 오류:", error.message); // MCP 클라이언트에게 더 구체적인 오류 제공 throw new McpError(ErrorCode.InternalError, `데이터베이스 연결 실패: ${error.message}`); } }