Skip to main content
Glama
carterlasalle

mac-messages-mcp

tool_check_db_access

Diagnose database access issues for the macOS Messages app to identify and resolve connectivity problems.

Instructions

Diagnose database access issues.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler function for 'tool_check_db_access', decorated with @mcp.tool() for registration. It wraps the call to check_messages_db_access() with error handling and logging.
    @mcp.tool() def tool_check_db_access(ctx: Context) -> str: """ Diagnose database access issues. """ logger.info("Checking database access") try: return check_messages_db_access() except Exception as e: logger.error(f"Error checking database access: {str(e)}") return f"Error checking database access: {str(e)}"
  • The core helper function that checks Messages database accessibility, file existence, permissions, and table presence. Called by the tool handler.
    def check_messages_db_access() -> str: """Check if the Messages database is accessible and return detailed information.""" try: db_path = get_messages_db_path() status = [] # Check if the file exists if not os.path.exists(db_path): return f"ERROR: Messages database not found at {db_path} PLEASE TELL THE USER TO GRANT FULL DISK ACCESS TO THE TERMINAL APPLICATION(CURSOR, TERMINAL, CLAUDE, ETC.) AND RESTART THE APPLICATION. DO NOT RETRY UNTIL NEXT MESSAGE." status.append(f"Database file exists at: {db_path}") # Check file permissions try: with open(db_path, 'rb') as f: # Just try to read a byte to confirm access f.read(1) status.append("File is readable") except PermissionError: return f"ERROR: Permission denied when trying to read {db_path}. Please grant Full Disk Access permission to your terminal application. PLEASE TELL THE USER TO GRANT FULL DISK ACCESS TO THE TERMINAL APPLICATION(CURSOR, TERMINAL, CLAUDE, ETC.) AND RESTART THE APPLICATION. DO NOT RETRY UNTIL NEXT MESSAGE." except Exception as e: return f"ERROR: Unknown error reading file: {str(e)} PLEASE TELL THE USER TO GRANT FULL DISK ACCESS TO THE TERMINAL APPLICATION(CURSOR, TERMINAL, CLAUDE, ETC.) AND RESTART THE APPLICATION. DO NOT RETRY UNTIL NEXT MESSAGE." # Try to connect to the database try: conn = sqlite3.connect(db_path) status.append("Successfully connected to database") # Test a simple query cursor = conn.cursor() cursor.execute("SELECT count(*) FROM sqlite_master") count = cursor.fetchone()[0] status.append(f"Database contains {count} tables") # Check if the necessary tables exist cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name IN ('message', 'handle', 'chat')") tables = [row[0] for row in cursor.fetchall()] if 'message' in tables and 'handle' in tables: status.append("Required tables (message, handle) are present") else: status.append(f"WARNING: Some required tables are missing. Found: {', '.join(tables)}") conn.close() except sqlite3.OperationalError as e: return f"ERROR: Database connection error: {str(e)} PLEASE TELL THE USER TO GRANT FULL DISK ACCESS TO THE TERMINAL APPLICATION(CURSOR, TERMINAL, CLAUDE, ETC.) AND RESTART THE APPLICATION. DO NOT RETRY UNTIL NEXT MESSAGE." return "\n".join(status) except Exception as e: return f"ERROR: Unexpected error during database access check: {str(e)} PLEASE TELL THE USER TO GRANT FULL DISK ACCESS TO THE TERMINAL APPLICATION(CURSOR, TERMINAL, CLAUDE, ETC.) AND RESTART THE APPLICATION. DO NOT RETRY UNTIL NEXT MESSAGE."

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/carterlasalle/mac_messages_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server