Skip to main content
Glama
sifter-ai

sifter-mcp

Official

find_records

Retrieve records from a sift by applying a Mongo-subset filter, optional sort, limit, and pagination cursor for precise data querying.

Instructions

Filter records with structured criteria (no LLM roundtrip).

Args:
    sift_id: The sift identifier
    filter: Mongo-subset filter dict e.g. {"total": {"$gt": 1000}}
    sort: Optional sort spec e.g. [["date", -1]]
    limit: Max records to return (default 50)
    cursor: Opaque pagination cursor from a previous call

Returns:
    {"records": [...], "next_cursor": "..." | null}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sift_idYes
filterYes
sortNo
limitNo
cursorNo

Implementation Reference

  • Direct database handler for find_records used by the chat agent loop. Transforms filter keys to 'extracted_data.' prefix and runs a MongoDB aggregation pipeline.
    if name == "find_records":
        limit = min(args.get("limit", 50), 200)
        raw_filter = args.get("filter", {})
        mongo_filter = {f"extracted_data.{k}": v for k, v in raw_filter.items()}
        pipeline = [{"$match": mongo_filter}, {"$limit": limit}]
        results = await self.results_svc.execute_aggregation(args["sift_id"], pipeline)
        return {"results": results, "count": len(results)}
  • MCP tool handler for find_records. Uses AsyncSifter SDK client to filter records in a sift with structured criteria (Mongo-subset filter). Decorated with @mcp.tool().
    @mcp.tool()
    async def find_records(
        sift_id: str,
        filter: dict,
        sort: list = None,
        limit: int = 50,
        cursor: str = "",
    ) -> dict:
        """Filter records with structured criteria (no LLM roundtrip).
    
        Args:
            sift_id: The sift identifier
            filter: Mongo-subset filter dict e.g. {"total": {"$gt": 1000}}
            sort: Optional sort spec e.g. [["date", -1]]
            limit: Max records to return (default 50)
            cursor: Opaque pagination cursor from a previous call
    
        Returns:
            {"records": [...], "next_cursor": "..." | null}
        """
        async with _get_client() as client:
            handle = await client.get_sift(sift_id)
            page = await handle.find(
                filter=filter,
                sort=sort or None,
                limit=min(limit, 200),
                cursor=cursor or None,
            )
        return {"records": page.items, "next_cursor": page.next_cursor, "total": page.total}
  • JSON Schema definition for the find_records tool function used in the agent tool list (OpenAI-compatible function calling schema).
    {
        "type": "function",
        "function": {
            "name": "find_records",
            "description": "Filter records in a sift using structured criteria (no LLM round-trip). Field names map to extracted_data keys.",
            "parameters": {
                "type": "object",
                "properties": {
                    "sift_id": {"type": "string", "description": "The sift identifier"},
                    "filter": {
                        "type": "object",
                        "description": 'MongoDB-style filter on extracted fields, e.g. {"amount": {"$gt": 1000}}',
                    },
                    "limit": {"type": "integer", "description": "Max records (default 50, max 200)"},
                },
                "required": ["sift_id", "filter"],
            },
        },
    },
  • Registration via @mcp.tool() decorator on the find_records async function in the FastMCP server.
    @mcp.tool()
    async def find_records(
        sift_id: str,
        filter: dict,
        sort: list = None,
        limit: int = 50,
        cursor: str = "",
    ) -> dict:
        """Filter records with structured criteria (no LLM roundtrip).
    
        Args:
            sift_id: The sift identifier
            filter: Mongo-subset filter dict e.g. {"total": {"$gt": 1000}}
            sort: Optional sort spec e.g. [["date", -1]]
            limit: Max records to return (default 50)
            cursor: Opaque pagination cursor from a previous call
    
        Returns:
            {"records": [...], "next_cursor": "..." | null}
        """
        async with _get_client() as client:
            handle = await client.get_sift(sift_id)
            page = await handle.find(
                filter=filter,
                sort=sort or None,
                limit=min(limit, 200),
                cursor=cursor or None,
            )
        return {"records": page.items, "next_cursor": page.next_cursor, "total": page.total}
  • Zapier integration: defines 'find_records' as a search with input fields (sift_id, filter JSON, limit) and an HTTP perform function calling the backend API.
    const searchFindRecords = {
      key: "find_records",
      noun: "Record",
      display: {
        label: "Find Records",
        description: "Search records in a sift.",
      },
      operation: {
        inputFields: [
          { key: "sift_id", label: "Sift", dynamic: "sift_choices.id.name", required: true },
          { key: "filter", label: "Filter (JSON)", required: false, helpText: 'e.g. {"amount": {"$gt": 100}}' },
          { key: "limit", label: "Limit", required: false, default: "10" },
        ],
        perform: async (z, bundle) => {
          const params = new URLSearchParams({ limit: bundle.inputData.limit || "10" });
          if (bundle.inputData.filter) params.set("filter", bundle.inputData.filter);
          const resp = await z.request({
            url: `${apiUrl(bundle)}/api/sifts/${bundle.inputData.sift_id}/records?${params}`,
            headers: headers(bundle),
          });
          return (resp.data.items || []);
        },
        sample: { id: "sample-record-id", extracted_data: {} },
      },
    };
Behavior4/5

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

With no annotations, the description carries full burden. It discloses that the tool performs filtering (read operation), explains the filter syntax with MongoDB-like operators, and specifies pagination behavior via cursor. It does not explicitly state idempotency or whether the operation is read-only, but the context implies no side effects. Overall, good transparency.

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?

The description is well-structured with 'Args' and 'Returns' sections, making it scannable. It uses bullet-like formatting. It could be slightly shorter (e.g., combine default values), but remains concise without critical omissions.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 5 parameters (including nested filter and sort), no output schema, and the tool's complexity, the description fully covers input syntax, behavior (pagination, default limit), and output format. No obvious gaps remain for correct invocation.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must explain each parameter. It does so thoroughly: sift_id (required identifier), filter (object with example), sort (array of tuples), limit (integer with default 50), cursor (opaque string). Examples and types add meaning beyond the raw schema.

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

Purpose5/5

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

The first sentence 'Filter records with structured criteria (no LLM roundtrip)' clearly specifies the action (filter), resource (records), and mode (structured, deterministic). This distinguishes from sibling tools like query_sift that may use LLM, and from list_records which likely returns all records.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states 'no LLM roundtrip,' indicating this tool is for deterministic filtering. However, it does not explicitly mention when not to use it or name alternative tools for similar tasks (e.g., query_sift for natural language). The intended use case is clear but exclusion criteria are only implied.

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/sifter-ai/sifter'

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