restore_note
Restore a deleted or trashed note by providing its unique note ID.
Instructions
Restore a trashed/deleted note.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/server/cli.py:237-246 (handler)The actual handler function for the 'restore_note' tool. It retrieves the note, ensures it's modifiable, calls untrash() and undelete() on the note, syncs with Google Keep, and returns the serialized note as JSON.
@mcp.tool() def restore_note(note_id: str) -> str: """Restore a trashed/deleted note.""" keep, note = _get_note_or_raise(note_id) _ensure_modifiable(note) note.untrash() note.undelete() keep.sync() return json.dumps(serialize_note(note)) - src/server/cli.py:237-237 (registration)The tool is registered with the MCP server using the @mcp.tool() decorator on the restore_note function. The FastMCP instance is created at line 14.
@mcp.tool() - src/server/cli.py:238-238 (schema)The function signature defines the input schema: restore_note takes a single string parameter 'note_id' and returns a string (JSON).
def restore_note(note_id: str) -> str: - src/server/cli.py:17-22 (helper)Helper function _get_note_or_raise: retrieves a note by ID from the Keep client, raising ValueError if not found.
def _get_note_or_raise(note_id: str): keep = get_client() note = keep.get(note_id) if not note: raise ValueError(f"Note with ID {note_id} not found") return keep, note - src/server/keep_api.py:71-105 (helper)Helper function serialize_note: serializes a Google Keep note object into a dictionary including id, title, text, trashed status, color, labels, and media.
def serialize_note(note): """ Serialize a Google Keep note into a dictionary. Args: note: A Google Keep note object Returns: dict: A dictionary containing the note's id, title, text, pinned status, color and labels """ payload = { 'id': note.id, 'title': note.title, 'text': note.text, 'type': note.type.value, 'pinned': note.pinned, 'archived': note.archived, 'trashed': note.trashed, 'color': note.color.value if note.color else None, 'labels': [serialize_label(label) for label in note.labels.all()], 'collaborators': list(note.collaborators.all()), } if hasattr(note, 'items'): payload['items'] = [serialize_list_item(item) for item in note.items] payload['media'] = [ { 'blob_id': blob.id, 'type': blob.blob.type.value if blob.blob and blob.blob.type else None, } for blob in note.blobs ] return payload