Skip to main content
Glama
onimsha

Airtable OAuth MCP Server

by onimsha

search_records

Filter Airtable records using custom formulas to find specific data in your base. This tool enables targeted searches by applying formula-based criteria to retrieve matching records from specified tables.

Instructions

Search records using a formula filter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
base_idYesThe Airtable base ID
table_idYesThe table ID or name
filter_by_formulaYesAirtable formula for filtering
viewNoView name or ID
fieldsNoSpecific fields to include (field name or array of field names)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Primary handler for the 'search_records' MCP tool. Authenticates the client, normalizes the fields parameter to handle string or list input, constructs ListRecordsOptions, calls the AirtableClient.search_records helper, and returns formatted records with id, fields, and createdTime.
    @self.mcp.tool(description="Search records using a formula filter")
    async def search_records(
        base_id: Annotated[str, Field(description="The Airtable base ID")],
        table_id: Annotated[str, Field(description="The table ID or name")],
        filter_by_formula: Annotated[
            str, Field(description="Airtable formula for filtering")
        ],
        view: Annotated[str | None, Field(description="View name or ID")] = None,
        fields: Annotated[
            str | list[str] | None,
            Field(
                description="Specific fields to include (field name or array of field names)"
            ),
        ] = None,
    ) -> list[dict[str, Any]]:
        """Search records using a formula filter."""
        client = await self._get_authenticated_client()
    
        # Normalize fields parameter
        normalized_fields = None
        if fields is not None:
            if isinstance(fields, str):
                # Check if it's a JSON-encoded array string
                if fields.startswith("[") and fields.endswith("]"):
                    try:
                        import json
    
                        normalized_fields = json.loads(fields)
                    except (json.JSONDecodeError, ValueError):
                        # If JSON parsing fails, treat as single field name
                        normalized_fields = [fields]
                else:
                    # Single field name
                    normalized_fields = [fields]
            else:
                normalized_fields = fields
    
        options = ListRecordsOptions(
            view=view,
            fields=normalized_fields,
        )
    
        records = await client.search_records(
            base_id,
            table_id,
            filter_by_formula,
            options,
        )
    
        return [
            {
                "id": record.id,
                "fields": record.fields,
                "createdTime": record.created_time,
            }
            for record in records
        ]
  • Supporting helper method on AirtableClient that applies the filter_by_formula to ListRecordsOptions and delegates to list_records method.
    async def search_records(
        self,
        base_id: str,
        table_id: str,
        filter_by_formula: str,
        options: ListRecordsOptions | None = None,
    ) -> list[AirtableRecord]:
        """Search records using a formula filter.
    
        Args:
            base_id: The Airtable base ID
            table_id: The table ID or name
            filter_by_formula: Airtable formula for filtering
            options: Additional options for the search
    
        Returns:
            List of matching records
        """
        logger.info(
            f"Searching records in {base_id}/{table_id} with formula: {filter_by_formula}"
        )
    
        # Merge filter with existing options
        search_options = options or ListRecordsOptions()
        search_options.filter_by_formula = filter_by_formula
    
        return await self.list_records(base_id, table_id, search_options)
  • Pydantic schema model SearchRecordsArgs closely matching the search_records tool parameters, tested separately in unit tests.
    class SearchRecordsArgs(BaseArgs):
        """Arguments for search_records tool."""
    
        base_id: str = Field(description="The Airtable base ID")
        table_id: str = Field(description="The table ID or name")
        filter_by_formula: str = Field(description="Airtable formula for filtering")
        max_records: int | None = Field(
            default=None, description="Maximum number of records to return"
        )
        view: str | None = Field(default=None, description="View name or ID")
        fields: list[str] | None = Field(
            default=None, description="Specific fields to include"
        )
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 only states the basic action without behavioral details. It doesn't mention whether this is a read-only operation, potential rate limits, authentication requirements, pagination behavior, or what happens with invalid formulas. For a search tool with 5 parameters, this is insufficient disclosure.

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 a single, efficient sentence with zero wasted words. It's appropriately sized for a tool with good schema documentation and gets straight to the point without unnecessary elaboration.

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 has an output schema (which handles return values) and 100% schema coverage, the description is minimally adequate. However, for a search operation with formula filtering and multiple sibling tools, it should provide more context about when to use it and what behavioral expectations exist, especially with no annotations.

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 100%, providing good documentation for all parameters. The description adds minimal value by mentioning 'formula filter' which aligns with the 'filter_by_formula' parameter but doesn't explain formula syntax or provide examples. This meets the baseline for high schema coverage.

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

Purpose3/5

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

The description 'Search records using a formula filter' states the verb (search) and resource (records) but is vague about scope and lacks differentiation from sibling tools like 'list_records' or 'get_record'. It doesn't specify what type of records or system is involved, though the input schema hints at Airtable.

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 is provided on when to use this tool versus alternatives like 'list_records' or 'get_record'. The description implies formula-based filtering but doesn't explain when this is preferred over other filtering methods or tools, leaving the agent to guess based on parameter names alone.

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/onimsha/airtable-mcp-server-oauth'

If you have feedback or need assistance with the MCP directory API, please join our Discord server