Commit Graph

16 Commits

Author SHA1 Message Date
bea 2cb1666441 feat(ncmcp): enhanced CLI wrapper with positional args, stdin, @file, --curl
Step 9 of file management plan:

- Positional path: ncmcp read_file /Documents/file.txt (equiv to path=/...)
- stdin content: echo 'hello' | ncmcp upload_file path=/test.txt
- @file for upload: ncmcp upload_file path=/remote.txt @./local.txt (base64)
- @file for bulk_upload: ncmcp bulk_upload @./files.json
- --curl flag: ncmcp download_file path=/file --curl prints curl cmd
- Updated help text with all 21+ file tools
- Full tool list in --help output
- Backward compatible: key=value syntax unchanged
2026-05-11 17:28:46 +02:00
bea 40ced0f336 fix: remove duplicate handler implementations from parallel merge 2026-05-11 17:11:16 +02:00
bea f87c82d36e Step 8: add set_favorite, get_file_versions, restore_file_version tools
- set_favorite: PROPPATCH oc:favorite + PROPFIND for updated metadata
- get_file_versions: PROPFIND on /versions/{user}/versions/{fileId}
- restore_file_version: MOVE to /versions/{user}/restore
- Uses existing webdav helpers (buildProppatchBody, buildVersionsPropfindBody, parseVersionsResponse)
2026-05-11 17:09:58 +02:00
bea 66112abe9c feat(files): add trashbin tools (Step 7) — trash_list, trash_restore, trash_delete, trash_empty
Also includes uncommitted changes from parallel subagents (Steps 6, 8).
2026-05-11 17:09:39 +02:00
bea ade15a6f6d feat(files): add chunked upload tools (start/chunk/finish)
Step 5 — Chunked Upload for large files:
- chunked_upload_start: creates upload session with UUID, MKCOL /uploads/{user}/{uuid}
- chunked_upload_chunk: uploads base64-encoded chunks (1-based, 5-digit padded)
- chunked_upload_finish: MOVE .file to assemble, returns FileMetadata

State: in-memory Map<string, ChunkedUploadSession>, not persistent (server expires 24h)
2026-05-11 17:05:04 +02:00
bea dff7db507d feat(files): Step 4 — add upload_file, create_folder, bulk_upload tools
- upload_file: PUT request with utf8/base64 encoding, auto MIME detection, X-OC-Mtime support
- create_folder: MKCOL request with 405 (already exists) error handling
- bulk_upload: POST multipart/related with manual body construction for multi-file upload
- All tools return FileMetadata/BulkUploadResult via PROPFIND after operation
2026-05-11 17:01:25 +02:00
bea 46e9ca752d Step 3: Add read_file, download_file, download_folder tools
- read_file: GET file content inline (utf8 for text, base64 for binary)
  with configurable maxSize (default 10MB) to stay within MCP transport limits
- download_file: returns direct download URL for out-of-band fetching
  with optional HEAD metadata
- download_folder: GET folder as ZIP/TAR archive, returns inline base64
  if under maxSize (default 50MB), otherwise returns download URL
  with optional X-NC-Files header for selective download
2026-05-11 16:53:15 +02:00
bea e92215fd3e feat(tools): implement Browsing & Discovery tools (Step 2)
Add 5 file management tools to src/tools/files.ts:
- list_files: PROPFIND with depth control (0/1/infinity)
- get_file_info: PROPFIND Depth:0 with extended properties (owner, preview, checksums)
- search_files: WebDAV SEARCH with PROPFIND fallback + client-side filtering
- list_favorites: REPORT with oc:filter-files
- get_quota: PROPFIND for quota-used-bytes / quota-available-bytes

search_files tries WebDAV SEARCH first; if the server lacks Full Text Search,
falls back to PROPFIND Depth:infinity with client-side filtering by name,
mimeType (wildcard), size range, date range, and favorite status.
Sorting and limit are applied after filtering.
2026-05-11 15:04:55 +02:00
bea ce477546a1 Fix search: add username param, fix scope path, add sortBy property mapping
- buildSearchRequest now accepts username parameter for correct scope
- Fix double-slash in scope path when path='/'
- Map sortBy names to correct XML namespaces (size→oc:size, etc.)
- Sort property mapping for: name, size, lastModified, created, favorite
2026-05-11 14:54:47 +02:00
bea 73d96b9902 Step 1: complete webdav.ts — XML builders + parsers for file operations
- All PROPFIND builders (standard, extended, trashbin, versions, quota)
- PROPPATCH builder for property updates (favorites)
- REPORT builder for favorite filtering
- SEARCH builder (rfc5323) with dynamic where-clause construction
- All response parsers (files, single file, search, trashbin, versions, quota)
- Helper extractors for properties, booleans, numerics
- Namespace handling for both prefixed and unprefixed XML tags
2026-05-11 14:08:23 +02:00
bea 84c5bdd90e refactor: modularize codebase — Step 0 structural refactoring
Extract monolithic index.ts (~600 lines) into focused modules:
- src/types.ts — shared TypeScript interfaces (FileMetadata, QuotaInfo, etc.)
- src/utils.ts — path, mime detection, formatting helpers
- src/client.ts — NextcloudClient wrapping axios with WebDAV primitives
- src/webdav.ts — XML builders + parsers (scaffolding for file tools)
- src/tools/index.ts — ToolModule interface + auto registry
- src/tools/calendar.ts — extracted calendar tools
- src/tools/tasks.ts — extracted task tools
- src/tools/notes.ts — extracted note tools
- src/tools/email.ts — extracted email tools
- src/tools/files.ts — empty scaffolding for upcoming file management tools

src/index.ts reduced to ~50 lines: config, client instantiation, module registration, MCP setup.

Zero regression on existing tools. Verified: list_calendars, get_notes, create_note, get_note_content all functional.
2026-05-11 13:43:36 +02:00
bea d308d8375e Add ncmcp.mjs CLI wrapper 2026-05-11 02:38:22 +02:00
bea dd32492831 fix build 2026-03-09 17:03:25 +01:00
bea f114308447 update caldav 2026-03-09 16:57:33 +01:00
Jules Grinnell 7da30ae044 Clean git move from play 2025-11-23 16:44:05 +01:00
Jules f0331de014 Initial commit 2025-11-23 16:35:57 +01:00