Skip to main content
Glama
baidu

Baidu Vector Database MCP Server

Official
by baidu

fulltext_search

Search text content in Baidu Vector Database tables using BM25 similarity with attribute filtering to retrieve relevant results.

Instructions

Perform full text search combining BM25 similarity and scalar attribute filtering in the Mochow instance.

Args:
    table_name (str): Name of the table to search.
    index_name (str): Name of the inverted index to perform full text search.
    search_text (str): Text to search.
    limit (int): Maximum number of results. Defaults to 10.
    output_fields (Optional[list[str]]): Fields to return in the results. Defaults to None.

Returns:
    str: A string containing the full text search results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
index_nameYes
search_textYes
filter_exprNo
limitNo
output_fieldsNo

Implementation Reference

  • The MCP tool handler for 'fulltext_search'. It extracts parameters, calls the underlying connector's fulltext_search method, formats the search results from HttpResponse into a readable string output.
    @mcp.tool()
    async def fulltext_search(
        table_name: str, 
        index_name: str,
        search_text: str,
        filter_expr: Optional[str] = None,
        limit: int = 10,
        output_fields: Optional[list[str]] = None,
        ctx: Context = None,
    ) -> str:
        """
        Perform full text search combining BM25 similarity and scalar attribute filtering in the Mochow instance.
    
        Args:
            table_name (str): Name of the table to search.
            index_name (str): Name of the inverted index to perform full text search.
            search_text (str): Text to search.
            limit (int): Maximum number of results. Defaults to 10.
            output_fields (Optional[list[str]]): Fields to return in the results. Defaults to None.
    
        Returns:
            str: A string containing the full text search results.
        """
        connector = ctx.request_context.lifespan_context.connector
        search_results = await connector.fulltext_search(table_name, index_name, search_text, limit, output_fields, filter_expr)
    
        output = f"Full text search results for '{table_name}':\n"
        for row in search_results.rows:
            output += f"{str(row["row"])}\n"
    
        return output
  • Helper method in the MochowConnector class that implements the core full-text search logic using BM25SearchRequest on the Mochow database client.
    async def fulltext_search(
        self,
        table_name: str, 
        index_name: str,
        search_text: str,
        limit: int = 10,
        output_fields: Optional[list[str]] = None,
        filter_expr: Optional[str] = None,
    ) -> HttpResponse:
        """
        Perform full text search combining BM25 similarity and scalar attribute filtering.
    
        Args:
            table_name (str): Name of the table to search.
            index_name (str): Name of the inverted index to perform full text search.
            search_text (str): Text to search.
            limit (int): Maximum number of results. Defaults to 10.
            output_fields (Optional[list[str]]): Fields to return in the results. Defaults to None.
            filter_expr (Optional[str]): Filter expression for scalar attributes. Defaults to None.
    
        Returns:
            HttpResponse: The HTTP response containing the search results.
        """
        if self.database is None:
            raise ValueError("Switch to the database before perform full text search.")
    
        request = BM25SearchRequest(index_name=index_name,
                                    search_text=search_text,
                                    limit=limit,
                                    filter=filter_expr)
        try:
            return self.database.table(table_name).bm25_search(request=request, projections=output_fields)
        except Exception as e:
            raise ValueError(f"Failed to perform full text search: {str(e)}")
  • The @mcp.tool() decorator registers the fulltext_search function as an MCP tool.
    @mcp.tool()
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 mentions BM25 similarity and scalar filtering but doesn't cover critical aspects like performance characteristics, error conditions, authentication requirements, rate limits, or what happens when no results are found. For a search tool with 6 parameters, this leaves significant gaps.

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 well-structured with a clear purpose statement followed by organized Args and Returns sections. Every sentence earns its place, and there's no redundant information. The formatting makes it easy to scan and understand.

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 complexity (6 parameters, no annotations, no output schema), the description provides good parameter documentation but lacks behavioral context and usage guidance. The Returns section is minimal ('A string containing the full text search results'), which doesn't help understand the output format. For a search tool, this leaves the agent with incomplete information about what to expect.

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 provides clear documentation for 5 out of 6 parameters (table_name, index_name, search_text, limit, output_fields) in the Args section, adding meaningful context beyond the schema's 0% coverage. However, it completely omits the 'filter_expr' parameter, which is a notable gap given its potential importance for scalar filtering mentioned in the purpose.

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 performs 'full text search combining BM25 similarity and scalar attribute filtering in the Mochow instance,' which is a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'select_table_rows' or 'vector_search,' which might also retrieve data from tables.

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 like 'select_table_rows' or 'vector_search.' It mentions BM25 and scalar filtering but doesn't explain when this approach is preferred over other search methods available in the sibling tools.

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