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."
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It implies a read-only diagnostic operation but doesn't disclose traits like whether it performs active tests, returns structured results, requires permissions, or has side effects, which is inadequate for a tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste, front-loading the core purpose without unnecessary elaboration. It's appropriately sized for a simple diagnostic tool with no parameters.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'diagnose' entails behaviorally, what results to expect, or how it differs from other check tools, leaving significant gaps for an agent to understand its use in context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so no parameter documentation is needed. The description doesn't add param details, but this is appropriate given the empty schema, warranting a baseline score above minimum viable.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Diagnose database access issues' clearly states the tool's purpose with a specific verb ('diagnose') and target ('database access issues'), avoiding tautology. However, it doesn't differentiate this diagnostic tool from other 'check' siblings like tool_check_addressbook or tool_check_contacts, leaving ambiguity about scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't specify prerequisites, context (e.g., after connection errors), or exclusions, nor does it reference sibling tools for comparison, leaving usage entirely implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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