twist_inbox_get_count
Retrieve the current count of unread messages in your Twist workspace inbox to monitor pending conversations.
Instructions
Gets inbox count in a workspace for the authenticated user.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/inbox.py:173-200 (handler)Handler function that retrieves the inbox count for the workspace using the Twist API.def twist_inbox_get_count( ctx: Context ) -> Union[str, dict]: """Gets inbox count in a workspace for the authenticated user. """ 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} try: logger.info(f"Getting inbox count for workspace ID: {workspace_id}") count_data = twist_request("inbox/get_count", params=params, token=token) if not count_data: logger.info("Failed to get inbox count") return "Failed to get inbox count" logger.info(f"Retrieved inbox count: {count_data}") return count_data except Exception as error: logger.error(f"Error getting inbox count: {error}") return f"Error getting inbox count: {str(error)}"
- main.py:42-48 (registration)Dynamically registers all functions starting with 'twist_' from src.inbox and src.threads modules as MCP tools, including twist_inbox_get_count.# 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)