list_tables
Retrieve table names from a StarRocks database to explore available data structures for querying and analysis.
Instructions
List tables in a database
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | Database name (optional, defaults to 'ads') |
Implementation Reference
- The handler logic in `table_tools.py` which calls the `list_tables` method on the StarRocks client.
elif name == "list_tables": database = arguments.get("database") tables = client.list_tables(database) db_name = database or config.database return [ TextContent( type="text", text=f"Found {len(tables)} tables in database '{db_name}':\n\n{format_json(tables)}", ) ] - src/starrocks_mcp/client.py:89-96 (handler)The core implementation of `list_tables` that executes the SQL query against StarRocks.
def list_tables(self, database: Optional[str] = None) -> List[str]: """List tables in a database.""" db = database or self.config.database validated_db = validate_identifier(db, "database") results = self.execute_query(f"SHOW TABLES FROM `{validated_db}`") # StarRocks returns column name like "Tables_in_{database}" key = f"Tables_in_{validated_db}" return [row.get(key, row.get("TABLE_NAME", "")) for row in results] - The registration and schema definition for the `list_tables` tool.
Tool( name="list_tables", description="List tables in a database", inputSchema={ "type": "object", "properties": { "database": { "type": "string", "description": "Database name (optional, defaults to 'ads')", } }, }, ),