docmost-mcp-server
# docmost-mcp-server
[](https://charlesqing.github.io/docmost-mcp-server/)
Model Context Protocol server for self-hosted [Docmost](https://docmost.com) **Community / Open Source Edition**.
> **Fork notice:** This project is a fork of [dilruwanm/docmost-community-mcp](https://github.com/dilruwanm/docmost-community-mcp), developed and maintained by [charlesqing](https://github.com/charlesqing) at [charlesqing/docmost-mcp-server](https://github.com/charlesqing/docmost-mcp-server). It builds on the upstream MCP tool set and adds safety hardening (untrusted-content envelope, write-verification, markdown-loss hints, busy-page protection, `dry_run`) plus a Streamable HTTP transport, while staying dependency-light. Credit for the original design and implementation goes to the upstream authors; see [LICENSE](LICENSE) and [CHANGELOG](CHANGELOG.md).
Official Docmost MCP and API keys are Enterprise-only. This server talks to the same internal HTTP API the Docmost web app uses, so you can search, read, write, and organize a CE wiki from Cursor, Claude, or any MCP client.
Requires **Docmost v0.80.1+** for body writes (v0.80.1 fixed CVE-2026-48073, where a REST write could report success without persisting). Latest verified target is **v0.98.0 CE** (Docker `docmost:0.98.0`). Verified on 2026-11-29: 89 unit tests, 56 tools, 6 prompts, 2 resources, plus a 22-check live Streamable HTTP probe against v0.98.0. `format: "json"` writes round-trip ProseMirror attributes and block ids unchanged. See [Known limits](#known-limits) for what that probe does not cover.
Safety features borrowed from [docmost-mcp-remote](https://github.com/bbik52/docmost-mcp-remote), kept lightweight (zero new dependencies): wiki text is wrapped in an untrusted-content envelope, body writes are verified by re-reading, Markdown loss is reported, full replaces are refused if someone else just saved, and `dry_run` previews changes. Each is switchable via environment variables.
## Install
This fork is distributed from GitHub, not published to npm. Install from the repository:
```bash
npx -y github:charlesqing/docmost-mcp-server
```
Or clone and build (Node 20+):
```bash
git clone https://github.com/charlesqing/docmost-mcp-server.git
cd docmost-mcp-server
npm install # the prepare script compiles TypeScript into dist/
npm run build
```
## What you get
Official Enterprise MCP tool names, plus Community extras those docs omit.
**Pages (21):** `search_pages`, `get_page`, `create_page`, `update_page`, `edit_page`, `list_pages`, `list_child_pages`, `get_page_tree`, `duplicate_page`, `copy_page_to_space`, `move_page`, `move_page_to_space`, `delete_page`, `restore_page`, `list_trash`, `get_page_history`, `get_history_version`, `get_breadcrumbs`, `get_backlinks`, `get_backlinks_count`, `export_page`
**Spaces (10):** `list_spaces`, `get_space`, `create_space`, `update_space`, `delete_space`, `export_space`, `archive_space`, `unarchive_space`, `set_space_homepage`, `check_space_health`
**Comments (5):** `get_comments`, `create_comment`, `update_comment`, `resolve_comment`, `delete_comment`
**Search / people:** `search_attachments`, `search_suggest`, `list_workspace_members`, `get_current_user`, `get_workspace_info`, `get_my_profile`, `update_my_profile`, `get_my_recent_pages`
**Files / labels / access:** `upload_attachment`, `get_attachment_info`, `list_page_labels`, `add_page_labels`, `remove_page_label`, `list_space_members`, `add_space_members`, `remove_space_member`, `update_space_member_role`
**Favorites:** `list_favorites`, `add_favorite`, `remove_favorite`
**Prompts (6):** `summarize_page`, `summarize_space`, `answer_from_wiki`, `whats_new`, `draft_page`, `tidy_page`
**Resources (2):** `docmost://guide/usage`, `docmost://guide/toolsets` — in-client guidance; not all MCP clients surface prompts/resources.
Page and comment bodies are **Markdown**. `update_page` goes through `POST /api/pages/update` with `format: "markdown"` so Docmost converts and applies the change in place. `edit_page` (below) edits the page's ProseMirror JSON instead, so untouched content is written back exactly as it was read. The server does not open a Yjs socket or invent its own TipTap schema.
## Safety features
Enabled by default; each has an opt-out variable below.
- **Untrusted content**: page bodies, comments and search snippets come back inside `<docmost-untrusted-content source="...">…</docmost-untrusted-content>`. Attacker-supplied tags are escaped so the envelope cannot be broken. Treat that text as data, never instructions. Titles/names are stripped of control characters and capped.
- **Write verification**: after every body write the page is re-read. If the new content is missing (e.g. `COLLAB_DISABLE_REDIS` on the server), the tool reports failure — a 200 alone is not trusted.
- **Markdown loss hint**: `get_page` adds `markdown_loses: ["tables", "@mentions", "colours/highlights", …]` when the Markdown view drops structure. Switch to `format: "json"` before editing such pages.
- **Busy-page protection**: a full `replace` is refused if someone else saved the page in the last 60s, so concurrent typing is not overwritten. Append/prepend and `expected_updated_at` are unaffected.
- **`dry_run`**: pass `dry_run: true` to `update_page` or `edit_page` to see the change (or resulting Markdown) without writing.
These are deliberately lightweight: no new runtime dependencies, no database, no OAuth server. Boundaries worth knowing:
- `DOCMOST_READ_ONLY` refuses mutating **wiki** tools but does not remove them from `tools/list`, and does not cover local file writes by the export tools.
- `upload_attachment` accepts only absolute paths under the server working directory or the OS temp directory, rejects symlinks to other locations and files over 20 MiB. Export filenames from the server are reduced to a bare filename before writing.
- Untrusted wrapping covers successful page/comment/search text; error messages that quote a page title or paragraph are not wrapped.
- Boolean variables accept `1/0`, `true/false`, `yes/no`, `on/off`. A typo now fails at startup instead of silently disabling a safety feature.
## Editing part of a page
`update_page` replaces, appends or prepends a whole body. To change one part, use `edit_page`: it reads the page, applies your edits in memory and writes once. Tables, callouts, inline comments and every block you did not touch are sent back unchanged. If any edit fails, nothing is written.
```json
{
"page_id": "aB3dE5fG7h",
"expected_updated_at": "2026-11-21T12:00:00.000Z",
"edits": [
{ "mode": "replace_text", "old_text": "v1.0", "new_text": "v1.1" },
{ "mode": "replace_section", "heading": "## Status", "markdown": "Shipped." },
{ "mode": "insert_in_section", "heading": "Install", "markdown": "Requires Node 20." }
]
}
```
| Mode | What it does |
|---|---|
| `replace_text` | Replaces `old_text` with `new_text`. It must match exactly once, inside one paragraph, heading or list item, unless `replace_all` is set. Formatting around the match is kept. |
| `replace_section` | Keeps the heading and replaces everything under it, **subsections included**. Rename a heading with `replace_text`. |
| `insert_in_section` | Adds blocks to a section. `at: "end"` (default) is the end of the section's own body, before any subsection; `at: "start"` is right under the heading. |
| `insert_after_section` | Adds blocks after the section **and all its subsections**. |
| `delete_section` | Removes the heading, its body and its subsections. |
How sections work:
- `heading` is the heading's text (case-insensitive), or `"## Text"` to pin the level. A missing heading, or a name that matches more than one section, is an error that lists the candidates.
- A section runs from its heading to the next heading of the same or higher level. Sections are flat: text sitting after a subsection's content belongs to that subsection. To add text to a parent section ahead of its subsections, use `insert_in_section`, not `insert_after_section`.
- Only top-level headings count; headings inside callouts or tables do not.
- New `markdown` supports headings, paragraphs, one-level bullet and numbered lists, fenced code, and bold, italic, code and links. Tables, blockquotes, callouts, images, nested or task lists and horizontal rules are refused with an error naming the construct. Use `replace_text` to change text inside existing rich content.
- `expected_updated_at` (optional) refuses the write if the page changed since that `updatedAt`. There is still a small window between the check and the write.
## Reading less
`get_page` can return part of a page: `outline: true` lists the headings with offsets, `heading` returns one section as Markdown, and `max_chars` plus `offset` page through the body. Text longer than 40,000 characters is cut off with `truncated: true` and a `next_offset`; pass it back as `offset` to continue. `get_history_version` pages the same way. `format=json` bodies are not capped.
## Smaller responses
To save AI context, list and write results are slim by default (for example `list_pages` items keep `id, slugId, title, icon, parentPageId, hasChildren, updatedAt`, with the shared `space` shown once), fields that are `null` are omitted, and JSON is compact. Pass `verbose: true` to get the full metadata. The [CHANGELOG](CHANGELOG.md) lists exactly which fields each tool drops.
`DOCMOST_TOOLSETS` limits which tools are exposed, which shrinks the tool list your client sends to the model on every request.
## Environment
| Variable | Required | Purpose |
|---|---|---|
| `DOCMOST_URL` | yes | Instance URL, e.g. `https://docs.example.com` |
| `DOCMOST_EMAIL` + `DOCMOST_PASSWORD` | one auth method | Community login |
| `DOCMOST_AUTH_TOKEN` | one auth method | `authToken` cookie from the browser |
| `DOCMOST_SESSION_PATH` | no | Session cache file |
| `DOCMOST_READ_ONLY` | no | `true` / `1` / `yes` / `on` — mutating tools return an error; they stay listed. A typo fails at startup. |
| `DOCMOST_TOOLSETS` | no | Comma list of tool groups to expose: `pages`, `spaces`, `comments`, `search`, `workspace`, `attachments`, `labels`, `members`, `favorites`, `admin`. Unset means all tools. An unknown name stops startup. |
| `DOCMOST_TRANSPORT` | no | `stdio` (default) or `http` (Streamable HTTP). Aliases: `streamable-http`, `streamable_http`. |
| `DOCMOST_UNTRUSTED_WRAP` | no | Wrap page bodies, comments and search snippets in `<docmost-untrusted-content>` to mark them as data. Default `true`. |
| `DOCMOST_VERIFY_WRITES` | no | Re-read after a body write to confirm it persisted (catches `COLLAB_DISABLE_REDIS`). Default `true`. |
| `DOCMOST_DETECT_MARKDOWN_LOSS` | no | Add `markdown_loses` to `get_page` when Markdown drops tables/callouts/mentions/colours. Default `true`. |
| `DOCMOST_BUSY_WINDOW_MS` | no | Refuse a full replace if someone else saved within this window. Default `60000`; `0` disables. |
Email/password is preferred. The JWT is cached under `~/.docmost-mcp-server/session.json` and refreshed on 401. MFA accounts cannot complete login here — use `DOCMOST_AUTH_TOKEN` instead.
Use a dedicated Docmost user. Do not commit credentials.
## Streamable HTTP
Set `DOCMOST_TRANSPORT=http` to serve the same tools over [MCP Streamable HTTP](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http) instead of stdio. The default stays `stdio`, so existing client configs need no change.
```bash
DOCMOST_URL=http://127.0.0.1:3000 \
DOCMOST_EMAIL=admin@example.com DOCMOST_PASSWORD=secret \
DOCMOST_TRANSPORT=http DOCMOST_HTTP_TOKEN=a-long-random-secret \
node dist/index.js
```
```json
{
"mcpServers": {
"docmost": {
"type": "http",
"url": "http://127.0.0.1:3001/mcp",
"headers": { "Authorization": "Bearer a-long-random-secret" }
}
}
}
```
Sessions are **stateful**: every client session gets its own Docmost client (JWT cache and version probe), a server-generated `mcp-session-id` response header, and is reclaimed after 30 minutes idle. Send `DELETE /mcp` with that header to end a session explicitly. `GET /healthz` is unauthenticated and returns `{"status":"ok","sessions":N}` for liveness probes.
| Variable | Default | Purpose |
|---|---|---|
| `DOCMOST_HTTP_HOST` | `127.0.0.1` | Bind address. Loopback by default. |
| `DOCMOST_HTTP_PORT` | `3001` | TCP port. |
| `DOCMOST_HTTP_PATH` | `/mcp` | MCP endpoint path (a leading `/` is added if missing). |
| `DOCMOST_HTTP_TOKEN` | unset | If set, every request needs `Authorization: Bearer <token>`. Compared in constant time. |
| `DOCMOST_HTTP_ALLOWED_HOSTS` | unset | Comma-separated Host-header allowlist for DNS rebinding protection. |
| `DOCMOST_HTTP_JSON_RESPONSE` | `false` | Reply with plain JSON instead of an SSE stream. |
| `DOCMOST_HTTP_MAX_SESSIONS` | `50` | Concurrent session limit; new handshakes get `503` when full. |
| `DOCMOST_HTTP_SESSION_TTL_MS` | `1800000` | Idle session timeout; minimum `1000`, `0` disables expiry. |
Requests are capped at 4 MiB. Invalid JSON gets `400`, unknown session ids get `404`, wrong methods get `405`. Start with `DOCMOST_HTTP_TOKEN` **before** changing `DOCMOST_HTTP_HOST` to a non-loopback address — anyone who can reach the port would otherwise inherit the configured Docmost account. A warning is logged when the endpoint is exposed without a token. Session-cap checks reserve a slot before the async handshake, so concurrent `initialize` calls cannot overrun `maxSessions`.
The Host allowlist checks the `Host` header of **clients calling the MCP endpoint**, not the MCP → Docmost API calls and not the client's source IP. Write the host from the client's MCP URL into it (e.g. `mcp.example.com` for `http://mcp.example.com:3001/mcp`); Docmost's own address is irrelevant here. It is a DNS-rebinding helper, not authentication — the Bearer token is the actual gate. Bearer scheme matching is case-insensitive. For non-loopback deployments, use a dedicated Docmost account and put TLS in front of the endpoint.
### Live HTTP probe
`scripts/http-e2e.mjs` checks a running endpoint against a real Docmost instance: health/auth/Host-header/session guards, `initialize`, `tools/list`, `prompts/list`, `resources/list`, and a create → read → edit → dry-run → delete page round trip. It reads `DOCMOST_HTTP_TOKEN` from the environment or the project-root `.env` (falling back to the current working directory's `.env`).
```bash
npm run test:e2e # 127.0.0.1:3001
MCP_BASE_URL=http://mcp.example.com:3001 npm run test:e2e
```
`npm test` is offline (stub/in-memory); `npm run test:e2e` needs a running endpoint and a reachable Docmost instance, and creates then deletes one test page. The probe always tries to close its session and test page even when a check fails.
### Linux deployment files
`deploy/docmost-mcp.service` is an example systemd unit: it loads `/opt/docmost-mcp/.env`, runs `node /opt/docmost-mcp/dist/index.js`, and restarts on failure. Copy it to `/etc/systemd/system/`, then `systemctl daemon-reload && systemctl enable --now docmost-mcp`. Adjust the Node path and install directory for your host.
That unit currently has no `User=`/`Group=`, so systemd runs it as **root**, and the Node path is host-specific. For production, create a dedicated service user, set `User=`/`Group=`, `UMask=0077`, `NoNewPrivileges=true`, `ProtectSystem=strict`, `ProtectHome=true`, `PrivateTmp=true`, a memory cap, and make `.env` (0600) owned by that user. `.env.example` mirrors the live configuration with credentials replaced by placeholders; never commit a real token — rotate it if that happens.
## Cursor
Add to `.cursor/mcp.json` or `~/.cursor/mcp.json`:
```json
{
"mcpServers": {
"docmost": {
"command": "npx",
"args": ["-y", "github:charlesqing/docmost-mcp-server"],
"env": {
"DOCMOST_URL": "https://docs.example.com",
"DOCMOST_EMAIL": "you@example.com",
"DOCMOST_PASSWORD": "your-password"
}
}
}
}
```
From a local clone:
```json
{
"mcpServers": {
"docmost": {
"command": "node",
"args": ["/absolute/path/to/docmost-mcp-server/dist/index.js"],
"env": {
"DOCMOST_URL": "https://docs.example.com",
"DOCMOST_EMAIL": "you@example.com",
"DOCMOST_PASSWORD": "your-password"
}
}
}
}
```
## Claude Desktop / Claude Code
Same `mcpServers` block as above. Claude Code:
```bash
claude mcp add docmost --env DOCMOST_URL=https://docs.example.com --env DOCMOST_EMAIL=you@example.com --env DOCMOST_PASSWORD=secret -- npx -y github:charlesqing/docmost-mcp-server
```
## Design notes
- **stdio by default**; Streamable HTTP is opt-in via `DOCMOST_TRANSPORT=http`. Both transports expose the same tools and share the same configuration.
- **No Enterprise license, no Docmost database access, no Docmost fork.**
- Space slugs are accepted anywhere a space id is required.
- Page slugIds (the id in page URLs) are accepted anywhere a page id is required, and are resolved to UUIDs before the request.
- `move_page` computes the required fractional `position` key (`first`, `last`, or after a sibling).
- `create_page` / `update_page` fail clearly on servers older than **v0.80.1** (CVE-2026-48073) instead of silently dropping the body. `get_current_user` reports `docmostVersion` from Docmost's `currentVersion` field.
- `delete_space` requires `confirm: true`. Mutating tools honor `DOCMOST_READ_ONLY`.
- `list_pages` defaults to recently updated pages. Pass `view=tree` for sidebar-root pages. `get_page_tree` reads the full nested hierarchy in one call.
- `edit_page` needs Docmost to accept `format: "json"` on `/api/pages/update`; verified on v0.98.0. It writes the whole page body back in one request; a concurrent editor is protected by busy-page detection (60s) and optional `expected_updated_at`.
- `search_attachments` is Enterprise-only; Community hosts get a clear 403 message.
- Export tools write a zip or a single `.md`/`.html` file to `output_path` or a temp file and return the path.
- **Docmost v0.98+:** body writes on locked pages and base (database) pages are refused with a clear error instead of sending a write that would fail or corrupt content. `list_spaces` hides archived spaces by default; pass `include_archived: true` to see them if the server returns them. Docmost v0.98's `/spaces` endpoint omits archived spaces entirely, so to `unarchive_space` you must pass the space **UUID** (a slug cannot be resolved while it is archived).
- **Favorites** accept `page`, `space` or `template` as `type`. Page slugIds and space slugs are resolved before the request. Templates are EE-only and will surface the server's 403 on Community hosts.
- `get_workspace_info` returns the workspace fields agents use plus `entitlements` (`tier`, `features`), useful for detecting Enterprise-only capabilities before calling them.
## Known limits
From the 2026-11-29 review. These do not change the verified happy path, but they bound what you should assume:
- **Version gate**: if `/api/version` cannot be read, writes are still allowed (fail-open). Keep the MCP host able to reach that endpoint on Docmost ≥ v0.80.1.
- **Busy page**: the 60s check is skipped when `/users/me` fails. Pass `expected_updated_at` when concurrent edits matter.
- **Markdown comments**: the inline converter handles one level of bold/italic/code/link, not nested emphasis or parentheses inside URLs; tables, callouts and images are not supported in comments. Page section edits use a stricter unsupported-construct list.
- **`get_page_tree`**: at most 100 siblings per level and no cursor; `truncated=true` means a bound was hit. `max_depth`/`max_nodes` are the only bounds.
- **`check_space_health`**: paginates up to `max_pages` (default 200); `min_chars > 0` fetches each scanned page body (one request per page).
- **Exports** are annotated `readOnlyHint: true` but write local files; `DOCMOST_READ_ONLY` does not stop them. Prefer an explicit `output_path`.
- **Error text** that quotes a page title or paragraph is not wrapped in the untrusted envelope.
- **systemd unit** is a working example, not a hardened template; see Linux deployment files.
- Concurrent 401 responses can trigger more than one Docmost login within a session; harmless but noisier when auth fails.
## License
MIT. This package does not include Docmost AGPL or Enterprise source. The copyright notice in [LICENSE](LICENSE) retains the upstream `docmost-community-mcp` contributors alongside this fork's maintainer.
TDQS
Scored across 56 tools
Descriptions do a lot of work to separate tools (e.g. update_page vs edit_page, list_pages vs get_page_tree vs list_child_pages), but the set still contains multiple near-duplicate pairs: move_page vs move_page_to_space, get_backlinks vs get_backlinks_count, get_current_user vs get_my_profile, search_pages vs search_suggest. Several of these could be merged via parameters, leaving an agent to guess which variant applies in edge cases.
The dominant convention is snake_case verb_noun (get_page, create_page, list_spaces, archive_space, add_page_labels), applied consistently across the vast majority of tools. A few outliers break the pattern mildly: search_suggest (verb_verb), check_space_health (verb_noun_noun), and get_history_version which omits the resource noun.
56 tools is well past the point where a single agent can hold the surface in mind, and the domain (a wiki with pages, spaces, comments, labels, members) does not justify that many distinct entry points. Many pairs are thin variants of each other and could be consolidated into fewer parameterized tools.
Coverage is genuinely broad: page CRUD plus history, trash, export, hierarchy, backlinks, labels; full space lifecycle and membership; comment CRUD with resolve; attachments; favorites and profile. Gaps are minor but real — no attachment deletion/download tool, no template tools despite favorites supporting template types, and inline comments are explicitly unsupported.