list_databases
Retrieve a list of all accessible databases in the MariaDB server to facilitate database exploration and schema inspection with secure read-only operations.
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-199 (handler)The main handler function for the list_databases tool, decorated with @mcp.tool() which registers it with the FastMCP server. Executes 'SHOW DATABASES' SQL query, processes results into a formatted list of database names, handles errors, and returns the result as a string.@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)}"