delete_label
Remove a label from Google Keep by providing its unique ID.
Instructions
Delete a label by ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| label_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/server/cli.py:276-301 (handler)The actual handler function for the 'delete_label' MCP tool. It fetches the label, validates safe-mode constraints (cannot delete keep-mcp label or labels on unmanaged notes in safe mode), then calls keep.deleteLabel() and syncs.
@mcp.tool() def delete_label(label_id: str) -> str: """Delete a label by ID.""" keep = get_client() label = keep.getLabel(label_id) if not label: raise ValueError(f"Label with ID {label_id} not found") if not is_unsafe_mode(): if label.name == KEEP_MCP_LABEL: raise ValueError( f"Cannot delete the '{KEEP_MCP_LABEL}' label in safe mode: all notes managed " "by this server would become permanently unmodifiable. Set UNSAFE_MODE=true to override." ) unmanaged = [ n for n in keep.all() if any(lb.id == label_id for lb in n.labels.all()) and not has_keep_mcp_label(n) ] if unmanaged: raise ValueError( f"Cannot delete label '{label.name}' in safe mode: it is attached to " f"{len(unmanaged)} unmanaged note(s). Deleting it would silently modify " "those notes. Set UNSAFE_MODE=true to override." ) keep.deleteLabel(label_id) keep.sync() return json.dumps({"message": f"Label {label_id} marked for deletion"}) - src/server/cli.py:276-276 (registration)The 'delete_label' function is registered as an MCP tool via the @mcp.tool() decorator on line 276.
@mcp.tool() - src/server/cli.py:276-276 (schema)The type signature (label_id: str) -> str defines the input/output schema: accepts a single string label_id, returns a JSON string.
@mcp.tool() - src/server/keep_api.py:107-135 (helper)Helper functions used by delete_label: is_unsafe_mode() checks env var, has_keep_mcp_label() checks if a note has the keep-mcp label, KEEP_MCP_LABEL constant.
def is_unsafe_mode() -> bool: return os.getenv('UNSAFE_MODE', '').lower() == 'true' def can_modify_note(note): """ Check if a note can be modified based on label and environment settings. Args: note: A Google Keep note object Returns: bool: True if the note can be modified, False otherwise """ return is_unsafe_mode() or has_keep_mcp_label(note) def has_keep_mcp_label(note): """ Check if a note has the keep-mcp label. Args: note: A Google Keep note object Returns: bool: True if the note has the keep-mcp label, False otherwise """ return any(label.name == KEEP_MCP_LABEL for label in note.labels.all())