Skip to main content
Glama
baidu

Baidu Vector Database MCP Server

Official
by baidu

create_database

Create a new database in Baidu Vector Database MCP Server by specifying a unique database name, enabling organized storage and management of vector data for efficient search operations.

Instructions

Create a database in the Mochow instance. Args: database_name (str): Name of the database. Returns: str: A message indicating the success of database creation.

Input Schema

NameRequiredDescriptionDefault
database_nameYes

Input Schema (JSON Schema)

{ "properties": { "database_name": { "title": "Database Name", "type": "string" } }, "required": [ "database_name" ], "title": "create_databaseArguments", "type": "object" }

Implementation Reference

  • The handler function for the 'create_database' MCP tool. It is registered via the @mcp.tool() decorator and implements the tool logic by delegating to the MochowConnector's create_database method.
    @mcp.tool() async def create_database(database_name: str, ctx: Context = None) -> str: """ Create a database in the Mochow instance. Args: database_name (str): Name of the database. Returns: str: A message indicating the success of database creation. """ connector = ctx.request_context.lifespan_context.connector await connector.create_database(database_name) return f"Created a database named '{database_name}'in Mochow instance:\n"
  • Supporting method in MochowConnector class that performs the actual database creation logic: checks for existence, creates via client if needed, and updates the current database reference.
    async def create_database(self, db_name: str) -> bool: """ Create a new database. Args: db_name (str): Name of the database to create. Returns: bool: True if the database is created or already exists, False otherwise. """ try: # database already existed for db in self.client.list_databases(): if db.database_name == db_name: return True # create the new database self.client.create_database(db_name) self.database = self.client.database(db_name) return True except Exception as e: raise ValueError(f"Failed to create database: {str(e)}")
  • Initialization of the FastMCP server instance named 'mcp' with lifespan manager, to which all tools including 'create_database' are registered via decorators.
    mcp = FastMCP("Mochow", lifespan=server_lifespan)

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