Skip to content

zn mcp: expose asset operations (upload/rename/move/delete) as tools — the server API already implements them #34

Closed

Description

@Asterythm

Summary

zn mcp currently exposes only a read-only list_assets tool, while the znserver HTTP API already implements a full asset mutation family (upload, rename, move, duplicate, delete, restore, purge). Assistants connected over MCP therefore cannot manage attachments at all, even though desktop and web clients can.

What I measured

zn mcp v0.15.0 tools/list returns 34 tools; the only asset tool is:

  • list_assets — "List files under the vault's attachments directory (images, PDFs, audio, video, other binaries)". No parameters, read-only.

Same result on 0.8.0, so this isn't a recent regression — the mutation tools have never existed.

Meanwhile znserver (internal/httpserver/server.go, verified against self-hosted 2.80.1) routes:

GET  /api/assets
GET  /api/assets/exists
GET  /api/assets/raw
POST /api/assets/upload      (multipart: file, optional notePath)
POST /api/assets/rename
POST /api/assets/move
POST /api/assets/duplicate
POST /api/assets/delete      (soft delete, returns undoToken)
GET  /api/assets/deleted
POST /api/assets/restore
POST /api/assets/purge
POST /api/assets/empty-deleted

I verified upload/read-back/delete/restore against a live 2.80.1 server. Upload already returns exactly what an assistant needs next:

{"path":"assets/plot.png","markdown":"![[assets/plot.png]]","kind":"image"}

i.e. the wikilink to insert into the note body.

Use case

MCP is the primary integration surface for coding assistants and agents. They routinely need to attach generated plots, diagrams, PDFs, or audio to notes. Today the only programmatic path is direct filesystem access to the vault directory, which remote MCP clients (cloud-hosted agents talking to a znserver over the network) don't have — the HTTP API above is their only channel, and zn mcp doesn't proxy it.

Proposal

Expose the server's asset ops as MCP tools, e.g.:

  • upload_asset({filename, content_base64, notePath?}) → {path, markdown}
  • rename_asset({path, name}), move_asset({path, targetDir}), duplicate_asset({path})
  • delete_asset({path}) / restore_asset({...}) (soft delete + undo, mirroring the API)
  • optionally read_asset({path}) for small assets

Since 2.80 added path-level ACL flags to zn mcp (--allow-path, --read-only, …), the mutation tools could respect the same flags so read-only setups stay read-only.

Happy to provide more traces if useful — and thanks for the great tool.

Activity

  1. adibhanna commented on Nov 4, 2026

    @adibhanna
    Contributor

    Thanks @Asterythm for the clear report and the traces. zn mcp can now manage attachments, merged in 06ca624 and shipping in the next zn release.

    New tools: upload_asset, read_asset, rename_asset, move_asset, duplicate_asset, delete_asset and restore_asset, and list_assets with deleted: true shows what can be restored. Upload returns the path and embed you asked for, up to 16 MiB. Renames and moves update the notes that link to the file.

    A few choices worth knowing. Deletes are soft, and permanent deletion isn't exposed, so it stays in the app. The tools honor --allow-path, --deny-path, --read-only and --access. A client limited by paths on a server can list, upload, delete and restore, but can't read, copy, rename or move files. upload_asset needs the assets folder shared. notePath isn't included, because the server ignores it; paste the returned markdown into the note instead.

    The desktop app's bundled MCP server doesn't have these tools yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions