remove_label_from_note
Removes a label from a Google Keep note. Provide the note ID and label ID to detach the label.
Instructions
Remove a label from a note.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note_id | Yes | ||
| label_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/server/cli.py:319-336 (handler)The main handler function for the 'remove_label_from_note' MCP tool. It retrieves the note by ID, ensures the note is modifiable, looks up the label by ID (raising an error if not found), protects the 'keep-mcp' label in safe mode, removes the label from the note, syncs with Google Keep, and returns the updated note as JSON.
@mcp.tool() def remove_label_from_note(note_id: str, label_id: str) -> str: """Remove a label from a note.""" keep, note = _get_note_or_raise(note_id) _ensure_modifiable(note) label = keep.getLabel(label_id) if not label: raise ValueError(f"Label with ID {label_id} not found") if label.name == KEEP_MCP_LABEL and not is_unsafe_mode(): raise ValueError( f"Cannot remove the '{KEEP_MCP_LABEL}' label in safe mode: the note would " "become permanently unmodifiable. Set UNSAFE_MODE=true to override." ) note.labels.remove(label) keep.sync() return json.dumps(serialize_note(note)) - src/server/cli.py:17-22 (helper)Helper that fetches a note by ID using the Keep client, raising ValueError if not found. Returns both the client and the note.
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/cli.py:25-30 (helper)Helper that checks if a note is modifiable (has keep-mcp label or UNSAFE_MODE is enabled), raising ValueError if not.
def _ensure_modifiable(note): if not can_modify_note(note): raise ValueError( f"Note with ID {note.id} cannot be modified " "(missing keep-mcp label and UNSAFE_MODE is not enabled)" ) - src/server/keep_api.py:107-108 (helper)Helper that checks the UNSAFE_MODE environment variable to determine if safety restrictions should be bypassed.
def is_unsafe_mode() -> bool: return os.getenv('UNSAFE_MODE', '').lower() == 'true' - src/server/keep_api.py:71-105 (helper)Serializes a note object into a dictionary (id, title, text, type, pinned, archived, trashed, color, labels, collaborators, items, media) for JSON response.
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