Skip to main content
Glama
netologist

Bear Notes MCP Server

by netologist

find_notes_by_title

Search for notes in Bear App by title, using exact or partial matching to quickly locate specific content.

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
NameRequiredDescriptionDefault
title_queryYes
exact_matchNo

Implementation Reference

  • main.py:308-367 (handler)
    The handler function that implements the core logic of the 'find_notes_by_title' tool. It connects to the Bear App database, executes SQL queries for exact or partial title matching, processes results into structured dictionaries with previews, and handles exceptions.
    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)}"}]
  • main.py:307-307 (registration)
    The @mcp.tool() decorator registers the find_notes_by_title function as an MCP tool, making it available via the FastMCP server.
    @mcp.tool()
  • main.py:19-26 (helper)
    Helper function used by the tool to create a SQLite connection to the Bear App database with row_factory enabled for dictionary-like row access.
    def get_bear_db_connection():
        """Connect to Bear database"""
        if not os.path.exists(BEAR_DB_PATH):
            raise FileNotFoundError(f"Bear database not found: {BEAR_DB_PATH}")
        
        conn = sqlite3.connect(BEAR_DB_PATH)
        conn.row_factory = sqlite3.Row  # Enable column name access
        return conn

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/netologist/mcp-bear-notes'

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