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
| Name | Required | Description | Default |
|---|---|---|---|
| note_id | Yes | The unique identifier of the note (ZUNIQUEIDENTIFIER) |
Implementation Reference
- src/mcp_bear/database.py:102-136 (handler)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() - src/mcp_bear/server.py:202-214 (registration)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"], }, ), - src/mcp_bear/server.py:376-385 (handler)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"}))]