tool_get_chats
Retrieve and list available group chats from the macOS Messages app using a Python bridge for efficient message management and integration.
Instructions
List available group chats from the Messages app.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mac_messages_mcp/server.py:160-189 (handler)Handler function for 'tool_get_chats' that queries the Messages database for group chats with display names, filters and formats them for listing.@mcp.tool() def tool_get_chats(ctx: Context) -> str: """ List available group chats from the Messages app. """ logger.info("Getting available chats") try: query = "SELECT chat_identifier, display_name FROM chat WHERE display_name IS NOT NULL" results = query_messages_db(query) if not results: return "No group chats found." if "error" in results[0]: return f"Error accessing chats: {results[0]['error']}" # Filter out chats without display names and format the results chats = [r for r in results if r.get('display_name')] if not chats: return "No named group chats found." formatted_chats = [] for i, chat in enumerate(chats, 1): formatted_chats.append(f"{i}. {chat['display_name']} (ID: {chat['chat_identifier']})") return "Available group chats:\n" + "\n".join(formatted_chats) except Exception as e: logger.error(f"Error getting chats: {str(e)}") return f"Error getting chats: {str(e)}"