Skip to main content
Glama
baidu

Baidu Vector Database MCP Server

Official
by baidu

use_database

Switch between databases in Baidu Cloud Vector Database to manage different datasets for vector search operations.

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

  • MCP tool handler function for 'use_database'. It retrieves the connector from context, calls the connector's use_database method, and returns a success message. This is also the registration point via @mcp.tool() decorator.
    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"
  • Helper method in MochowConnector class that switches the current database by setting self.database to the client for the specified db_name.
    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)}")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Switch to a different database') and mentions a success message return, but lacks critical details: whether this affects subsequent operations, if it requires specific permissions, potential side effects, or error conditions (e.g., invalid database name).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with a clear purpose statement followed by formatted Args and Returns sections. Every sentence adds value without redundancy, making it easy to scan and understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (a state-changing operation with no annotations or output schema), the description is minimally adequate. It covers the basic action and parameter but lacks details on behavioral impact, error handling, and integration with sibling tools, leaving gaps for an agent to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context for the single parameter 'database_name' by explaining it's the 'Name of the database to use,' which clarifies its role beyond the schema's basic title. With 0% schema description coverage and only one parameter, this adequately compensates, though it could specify format constraints (e.g., case sensitivity).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Switch') and resource ('database'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_databases' or 'create_database', which would be needed for a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing database), exclusions, or relationships to sibling tools like 'list_databases' (which might be needed first to see available databases).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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