twist_inbox_archive_all
Archive all threads in a Twist workspace inbox to reduce clutter, with optional filtering by timestamp to target older conversations.
Instructions
Archives all threads in a workspace.
Args: older_than_ts: Only archives threads that are the same or older than this timestamp
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| older_than_ts | No |
Implementation Reference
- src/inbox.py:68-98 (handler)The main handler function that executes the logic to archive all inbox threads in the Twist workspace, optionally filtering by timestamp. It retrieves the token from context, builds params, calls the Twist API via twist_request, and returns success or error message.def twist_inbox_archive_all( ctx: Context, older_than_ts: Optional[int] = None ) -> str: """Archives all threads in a workspace. Args: older_than_ts: Only archives threads that are the same or older than this timestamp """ token = ctx.request_context.lifespan_context.twist_token workspace_id = os.getenv("TWIST_WORKSPACE_ID") if not workspace_id: logger.error("TWIST_WORKSPACE_ID environment variable is required") return "Error: TWIST_WORKSPACE_ID environment variable is required" params = {"workspace_id": workspace_id} if older_than_ts is not None: params["older_than_ts"] = older_than_ts try: logger.info(f"Archiving all inbox threads for workspace ID: {workspace_id}") result = twist_request("inbox/archive_all", params=params, token=token, method="POST") logger.info("Successfully archived all inbox threads") return "Successfully archived all inbox threads" except Exception as error: logger.error(f"Error archiving all inbox threads: {error}") return f"Error archiving all inbox threads: {str(error)}"
- main.py:42-48 (registration)Dynamic registration of all twist_* functions from src.inbox and src.threads modules as MCP tools using FastMCP.tool() decorator, matching the tool name to the function name 'twist_inbox_archive_all'.# Register all tools from tool modules for module in [src.inbox, src.threads]: for name, func in inspect.getmembers(module, inspect.isfunction): if name.startswith('twist_') and func.__module__ == module.__name__: logger.info(f"Registering tool: {name}") mcp.tool()(func)