list_databases
Retrieve all accessible database names from a MariaDB server to explore available data sources and manage connections.
Instructions
List all accessible databases in the MariaDB server.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mariadb_mcp/server.py:184-198 (handler)The main handler function for the 'list_databases' tool. It executes a 'SHOW DATABASES' SQL query using the shared MariaDB connection pool, extracts database names from the results, logs the operation, and returns a formatted list of available databases or an error message.@mcp.tool() async def list_databases() -> str: """List all accessible databases in the MariaDB server.""" logger.info("Tool called: list_databases") try: query = "SHOW DATABASES" results = await db_connection.execute_query(query) databases = [row['Database'] for row in results] logger.info(f"Found {len(databases)} databases") return f"Available databases ({len(databases)}):\n" + "\n".join(f"- {db}" for db in databases) except Exception as e: logger.error(f"Error listing databases: {e}") return f"Error listing databases: {str(e)}"
- src/mariadb_mcp/server.py:184-184 (registration)Registers the 'list_databases' tool with the FastMCP server using the @mcp.tool() decorator.@mcp.tool()