get_recent_notes
Retrieve recently modified notes from Bear App by specifying how many days to look back and the maximum number of results to return.
Instructions
Get recently modified notes
Args: days: Number of days to look back limit: Maximum number of results
Returns: Recently modified notes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | ||
| limit | No |
Implementation Reference
- main.py:369-426 (handler)The handler function for the 'get_recent_notes' MCP tool. It connects to the Bear App SQLite database, calculates the timestamp for notes modified in the specified number of days, queries the ZSFNOTE table for non-trashed notes modified since then, formats the results with metadata including preview and word count, and handles errors.@mcp.tool() def get_recent_notes(days: int = 7, limit: int = 20) -> List[Dict[str, Any]]: """ Get recently modified notes Args: days: Number of days to look back limit: Maximum number of results Returns: Recently modified notes """ try: conn = get_bear_db_connection() # Calculate timestamp for N days ago # Bear uses Core Data timestamps (seconds since 2001-01-01) import time import datetime now = datetime.datetime.now() days_ago = now - datetime.timedelta(days=days) # Convert to Core Data timestamp core_data_epoch = datetime.datetime(2001, 1, 1) timestamp = (days_ago - core_data_epoch).total_seconds() cursor = conn.execute(""" SELECT ZUNIQUEIDENTIFIER as id, ZTITLE as title, ZTEXT as content, ZCREATIONDATE as created_date, ZMODIFICATIONDATE as modified_date FROM ZSFNOTE WHERE ZTRASHED = 0 AND ZMODIFICATIONDATE > ? ORDER BY ZMODIFICATIONDATE DESC LIMIT ? """, (timestamp, limit)) results = [] for row in cursor.fetchall(): content = row["content"] or "" results.append({ "id": row["id"], "title": row["title"] or "Untitled", "content": content, "created_date": row["created_date"], "modified_date": row["modified_date"], "preview": content[:200] + "..." if len(content) > 200 else content, "word_count": len(content.split()) if content else 0 }) conn.close() return results except Exception as e: return [{"error": f"Error getting recent notes: {str(e)}"}]