get_my_info
Retrieve your iMessage self-handles and chat database metadata to verify your identity and data integrity.
Instructions
Return self-handles and chat.db metadata for sanity checks.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/imessage_mcp/db.py:280-305 (handler)Core handler function that queries chat.db for the user's own handles (destination_caller_id and account_login), total message count, earliest message date, and DB path.
def get_my_info() -> dict[str, Any]: with _open() as conn: handles = [ r[0] for r in conn.execute( "SELECT DISTINCT destination_caller_id FROM message WHERE destination_caller_id IS NOT NULL AND destination_caller_id != ''" ).fetchall() ] login_rows = [ r[0] for r in conn.execute( "SELECT DISTINCT account_login FROM chat WHERE account_login IS NOT NULL AND account_login != ''" ).fetchall() ] for h in login_rows: h_clean = h.replace("E:", "").replace("P:", "") if h_clean and h_clean not in handles: handles.append(h_clean) total = conn.execute("SELECT COUNT(*) FROM message").fetchone()[0] earliest = conn.execute("SELECT MIN(date) FROM message WHERE date > 0").fetchone()[0] return { "my_handles": handles, "db_path": str(DB_PATH), "messages_count": total, "earliest_date": apple_ts_to_iso(earliest), } - src/imessage_mcp/server.py:61-64 (registration)MCP tool registration decorator that exposes get_my_info as a tool, delegating to db.get_my_info().
@mcp.tool() def get_my_info() -> dict[str, Any]: """Return self-handles and chat.db metadata for sanity checks.""" return db.get_my_info() - src/imessage_mcp/handles.py:9-22 (helper)Helper function that converts Apple epoch timestamps to ISO8601 strings, used for the earliest_date field.
def apple_ts_to_iso(apple_ts: int | None) -> str | None: """Convert Apple Core Data timestamp to ISO8601 UTC string. Newer macOS stores date as nanoseconds since 2001-01-01 UTC. Older rows stored plain seconds. Heuristic: values > 1e11 are nanoseconds. """ if apple_ts is None or apple_ts == 0: return None if apple_ts > 10**11: unix_ts = apple_ts / 1_000_000_000 + APPLE_EPOCH_OFFSET else: unix_ts = apple_ts + APPLE_EPOCH_OFFSET return datetime.fromtimestamp(unix_ts, tz=timezone.utc).isoformat()