Skip to main content
Glama

get_note_by_id

Retrieve a specific note from Bear Notes using its unique identifier to access individual content directly through the MCP Bear server.

Instructions

Get a specific note by its unique identifier

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
note_idYesThe unique identifier of the note (ZUNIQUEIDENTIFIER)

Implementation Reference

  • The implementation of the get_note_by_id logic, which queries the SQLite database for a note matching the given ID.
    def get_note_by_id(note_id: str) -> dict[str, Any] | None:
        """
        Get a specific note by its unique identifier.
    
        Args:
            note_id: The unique identifier of the note (ZUNIQUEIDENTIFIER)
    
        Returns:
            Note dictionary or None if not found
        """
        db_path = get_bear_db_path()
        conn = sqlite3.connect(db_path)
        conn.row_factory = sqlite3.Row
        cursor = conn.cursor()
    
        try:
            cursor.execute(
                "SELECT * FROM ZSFNOTE WHERE ZUNIQUEIDENTIFIER=?;",
                (note_id,)
            )
            row = cursor.fetchone()
    
            if row:
                return {
                    "ZCREATIONDATE": row["ZCREATIONDATE"],
                    "ZMODIFICATIONDATE": row["ZMODIFICATIONDATE"],
                    "ZARCHIVED": row["ZARCHIVED"],
                    "ZSUBTITLE": row["ZSUBTITLE"],
                    "ZTEXT": row["ZTEXT"],
                    "ZTITLE": row["ZTITLE"],
                    "ZUNIQUEIDENTIFIER": row["ZUNIQUEIDENTIFIER"],
                }
            return None
        finally:
            conn.close()
  • Registration of the get_note_by_id tool in the MCP server's list_tools definition.
        name="get_note_by_id",
        description="Get a specific note by its unique identifier",
        inputSchema={
            "type": "object",
            "properties": {
                "note_id": {
                    "type": "string",
                    "description": "The unique identifier of the note (ZUNIQUEIDENTIFIER)",
                },
            },
            "required": ["note_id"],
        },
    ),
  • The handler in the MCP server's call_tool function that processes the get_note_by_id tool invocation and calls the database function.
    elif name == "get_note_by_id":
        if not isinstance(arguments, dict) or "note_id" not in arguments:
            raise ValueError("Missing required argument: note_id")
    
        note = get_note_by_id(note_id=arguments["note_id"])
        if note:
            return [TextContent(type="text", text=str({"note": note}))]
        else:
            return [TextContent(type="text", text=str({"error": "Note not found"}))]

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/maxim-ist/mcp-bear'

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