list_tables
Retrieve all table names from the Baidu Vector Database to view available data collections for vector search operations.
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)The MCP tool handler for 'list_tables', decorated with @mcp.tool(). It retrieves the list of tables from the MochowConnector and formats them into a string response.@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 using the Mochow database client and returns a list of 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()