pin_note
Change the pinned status of a note to keep important notes accessible at the top of your list.
Instructions
Pin or unpin a note.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note_id | Yes | ||
| pinned | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/server/cli.py:204-212 (handler)The pin_note tool handler function: retrieves the note, validates it is modifiable, sets pinned status, syncs, and returns serialized note.
@mcp.tool() def pin_note(note_id: str, pinned: bool = True) -> str: """Pin or unpin a note.""" keep, note = _get_note_or_raise(note_id) _ensure_modifiable(note) note.pinned = pinned keep.sync() return json.dumps(serialize_note(note)) - src/server/cli.py:204-204 (registration)Registration via @mcp.tool() decorator on the pin_note function, making it an MCP tool named 'pin_note'.
@mcp.tool() - src/server/cli.py:205-205 (schema)Schema/parameters: note_id (str, required) and pinned (bool, default True) define the input contract.
def pin_note(note_id: str, pinned: bool = True) -> str: - src/server/keep_api.py:71-105 (helper)The serialize_note helper function used by pin_note to convert the note object into a JSON-serializable dict (including the 'pinned' field).
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 - src/server/cli.py:17-22 (helper)The _get_note_or_raise helper used to fetch the note by ID or raise an error.
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