list_records
Fetch records from a sift by ID, with pagination options: limit, offset, or cursor for iterating through large result sets.
Instructions
Get extracted records from a sift.
Args:
sift_id: The sift identifier
limit: Maximum number of records to return (default 20, max 100)
offset: Number of records to skip (ignored when cursor is provided)
cursor: Opaque pagination cursor from a previous call's next_cursor fieldInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sift_id | Yes | ||
| limit | No | ||
| offset | No | ||
| cursor | No |
Implementation Reference
- code/mcp/sifter_mcp/server.py:72-85 (handler)MCP tool handler for list_records. Uses FastMCP @mcp.tool() decorator. Fetches a sift by ID and returns paginated extracted records with items, total, limit, offset, and next_cursor.
@mcp.tool() async def list_records(sift_id: str, limit: int = 20, offset: int = 0, cursor: str = "") -> dict: """Get extracted records from a sift. Args: sift_id: The sift identifier limit: Maximum number of records to return (default 20, max 100) offset: Number of records to skip (ignored when cursor is provided) cursor: Opaque pagination cursor from a previous call's next_cursor field """ async with _get_client() as client: handle = await client.get_sift(sift_id) page = await handle.find(limit=min(limit, 100), cursor=cursor or None) return {"items": page.items, "total": page.total, "limit": page.limit, "offset": page.offset, "next_cursor": page.next_cursor} - Agent loop handler for list_records. Dispatched by AgentToolRunner._dispatch(). Calls SiftResultsService.get_results() and returns total + records with extracted_data.
if name == "list_records": limit = min(args.get("limit", 20), 100) offset = args.get("offset", 0) results, total = await self.results_svc.get_results(args["sift_id"], skip=offset, limit=limit) return { "total": total, "records": [{"id": r.id, "filename": r.filename, **r.extracted_data} for r in results], } - OpenAI/LLM function-calling schema for list_records, defining parameters: sift_id (required), limit (optional integer), offset (optional integer).
{ "type": "function", "function": { "name": "list_records", "description": "Get a paginated list of extracted records from a sift.", "parameters": { "type": "object", "properties": { "sift_id": {"type": "string", "description": "The sift identifier"}, "limit": {"type": "integer", "description": "Max records to return (default 20, max 100)"}, "offset": {"type": "integer", "description": "Records to skip for pagination"}, }, "required": ["sift_id"], }, }, }, - Helper function _infer_sift_id_from_trace that searches for sift_id from list_records calls in tool traces to infer context for widgets.
def _infer_sift_id_from_trace(trace: list) -> Optional[str]: """Return the first sift_id seen in aggregate_sift or get_sift calls.""" for t in trace: if t.tool in ("aggregate_sift", "get_sift", "list_records", "query_sift"): sid = t.args.get("sift_id") if sid: