Add support for attachments in notes

This commit is contained in:
Chris Coutinho
2025-05-06 02:52:51 +02:00
parent 973caefb74
commit 04e4a8e0a8
21 changed files with 1493 additions and 6 deletions
+20
View File
@@ -108,6 +108,26 @@ def nc_notes_delete_note(note_id: int, ctx: Context):
return client.notes_delete_note(note_id=note_id)
@mcp.resource("nc://Notes/{note_id}/attachments/{attachment_filename}")
def nc_notes_get_attachment(note_id: int, attachment_filename: str):
"""Get a specific attachment from a note"""
ctx = mcp.get_context()
client: NextcloudClient = ctx.request_context.lifespan_context.client
# Assuming a method get_note_attachment exists in the client
# This method should return the raw content and determine the mime type
content, mime_type = client.get_note_attachment(note_id=note_id, filename=attachment_filename)
return {
"contents": [
{
# Use uppercase 'Notes' to match the decorator
"uri": f"nc://Notes/{note_id}/attachments/{attachment_filename}",
"mimeType": mime_type, # Client needs to determine this
"data": content, # Return raw bytes/data
}
]
}
def run():
mcp.run()