list_tables
Get a complete list of all table names in the current database, formatted one per line, for exploring database schema.
Instructions
List all tables in the current database.
Returns: str: A formatted string containing all table names, one per line
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- tools/sql_tools.py:57-67 (handler)The `list_tables` method on the `SQLTools` class executes the actual tool logic: it opens a MySQL connection, runs 'SHOW TABLES', fetches results, and returns table names as a newline-separated string.
def list_tables(self) -> str: """List all tables in the current database. Returns: str: A formatted string containing all table names, one per line """ with self.get_connection() as conn: cursor = conn.cursor() cursor.execute("SHOW TABLES") tables = [table[0] for table in cursor.fetchall()] return "\n".join(tables) - server.py:12-12 (registration)The `list_tables` method is registered as an MCP tool via `mcp.tool()(sql_tools.list_tables)`, making it available as a named tool in the MCP server.
mcp.tool()(sql_tools.list_tables)