MDZip

v0.3.0
io.github.mdzip-project/mcp-server Checked 14 hours ago Published 1 day ago

Read, search and edit MDZip (.mdz) documents: Markdown plus its images in one file.

A standalone MCP server that lets AI tools read, search and edit MDZip (.mdz) documents: Markdown plus its images in one file. It runs locally over stdio and needs only Node.js 20 or later. You don't need VS Code, Obsidian or MDZip Studio. It offers the same tools as the MCP server bundled with the MDZip VS Code extension, plus a tool to find archives, folder limits, a read-only mode and size limits. To run a build from source instead (npm install, then npm run build), use "command": "node" with "args": ["/dist/mdzip-mcp-server.js"].

Summary extracted from the README.

MDZip MCP Server

A standalone MCP server that lets AI tools read, search and edit MDZip (.mdz) documents: Markdown plus its images in one file. It runs locally over stdio and needs only Node.js 20 or later. You don't need VS Code, Obsidian or MDZip Studio.

It offers the same tools as the MCP server bundled with the MDZip VS Code extension, plus a tool to find archives, folder limits, a read-only mode and size limits.

Set up a client

Most clients take this configuration:

{
  "mcpServers": {
    "MDZip": {
      "command": "npx",
      "args": ["-y", "@mdzip/mcp-server"]
    }
  }
}

To run a build from source instead (npm install, then npm run build), use "command": "node" with "args": ["<path to>/dist/mdzip-mcp-server.js"].

Claude Desktop extension

Download mdzip.mcpb and install it in Claude Desktop: open Settings → Desktop app → Extensions and drag the file onto the page. Then click Configure on the extension and turn it on; it stays off until you do. Claude Desktop runs it with its own Node.js, so you don't need Node installed. When you install it, choose the folders it may use (Documents by default), whether it's read-only, and the size limit. You can change them later in the extension's settings.

Build it from source with npm run build:mcpb (writes dist/mdzip.mcpb, from mcpb/manifest.json).

Claude Code, Codex and ChatGPT plugin

This repo is also a plugin marketplace for Claude Code, Codex and the ChatGPT desktop app. The mdzip plugin (plugin/) adds the server, pinned to the current release.

Claude Code:

claude plugin marketplace add mdzip-project/mdzip-mcp
claude plugin install mdzip@mdzip-project

Codex and the ChatGPT desktop app: run codex plugin marketplace add mdzip-project/mdzip-mcp, then install MDZip from the app's Plugins directory.

The plugin can't take --root or --read-only; for those, add the server yourself as above.

Limit it to folders

Add --root <folder> to restrict the server to files inside that folder. Repeat it for more folders:

"args": ["-y", "@mdzip/mcp-server", "--root", "/Users/me/Documents/notes", "--root", "/Users/me/projects"]

--roots <folder>... does the same for every folder up to the next option (--roots /Users/me/Documents/notes /Users/me/projects), for clients that pass a list of folders as separate arguments.

With --root:

  • every archive, and every file copied in with sourcePath, must be inside one of the folders, or the call fails with PATH_OUTSIDE_ROOTS;
  • relative paths resolve against the first folder;
  • links are followed before the check, so a link inside a folder can't reach a file outside it;
  • the server tells the AI tool which folders it may use when it connects.

Without --root, the server can use any file the user running it can reach, and relative paths resolve against the folder the client starts it in.

Read-only

Add --read-only to offer only the tools that read. The four write tools aren't listed, and a call to one fails with READ_ONLY without changing anything.

Size limits

The server loads whole archives into memory, so it refuses, with TOO_LARGE:

  • an archive larger than 100 MB, or one that unpacks to more than 10 times that (1 GB);
  • a file copied in with sourcePath, or content passed inline, larger than 100 MB;
  • a write whose resulting archive would be larger than 100 MB (the archive is left as it was).

Change the limit with --max-file-mb <n>; the unpacked limit stays 10 times it.

Other options: --help, --version.

Tools

