list_tables
Retrieve names of all tables in the Baidu Vector Database to manage or query data efficiently. Returns a string listing table names for easy reference.
Instructions
List all tables in the current database.
Returns:
str: A string containing the names of all tables.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mochow_mcp_server/server.py:518-528 (handler)MCP tool handler for 'list_tables'. Retrieves the list of tables from the current database using the MochowConnector and formats the response as a string.@mcp.tool() async def list_tables(ctx: Context) -> str: """ List all tables in the current database. Returns: str: A string containing the names of all tables. """ connector = ctx.request_context.lifespan_context.connector tables = await connector.list_tables() return f"Tables in database:\n{', '.join(tables)}"
- Helper method in MochowConnector class that lists all tables in the current database by calling self.database.list_table() and extracting table names.async def list_tables(self) -> list[str]: """ List all tables in the current database. Returns: list[str]: A list of table names. """ if self.database is None: raise ValueError("Switch to the database before list tables") try: tables = self.database.list_table() return [table.table_name for table in tables] except Exception as e: raise ValueError(f"Failed to list tables: {str(e)}")
- src/mochow_mcp_server/server.py:518-518 (registration)The @mcp.tool() decorator registers the list_tables function as an MCP tool.@mcp.tool()