find_notes_by_title
Search and retrieve notes from the Bear App by specifying a title query. Choose between exact or partial title matching to filter results based on your criteria.
Instructions
Find notes by title
Args: title_query: Title text to search for exact_match: Whether to match title exactly or use partial matching
Returns: Notes matching the title criteria
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exact_match | No | ||
| title_query | Yes |
Implementation Reference
- main.py:307-368 (handler)The handler function decorated with @mcp.tool(), implementing the logic to query the Bear App SQLite database for notes matching the given title query, supporting both exact and partial matching. It returns a list of matching notes with metadata including ID, title, content preview, and timestamps.@mcp.tool() def find_notes_by_title(title_query: str, exact_match: bool = False) -> List[Dict[str, Any]]: """ Find notes by title Args: title_query: Title text to search for exact_match: Whether to match title exactly or use partial matching Returns: Notes matching the title criteria """ try: conn = get_bear_db_connection() if exact_match: sql = """ SELECT ZUNIQUEIDENTIFIER as id, ZTITLE as title, ZTEXT as content, ZCREATIONDATE as created_date, ZMODIFICATIONDATE as modified_date FROM ZSFNOTE WHERE ZTRASHED = 0 AND ZTITLE = ? ORDER BY ZMODIFICATIONDATE DESC """ params = [title_query] else: sql = """ SELECT ZUNIQUEIDENTIFIER as id, ZTITLE as title, ZTEXT as content, ZCREATIONDATE as created_date, ZMODIFICATIONDATE as modified_date FROM ZSFNOTE WHERE ZTRASHED = 0 AND ZTITLE LIKE ? ORDER BY ZMODIFICATIONDATE DESC """ params = [f"%{title_query}%"] cursor = conn.execute(sql, params) 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 }) conn.close() return results except Exception as e: return [{"error": f"Error searching by title: {str(e)}"}]