Skip to main content
Glama
baidu

Baidu Vector Database MCP Server

Official
by baidu

select_table_rows

Filter and retrieve specific rows from a table in Baidu Vector Database using expressions, with options to limit results and select output fields.

Instructions

Select rows with a filter expression in the Mochow instance.

Args:
    table_name (str): Name of the table.
    filter_expr (str): Filter expression to select data. Defaults to None.
    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 selected rows.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
filter_exprNo
limitNo
output_fieldsNo

Implementation Reference

  • The main handler function for the 'select_table_rows' tool. It is registered via the @mcp.tool() decorator, receives parameters, calls the underlying connector method, and formats the results as a string.
    @mcp.tool()
    async def select_table_rows(
        table_name: str,
        filter_expr: str = None, 
        limit: int = 10,
        output_fields: Optional[list[str]] = None,
        ctx: Context = None,
    ) -> str:
        """
        Select rows with a filter expression in the Mochow instance.
    
        Args:
            table_name (str): Name of the table.
            filter_expr (str): Filter expression to select data. Defaults to None.
            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 selected rows.
        """
        connector = ctx.request_context.lifespan_context.connector
        select_results = await connector.select_rows(table_name, filter_expr, limit, output_fields)
        output = f"Select rows results for '{table_name}':\n"
        for row in select_results.rows:
            output += f"{str(row)}\n"
        return output
  • Helper method in MochowConnector class that performs the actual database query to select rows from a table using filter expression, limit, and output fields.
    async def select_rows(
        self,
        table_name: str,
        filter_expr: str = None,
        limit: int = 10,
        output_fields: Optional[list[str]] = None,
    ) -> HttpResponse:
        """
        Select rows in a given table using a filter expression.
    
        Args:
            table_name (str): Name of the table.
            filter_expr (str): Filter expression to select data.
            limit (int): Maximum number of results. Defaults to 10.
            output_fields (Optional[list[str]]): Fields to return in the results. Defaults to None.
    
        Returns:
            HttpResponse: The HTTP response containing the selected rows.
        """
        if self.database is None:
            raise ValueError("Switch to the database before select rows with filter expression.")
    
        # select data with filter expression
        try:
            return self.database.table(table_name).select(filter=filter_expr, projections=output_fields, limit=limit)
        except ServerError as e:
            raise ValueError(f"Failed to select data with filter expression: {str(e)}")
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks critical behavioral details. It doesn't disclose whether this is read-only (implied by 'Select' but not explicit), authentication requirements, rate limits, error handling, or pagination behavior beyond the 'limit' parameter.

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

Conciseness4/5

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

Well-structured with a clear opening sentence followed by parameter and return value sections. The description is appropriately sized, though the 'Returns' section could be more informative given no output schema.

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?

For a 4-parameter tool with no annotations and no output schema, the description covers basic functionality but lacks completeness. It doesn't explain the return format beyond 'a string containing the selected rows', missing details on structure, error cases, or interaction with other tools like 'use_database' for context.

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

Parameters3/5

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

Schema description coverage is 0%, but the description adds meaningful context for all parameters: 'table_name' as the table to query, 'filter_expr' for filtering data, 'limit' for result maximum, and 'output_fields' for specifying returned fields. However, it doesn't explain filter expression syntax or field naming conventions.

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 action ('Select rows') and resource ('in the Mochow instance'), specifying it uses a filter expression. It distinguishes from siblings like 'delete_table_rows' (deletion) and 'describe_table' (metadata), but doesn't explicitly contrast with 'fulltext_search' or 'vector_search' for filtering alternatives.

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?

No guidance on when to use this tool versus alternatives like 'fulltext_search' or 'vector_search' for filtering, or 'list_tables' for broader queries. It mentions a filter expression but doesn't specify when filtering is appropriate versus other selection methods.

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