list_records
Retrieve paginated records from a sift. Provide sift_id, and optionally set limit, offset, or cursor to navigate results.
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)The MCP tool handler for 'list_records'. Decorated with @mcp.tool(), it takes sift_id, limit, offset, cursor params, gets the sift via AsyncSifter client, calls handle.find() for paginated results, and returns items, total, limit, offset, 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} - The AgentToolRunner handler for 'list_records'. Fetches paginated records directly from SiftResultsService.get_results() and returns formatted result dict with id, filename, and extracted_data per record.
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], } - The JSON schema registration for 'list_records' in AGENT_TOOL_SCHEMAS. Defines the function name, description, and parameters (sift_id required, limit/offset optional with defaults).
{ "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"], }, }, }, - code/mcp/sifter_mcp/server.py:72-85 (registration)The MCP tool is registered via the @mcp.tool() decorator on the list_records async function in the FastMCP server.
@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} - The SiftResultsService.get_results() helper method that queries MongoDB for paginated sift results by sift_id with skip/limit support.
async def get_results( self, sift_id: str, skip: int = 0, limit: int = 50, ) -> tuple[list[SiftResult], int]: query: dict = {"sift_id": sift_id} total = await self.col.count_documents(query) cursor = self.col.find(query).skip(skip).limit(limit) docs = await cursor.to_list(length=limit) return [SiftResult.from_mongo(d) for d in docs], total