drop_vector_index
Remove a vector index from a specified table in the Baidu Vector Database using the MCP server. Requires table and index names to execute.
Instructions
Drop the vector index in the Mochow instance.
Args:
table_name (str): Name of the table.
index_name (str): Name of the vector index to drop.
Returns:
str: A message indicating the success of index drop.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index_name | Yes | ||
| table_name | Yes |
Implementation Reference
- src/mochow_mcp_server/server.py:639-653 (handler)MCP tool handler for 'drop_vector_index'. It retrieves the connector from context, calls the helper method to drop the index, and returns a success message.@mcp.tool() async def drop_vector_index(table_name: str, index_name: str, ctx: Context = None) -> str: """ Drop the vector index in the Mochow instance. Args: table_name (str): Name of the table. index_name (str): Name of the vector index to drop. Returns: str: A message indicating the success of index drop. """ connector = ctx.request_context.lifespan_context.connector await connector.drop_vector_index(table_name, index_name) return f"Drop the vector index '{index_name}' successfully."
- Helper method in MochowConnector class that implements the logic to drop a vector index: checks existence, drops if exists, handles errors.async def drop_vector_index(self, table_name: str, index_name: str) -> bool: """ Drop a vector index in a given table. Args: table_name (str): Name of the table. index_name (str): Name of the vector index. Returns: bool: True if the index is dropped successfully or does not exist, False otherwise. """ if self.database is None: raise ValueError("Switch to the database before drop vector index") # check vector index index_existed = True try: self.database.table(table_name).describe_index(index_name) except ServerError as e: if e.code == ServerErrCode.INDEX_NOT_EXIST: index_existed = False else: raise ValueError(f"Failed to get index detail: {str(e)}") # index already existed with same name if not index_existed: return True try: self.database.table(table_name).drop_index(index_name) return True except Exception as e: raise ValueError(f"Failed to drop vector index: {str(e)}")