from __future__ import annotations

from neo4j import GraphDatabase


def list_databases(uri: str, username: str, password: str) -> list[str]:
    driver = GraphDatabase.driver(uri, auth=(username, password))
    try:
        with driver.session(database="system") as session:
            query = session.run("SHOW DATABASES")
            return [row["name"] for row in query.data() if row["name"] != "system"]
    finally:
        driver.close()
