describe_table
Retrieve table structure and details from Baidu Vector Database to understand schema, fields, and configuration for data operations.
Instructions
Describe table details in the Mochow instance.
Args:
table_name (str): Name of the table to describe.
Returns:
str: A string containing the details of the table.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table_name | Yes |
Implementation Reference
- src/mochow_mcp_server/server.py:530-543 (handler)The primary handler function for the 'describe_table' MCP tool. Decorated with @mcp.tool() for automatic registration. It fetches table details using the connector's describe_table_info method and returns a formatted string description.@mcp.tool() async def describe_table(table_name: str, ctx: Context = None) -> str: """ Describe table details in the Mochow instance. Args: table_name (str): Name of the table to describe. Returns: str: A string containing the details of the table. """ connector = ctx.request_context.lifespan_context.connector details = await connector.describe_table_info(table_name) return f"Table details named '{table_name}' in Mochow instance:\n{str(details)}"
- Supporting helper method in the MochowConnector class that interfaces with the underlying pymochow database to retrieve and return table schema/details as a dictionary.async def describe_table_info(self, table_name: str) -> dict: """ Get detailed information about a table. Args: table_name (str): Name of the table. Returns: dict: A dictionary containing table details. """ if self.database is None: raise ValueError("Switch to the database before describe table") try: return self.database.describe_table(table_name).to_dict() except Exception as e: raise ValueError(f"Failed to get table detail info: {str(e)}")
- src/mochow_mcp_server/server.py:530-530 (registration)The @mcp.tool() decorator on the describe_table function registers it as an MCP tool with FastMCP.@mcp.tool()
- Input schema defined by function signature (table_name: str) and docstring; output is str.async def describe_table(table_name: str, ctx: Context = None) -> str: """ Describe table details in the Mochow instance. Args: table_name (str): Name of the table to describe. Returns: str: A string containing the details of the table.