Tool What it does
mdz_find_archives Find .mdz files in a folder and its subfolders (all --root folders by default)
mdz_review_document Best first call: the main Markdown document, its images, and a content hash for safe writes
mdz_list_entries Every file in the archive, optionally with hashes
mdz_search_text Search text files in the archive (plain text or regex)
mdz_read_text Read one text file
mdz_read_image Read one image
mdz_read_markdown_embedded_images Markdown with its images inlined as data URLs
upsert_canonical_document Replace the main document; refused if it changed since it was read
mdz_create_archive Create a new, validated .mdz from files
mdz_write_entry Add or replace any file in an archive
mdz_remove_entry Remove a file from an archive

Write tools check a hash from your last read and refuse to overwrite changes made elsewhere. Archives are written to a temporary file beside them and then swapped in, so a crash or full disk mid-write leaves the old archive whole. Writing through a link updates the file it points to, and on macOS and Linux the archive keeps its permissions. Each tool is marked read or write (readOnlyHint, destructiveHint), so clients can ask before writes.

Images

mdz_read_image and mdz_review_document return PNG, JPEG, GIF and WebP images as they are. Most AI clients can't show other image formats, so:

  • SVG comes back as its source text (exact labels, colours and sizes) plus a PNG rendering (layout, overlaps, clipping). The PNG is 800 to 1568 px on its longest side, on a white background. Text is drawn in the bundled Noto Sans font, whatever font the SVG names. Rendering can't read files or the network, so an SVG's links to outside images are left out. Source over 64 KB is cut off in the text; mdz_read_text returns all of it.
  • AVIF and ICO come back as a note with their size, and no image.

The renderer is resvg compiled to WebAssembly and bundled into the server, so it works the same on every platform and installs nothing extra.

mdz_find_archives skips hidden folders and node_modules, doesn't follow links, searches 6 levels deep by default, and returns at most 100 archives by default. Without --root it needs a folder.

Development

npm install
npm run typecheck
npm test        # builds dist/mdzip-mcp-server.js, then runs the stdio smoke test and the mdzip-mcp-only tests

A release goes to npm, to GitHub, to the MCP Registry (from server.json, published by a workflow when a GitHub release is published, after the version is on npm) , to the plugins in plugin/, and to the Claude Desktop extension (mdzip.mcpb, built and attached to the GitHub release by a workflow), and all of them carry the version: package.json, both version fields in server.json, the plugin manifests' version, the pinned package in plugin/.mcp.json and plugin/mcp.json, and version in mcpb/manifest.json. npm test fails until they agree.

Code shared with mdzip-vscode

src/mdzToolHandlers.ts, src/mdzMcpServer.ts, tests/mcp-smoke.cjs and media/templates/embedded-agent-guide.md are copies of the same files in mdzip-vscode, taken from commit a9081c4 (files last changed in da62294). Until a later refactor makes the extension use this package, a fix to the tools has to be made in both repos. Lines that differ on purpose are marked [mdzip-mcp]. Code that exists only here sits in its own files (src/cli.ts, src/roots.ts, src/discovery.ts, src/limits.ts, src/atomicWrite.ts, src/imageContent.ts, src/serverTools.ts and tests/*.test.cjs), and mdzToolHandlers.ts stays as close to the original as possible: serverTools.ts adds mdz_find_archives, --root, --read-only and the size limits around the copied handlers. The changes inside them: the four fs.writeFile calls that save an archive call writeFileAtomic instead, and mdz_read_image and mdz_review_document build their image blocks with imageEntryContent (SVG as source + PNG). mdzip-vscode still sends SVG, AVIF and ICO as image blocks the model can't view. To check for drift:

git -C ../mdzip-vscode diff a9081c4 origin/main -- src/mdzToolHandlers.ts src/mdzMcpServer.ts tests/mcp-smoke.cjs media/templates/embedded-agent-guide.md

See docs/phase-0-inventory.md for the plan.

License

Apache-2.0. The published server bundles its dependencies; their licenses are in dist/THIRD_PARTY_NOTICES.md.