Skip to main content
Glama
baidu

Baidu Vector Database MCP Server

Official
by baidu

drop_vector_index

Remove a vector index from a table in Baidu Vector Database to manage storage or modify search structures.

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
NameRequiredDescriptionDefault
table_nameYes
index_nameYes

Implementation Reference

  • Core handler logic in MochowConnector that checks if the vector index exists and drops it using the database API.
    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)}")
  • Registers the 'drop_vector_index' tool with MCP using @mcp.tool() decorator. This is the entry point function called by MCP, which delegates to the connector's handler.
    @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."

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/baidu/mochow-mcp-server-python'

If you have feedback or need assistance with the MCP directory API, please join our Discord server