Skip to main content
Glama
baidu

Baidu Vector Database MCP Server

Official
by baidu

create_database

Create a new vector database in Baidu Cloud to store and organize vector embeddings for AI applications.

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

TableJSON Schema
NameRequiredDescriptionDefault
database_nameYes

Implementation Reference

  • MCP tool handler for 'create_database'. Registers the tool with FastMCP and implements the logic by delegating to MochowConnector.create_database.
    @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"
  • Helper method in MochowConnector class that performs the actual database creation using the pymochow client, first checking if it already exists.
    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)}")
  • FastMCP decorator that registers the create_database function as a tool.
    @mcp.tool()
  • Function signature and docstring defining the input schema (database_name: str) and output (str message).
    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. """

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