Skip to main content
Glama
baidu

Baidu Vector Database MCP Server

Official
by baidu

rebuild_vector_index

Rebuild a vector index in Baidu Vector Database to optimize search performance and maintain data integrity for AI applications.

Instructions

Rebuild the vector index in the Mochow instance. Args: table_name (str): Name of the table. index_name (str): Name of the vector index to rebuild. Returns: str: A message indicating the success of index rebuild initiation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
index_nameYes

Implementation Reference

  • MCP tool handler function for 'rebuild_vector_index', decorated with @mcp.tool() for registration, delegates to MochowConnector.rebuild_vector_index
    @mcp.tool() async def rebuild_vector_index(table_name: str, index_name: str, ctx: Context = None) -> str: """ Rebuild the vector index in the Mochow instance. Args: table_name (str): Name of the table. index_name (str): Name of the vector index to rebuild. Returns: str: A message indicating the success of index rebuild initiation. """ connector = ctx.request_context.lifespan_context.connector await connector.rebuild_vector_index(table_name, index_name) return f"Initiate the rebuild of vector index '{index_name}' successfully."
  • Core helper method in MochowConnector class that implements the vector index rebuild logic by calling the Mochow database API.
    async def rebuild_vector_index(self, table_name: str, index_name: str) -> bool: """ Rebuild 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 rebuilt successfully, False otherwise. """ if self.database is None: raise ValueError("Switch to the database before rebuild 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: raise ValueError(f"Vector index not existed with name '{index_name}'") try: self.database.table(table_name).rebuild_index(index_name) return True except Exception as e: raise ValueError(f"Failed to rebuild vector index: {str(e)}")

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