Skip to main content
Glama
yawlhead91

MariaDB MCP Server

by yawlhead91

list_tables

Retrieve all tables within a MariaDB database. Use this tool to explore database schemas and inspect table structures for better data management and analysis.

Instructions

List all tables in a specific database.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNo

Implementation Reference

  • The handler function for the list_tables tool. It executes a SHOW TABLES query on the specified or current database, extracts table names from the results, and formats them as a list. The @mcp.tool() decorator registers it as an MCP tool.
    @mcp.tool() async def list_tables(database: Optional[str] = None) -> str: """List all tables in a specific database.""" try: if database: # Use the specified database query = f"SHOW TABLES FROM `{database}`" else: # Use current database query = "SHOW TABLES" results = await db_connection.execute_query(query) if not results: db_name = database or "current database" return f"No tables found in {db_name}" # Get table name from result (column name varies) tables = [] for row in results: # The column name is usually "Tables_in_<database_name>" table_name = list(row.values())[0] tables.append(table_name) db_name = database or "current database" return f"Tables in {db_name} ({len(tables)}):\n" + "\n".join(f"- {table}" for table in tables) except Exception as e: logger.error(f"Error listing tables: {e}") return f"Error listing tables: {str(e)}"

Other Tools

Related Tools

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