create_note
Create a new Markdown note in Nextcloud Notes with optional category organization for structured storage.
Instructions
Create a new Markdown (.md) note.
- If category is None → stored in /Notes/<filename>
- If category is provided → stored in /Notes/<category>/<filename>
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | ||
| content | Yes | ||
| category | No |
Implementation Reference
- nextcloud_notes_mcp/server.py:140-162 (handler)The handler function for the 'create_note' tool. It creates a new Markdown note in Nextcloud via WebDAV, optionally in a category folder, using a temporary local file for upload.@mcp.tool() def create_note(filename: str, content: str, category: str | None = None) -> str: """ Create a new Markdown (.md) note. - If category is None → stored in /Notes/<filename> - If category is provided → stored in /Notes/<category>/<filename> """ # Determine full paths if category: full_dir = f"/Notes/{category}" full_path = f"{full_dir}/{filename}" _ensure_remote_dir(full_dir) else: full_path = f"/Notes/{filename}" tmp_path = os.path.join(tempfile.gettempdir(), next(tempfile._get_candidate_names()) + ".tmp") with open(tmp_path, "w", encoding="utf-8") as f: f.write(content) client.upload_sync(remote_path=full_path, local_path=tmp_path) os.remove(tmp_path) return f"Note created successfully: {full_path}"