Skip to main content
Glama
yawlhead91

MariaDB MCP Server

by yawlhead91

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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)}"
  • Registers the 'list_databases' tool with the FastMCP server using the @mcp.tool() decorator.
    @mcp.tool()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yawlhead91/mariadb-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server