add_label_to_note
Attach a label to a note by specifying both the note ID and the label ID.
Instructions
Add a label to 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:304-316 (handler)The MCP tool handler that adds a label to a note. It looks up the note and label by ID, ensures the note is modifiable, then adds the label and syncs.
@mcp.tool() def add_label_to_note(note_id: str, label_id: str) -> str: """Add a label to 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") note.labels.add(label) keep.sync() return json.dumps(serialize_note(note)) - src/server/cli.py:303-304 (registration)The @mcp.tool() decorator registers add_label_to_note as an MCP tool.
@mcp.tool() - src/server/cli.py:17-22 (helper)Helper function used by add_label_to_note to fetch the note and client, raising if note 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/cli.py:25-31 (helper)Helper function used by add_label_to_note to verify the note is modifiable (has keep-mcp label or UNSAFE_MODE is enabled).
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)" )