Skip to main content
Glama
morz-mcp

morz-mcp

by cumany
README.md
# morz-mcp

A local [Model Context Protocol](https://modelcontextprotocol.io/) server that exposes a
folder of Markdown notes (a Morz vault) to AI clients over stdio.

- Works with any MCP-capable client that can launch a local process.
- Reads and writes ordinary `.md` files; the Morz desktop app is optional.
- No network service, no port, no account, no API key.
- Requires Node.js **22.18+**.

## Install

### Single-file bundle (no npm)

Download `morz-mcp.mjs` from [Releases](https://github.com/cumany/morz-mcp/releases) once a
release is published, or build it from source:

```bash
npm ci
npm run bundle
node bundle/morz-mcp.mjs --vault "D:/Notes"
```

Point the client at the file:

```json
{
  "mcpServers": {
    "morz": {
      "command": "node",
      "args": ["D:/path/to/morz-mcp.mjs", "--vault", "D:/Notes"]
    }
  }
}
```

### npm

Once the package is published:

```bash
npx -y morz-mcp@0.1.0 --vault "D:/Notes"
```

```json
{
  "mcpServers": {
    "morz": {
      "command": "npx",
      "args": ["-y", "morz-mcp@0.1.0", "--vault", "D:/Notes"]
    }
  }
}
```

This speaks MCP on stdio, so it looks silent when run in a terminal. Configure your client
to launch it instead of running it in a shell.

## Vault discovery

The server resolves the vault root in this order:

1. `--vault <folder>`
2. `MORZ_VAULT` environment variable
3. the manifest written by the Morz desktop app at
   `<appDataDir>/com.morz.editor/morz.json`

In Morz desktop, **Settings → General → MCP** only writes that manifest; it does not start
this server or open a port. The setting can be disabled, and the manifest is then cleared.
Using `--vault` makes the server independent of the desktop app.

## Tools

| Tool | Purpose |
|---|---|
| `list_vaults` | Known vaults and the active one |
| `list_notes` | Recursive Markdown notes (hidden/system folders excluded) |
| `read_note` | Read a note, returns `mtime` for optimistic concurrency |
| `write_note` | Create/overwrite a note; accepts `expectedMtime` |
| `append_to_note` | Append text; accepts `expectedMtime` |
| `delete_note` | Soft-delete into `.trash` (restorable in Morz) |
| `search_notes` | Substring search with title weighting and hit lines |
| `get_tags` | Tags with usage counts |
| `get_backlinks` | Notes linking to a note, with line numbers |
| `get_outgoing_links` | Wikilinks, embeds and internal Markdown links |
| `get_vault_stats` | Note count, size, word count, top tags, recent notes |
| `get_note_info` | Title, tags, mtime, outgoing/backlink counts |

Resources: `note:///<relative-path>`.

## Safety model

- **Path fence**: every path must stay inside the vault root; absolute paths, drive letters,
  UNC paths, `..` and NUL are rejected.
- **Optimistic concurrency**: pass `expectedMtime` from `read_note` when writing; if the file
  changed since the read, the write is refused and the current `mtime` is returned.
- **Soft delete**: `delete_note` moves to `.trash`; it never hard-deletes.
- **No auth**: this is a local stdio process. The client controls who can launch it.
- **Unsaved editor buffers are not visible**: the server reads files on disk. If the Morz
  editor has unsaved changes, save before asking an agent to edit the same note.

Not supported in v1: rename/move, daily-note templates, IndexedDB/browser libraries, Android
SAF workspaces, and cloud sync.

## Development

```bash
npm ci
npm test        # type check, build and the 15-check stdio smoke test
npm run bundle  # single-file build in bundle/
```

The smoke test creates a temporary vault and exercises the handshake, all 12 tools, the path
fence, the stale-write guard and editor-compatible trash. See [CONTRIBUTING.md](CONTRIBUTING.md).

## Links

- Morz: https://morz.app
- Web app: https://app.morz.app
- Docs: https://morz.app/docs
- Issues: https://github.com/cumany/morz-mcp/issues

## License

MIT. The Morz application itself is proprietary; this MCP server is a separate MIT-licensed
component (see [LICENSE](LICENSE)).