Skip to main content
Glama
baidu

Baidu Vector Database MCP Server

Official
by baidu

use_database

Switch to a specified database within Baidu Vector Database MCP Server by providing the database name, enabling efficient management and access to vector data for LLM applications.

Instructions

Switch to a different database. Args: database_name (str): Name of the database to use. Returns: str: A message indicating the success of the database switch.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
database_nameYes

Implementation Reference

  • The main MCP tool handler for 'use_database'. It retrieves the connector from context, calls the connector's use_database method, and returns a success message. The @mcp.tool() decorator registers it as an MCP tool.
    @mcp.tool() async def use_database(database_name: str, ctx: Context = None) -> str: """ Switch to a different database. Args: database_name (str): Name of the database to use. Returns: str: A message indicating the success of the database switch. """ connector = ctx.request_context.lifespan_context.connector await connector.use_database(database_name) return f"Switched to database '{database_name}' successfully"
  • Supporting helper method in the MochowConnector class that switches the current database by setting self.database.
    async def use_database(self, db_name: str) -> bool: """ Switch to a different database. Args: db_name (str): Name of the database to use. Returns: bool: True if the database switch is successful, False otherwise. """ try: self.database = self.client.database(db_name) return True except Exception as e: raise ValueError(f"Failed to switch database: {str(e)}")

Other Tools

Related Tools

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