docmost-mcp
# Docmost MCP server
[](https://www.npmjs.com/package/@punyamsingh/docmost-mcp)
[](https://www.npmjs.com/package/@punyamsingh/docmost-mcp)
[](https://github.com/punyamsingh/docmost-mcp/actions/workflows/test.yml)
[](./LICENSE)
[](https://glama.ai/mcp/servers/punyamsingh/docmost-mcp)
[](https://mcpservers.org/servers/punyamsingh/docmost-mcp)
An MCP server for **self-hosted [Docmost](https://docmost.com)**. Read, search, create and edit wiki pages in Markdown from Claude Code, Claude Desktop, Cursor, VS Code or any other MCP client. Works with the free Community Edition: no Enterprise licence and no API key, just a normal Docmost login.
```bash
claude mcp add docmost --scope user \
-e DOCMOST_URL=https://docs.example.com \
-e DOCMOST_EMAIL=you@example.com \
-e DOCMOST_PASSWORD='your-password' \
-- npx -y @punyamsingh/docmost-mcp
```
That is all Claude Code needs; config for Claude Desktop, Cursor and VS Code is under [Setup](#setup).
Docmost's official MCP server and API keys are part of its paid Enterprise edition. This server needs neither. It logs in with a normal Docmost account and calls the same API the Docmost web app uses. Since Docmost v0.70 that API accepts and returns Markdown, and the server converts it to and from its editor format.
- **Markdown in and out**: pages come back as Markdown and are written from Markdown.
- **Safe edits**: an optional stale-write check stops a replace from overwriting someone else's newer change, and rewrites that would delete comments, mentions or diagrams are refused.
- **Live collaboration**: text edits are made in the live document, the way Docmost's own editor makes them, so they merge with whatever people with the page open are typing.
- **Any page reference**: a page id, slug id or the URL copied from the browser.
## Tools
| Tool | What it does |
|---|---|
| `get_workspace` | Returns the workspace with its member count, the account the server is signed in as with its email and role, and the spaces it can see with their ids |
| `list_members` | Lists the workspace's members with names, emails and roles, optionally filtered by name or email |
| `create_space` | Creates a space with a name and slug; needs a workspace admin |
| `update_space` | Renames a space or changes its slug or description; needs space admin rights |
| `list_pages` | Lists the root pages of a space, or the children of a page, with each page's `updatedAt` on Docmost 0.97 and newer |
| `find_pages` | Finds pages by full-text `query`, by `label` (Docmost 0.90 and newer) or in a space's trash with `inTrash`; with none of those, lists recently updated pages; optionally within one space, paged by `cursor` |
| `get_page` | Returns a page as Markdown, 500 lines at a time by default, with its id, space, parent, URL, `updatedAt`, the path of pages above it and, on Docmost 0.90 and newer, its labels; or one heading's `section`; or, with `outline`, only its headings and their line numbers; with `historyId`, reads a saved revision instead |
| `list_page_history` | Lists a page's saved revisions, newest first, with author, contributors and time |
| `list_page_links` | Lists the pages linking to a page, or the pages it links to, on Docmost 0.90 and newer |
| `create_page` | Creates a page from Markdown, at a space root or under a parent page |
| `update_page` | Replaces, appends to or prepends to a page body, or with `heading` only that heading's section, which can also be deleted; can rename the page or change its icon; in a call of their own, adds and removes labels by name |
| `replace_page_text` | Replaces an exact piece of text in a page, in place when it is plain text, leaving the rest of the page as it is |
| `move_page` | Moves a page and its subpages under another page or to a space root, including into another space; with `copy`, copies them there without comments, or next to the original when no destination is given |
| `delete_page` | Moves a page and its subpages to the space's trash; never deletes permanently |
| `restore_page` | Restores a page and its subpages from the trash, or with `historyId` puts a saved revision back as the page's body and title, diagrams, mentions and formatting included |
| `list_comments` | Lists a page's open comment threads with their replies, or every thread with `includeResolved` |
| `create_comment` | Posts a page comment, an inline comment attached to a `quote` copied from `get_page`, or with `parentCommentId` a reply in that comment's thread |
| `update_comment` | Replaces the text of one of the account's own comments, or resolves or reopens a thread with `resolved`; before Docmost 0.98 resolving needs an Enterprise licence |
| `delete_comment` | Permanently deletes a comment and removes its highlight; a whole thread needs `deleteReplies` |
| `upload_attachment` | Uploads a local image or file (up to 50 MB) to a page and returns a Markdown image or link to place with `replace_page_text` or `update_page` |
| `list_attachments` | Lists the files and images uploaded to a page, newest first, on Docmost 0.96 and newer |
| `delete_attachment` | Permanently deletes a file from a page; needs space admin rights and Docmost 0.97 or newer |
| `import_pages` | Creates pages from a `.md` or `.html` file, a `.zip`, or a folder, at the space root or under a parent page |
| `export_pages` | Saves a page as a Markdown or HTML file, or as a `.zip` with its subpages or attachments, or a whole space as a `.zip`, which needs space admin rights, and returns the path and size |
Every tool that takes a page accepts a page id, a slug id, or the page URL copied from the browser.
`get_workspace` returns at most 1000 spaces and `list_pages` at most 1000 pages; a longer list comes with a note saying it was cut short.
Pass the `updatedAt` from `get_page` as `expectedUpdatedAt` to `update_page`, and the change is refused if someone changed the page in the meantime. `replace_page_text` reads the current body itself, so it applies on top of other people's changes as long as the text still matches exactly once.
When `oldText` and `newText` are plain text and each match sits inside one paragraph, heading or code block, `replace_page_text` changes just that text in the page's live document, over Docmost's collaboration websocket, the same connection Docmost's editor uses. The change merges with what anyone with the page open is typing, and comments, mentions, colours and everything else on the page are kept. The new text takes the formatting of the text it replaces, as typing over a selection does in the editor. Docmost saves the change within 45 seconds, so the result's `updatedAt` is `null`; `editedInPlace` and `liveMerge` say which way the edit went. If the websocket can't be reached within 10 seconds, the edit is written to the saved page instead and `liveMergeSkipped` says why.
Otherwise, for example when the new text has Markdown formatting or the match crosses a line break or a mention, the edit rewrites the whole body from Markdown, as an `update_page` replace does. Content that Markdown cannot carry would be deleted, so the server refuses such a rewrite on any page that holds it: mentions, comments, highlights, coloured or underlined text, drawio and excalidraw diagrams, embeds, attachments, merged table cells, and any block type it does not recognise. Append and prepend only add blocks, so they still work on those pages.
A whole-body rewrite can't be merged, so it is refused while someone with the page open has typing that Docmost hasn't saved yet; retry a minute later. Append and prepend are merged by Docmost, so they always go through.
`restore_page` with a `historyId` undoes changes by putting a revision from `list_page_history` back, the way Docmost's own Restore button does. It sends the revision in Docmost's editor format rather than Markdown, so nothing is lost, and takes `expectedUpdatedAt` like a replace. Like a rewrite, it is refused while someone has unsaved typing open, and on a page in the trash. Comments added since the revision keep their thread but lose their highlight in the text; the result's `commentHighlightsRemoved` says how many.
### Exports and imports
Paths are on the machine running the server, which over HTTP is not the client's machine. An export given an existing folder saves under Docmost's file name, and refuses to replace a file unless `overwrite: true`. `import_pages` uses Docmost's own importer, which turns relative links into page links and uploads the images they point to; a folder is zipped first, and each subfolder becomes a page holding its files' pages. A single file must be under 30 MB, and `.docx` and `.pdf` need Docmost Enterprise. The server waits up to 2 minutes for a `.zip` or folder import, or `DOCMOST_IMPORT_WAIT_SECONDS`, then returns the import's task id if it is still running. With `parentPageId` the new pages are moved under that page; if the move fails they stay at the space root and the result says `moved: false` and why.
### Sections
`update_page` with a `heading` finds that heading by its text, ignoring case and any leading `#`, and works on everything below it down to the next heading of the same or a higher level, subsections included. `replace` keeps the heading and swaps what is under it, `prepend` adds content right under the heading, `append` adds it after the last subsection, and `delete` removes the heading too. A heading that appears twice is refused, as the section would be ambiguous.
The change is made in the page's live document, like `replace_page_text`, so it merges with what people with the page open are typing, and diagrams, mentions and comments outside the section are kept. When the websocket can't be reached, the saved page's editor content is changed instead. The new content is Markdown with headings, paragraphs, bullet, numbered and task lists, code blocks, quotes, horizontal rules, bold, italic, strikethrough, inline code and links; tables, images, callouts and HTML are refused, so use `replace_page_text`, or `update_page` without `heading`, for those. Comments whose highlighted text is replaced or deleted keep their thread but lose the highlight, and the result's `commentHighlightsRemoved` says how many.
### Comments
Comment text is plain text: blank lines start new paragraphs, and `@[Full Name]` mentions the one member with that name, which notifies them. A name that matches no member, or several, refuses the call before anything is posted.
An inline comment's `quote` must appear exactly once inside one paragraph or heading, without crossing a mention or sitting in a code block or on text that already has a comment. The server finds it in the page's live document and sends its position with the comment, and Docmost adds the highlight, as it does in its own editor. The server then waits up to 5 seconds for the highlight; if it doesn't appear, the comment still exists and the result says `anchored: false`.
Docmost threads are one level deep, so a reply to a reply is posted in the same thread, and only a thread's top comment can be resolved. Docmost 0.98 and newer let any member resolve threads; older releases keep it for Enterprise licences, and without one the call is refused and nothing changes. Docmost 0.95 leaves an inline thread's highlight looking open after a resolve, so the server updates it through the live document; `highlightUpdated` says whether it could. Deletes are permanent and take a comment's replies with them, so deleting a thread's top comment needs `deleteReplies: true`. Docmost's API leaves a deleted comment's highlight on the page, so the server removes it through the live document; if it can't, for an account that can only comment, the result says `highlightRemoved: false`.
## Requirements
- Node.js 22.18 or newer
- Docmost v0.70 or newer
- A Docmost account. Edits are attributed to this account in page history, so each person should use their own. An account with MFA signs in with a session token instead of a password, as described below.
## Setup
There is nothing to clone. Register the server with your MCP client and pass your Docmost login as environment variables. `npx` downloads and runs it.
### Claude Code: all projects
```bash
claude mcp add docmost --scope user \
-e DOCMOST_URL=https://docs.example.com \
-e DOCMOST_EMAIL=you@example.com \
-e DOCMOST_PASSWORD='your-password' \
-- npx -y @punyamsingh/docmost-mcp
```
### Claude Desktop, Cursor and other clients
Add the following to the client's MCP config (`claude_desktop_config.json`, `~/.cursor/mcp.json`, …):
```json
{
"mcpServers": {
"docmost": {
"command": "npx",
"args": ["-y", "@punyamsingh/docmost-mcp"],
"env": {
"DOCMOST_URL": "https://docs.example.com",
"DOCMOST_EMAIL": "you@example.com",
"DOCMOST_PASSWORD": "your-password"
}
}
}
}
```
### VS Code
Add the following to `.vscode/mcp.json` in a workspace, or to your user MCP config:
```json
{
"servers": {
"docmost": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@punyamsingh/docmost-mcp"],
"env": {
"DOCMOST_URL": "https://docs.example.com",
"DOCMOST_EMAIL": "you@example.com",
"DOCMOST_PASSWORD": "your-password"
}
}
}
}
```
To run the latest code on GitHub instead of the npm release, replace `@punyamsingh/docmost-mcp` with `github:punyamsingh/docmost-mcp`. The first start is slower because it builds from source.
The client stores these values in its own config file in plain text, the same as a `.env` file would, so use a config file only you can read.
After the first login the session token is cached in `~/.cache/docmost-mcp/` (or `$XDG_CACHE_HOME/docmost-mcp/`), with file mode `600`. Restarting the client therefore does not open a new Docmost session each time. A new login happens automatically when the token expires or is revoked.
### Accounts with MFA
The server can't complete a second factor, so an account with MFA signs in with a browser session instead. Sign in to Docmost in a browser, copy the value of its `authToken` cookie (in the browser's developer tools, under the site's cookies), and set `DOCMOST_AUTH_TOKEN` to it in place of `DOCMOST_EMAIL` and `DOCMOST_PASSWORD`; when an email and password are set too, they are used and the token is ignored. Treat the token like a password. It stops working when the session expires or you sign out, and the server then asks for a fresh one rather than logging in again.
### From a clone
```bash
git clone https://github.com/punyamsingh/docmost-mcp.git
cd docmost-mcp
npm install # also builds into build/
cp .env.example .env # then fill in DOCMOST_URL, DOCMOST_EMAIL, DOCMOST_PASSWORD
claude mcp add docmost --scope user -- node "$PWD/build/index.js"
```
`.env` is git-ignored. Variables set in the client's config take precedence over it.
The server reaches Docmost's collaboration websocket at `DOCMOST_URL` + `/collab`. If your Docmost serves it elsewhere (its `COLLAB_URL` setting), set `DOCMOST_COLLAB_URL` to that address.
`npm test` builds the server and runs the test suite against a fake Docmost, so it needs no Docmost instance.
### Over HTTP
The server speaks stdio by default. To serve [Streamable HTTP](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http) instead, start it with `--http` or set `DOCMOST_MCP_PORT`:
```bash
DOCMOST_URL=https://docs.example.com DOCMOST_EMAIL=you@example.com DOCMOST_PASSWORD='your-password' \
npx -y @punyamsingh/docmost-mcp --http --port 3000
```
Clients connect to `http://127.0.0.1:3000/mcp`, for example `claude mcp add --transport http docmost http://127.0.0.1:3000/mcp`.
| Flag | Environment variable | Default |
| --- | --- | --- |
| `--port` | `DOCMOST_MCP_PORT` | `3000` |
| `--host` | `DOCMOST_MCP_HOST` | `127.0.0.1` |
| | `DOCMOST_MCP_TOKEN` | none |
The server still logs in to Docmost with its own `DOCMOST_*` variables, so every client that reaches it acts as that one account. When `DOCMOST_MCP_TOKEN` is set, each request must send `Authorization: Bearer <token>`. The server refuses to bind to anything but a loopback address without a token, and serves plain HTTP, so put it behind a TLS proxy before exposing it to a network.
### Read-only mode
Set `DOCMOST_READ_ONLY=true` to offer only the tools that leave Docmost unchanged: reading, searching, listing and exporting. The tools that write are not listed at all, so the model never sees them.
## Limitations
- No tools for permissions.
- Mentions are looked up through Docmost's people search, 100 people at a time; when 100 or more people match a name, uniqueness can't be confirmed and the mention is refused.
- `delete_comment` checks a thread for replies just before deleting it. A reply posted in the moment between that check and the delete is deleted with the thread, because Docmost's delete can't be made conditional.
- The HTTP transport is stateless: it keeps no MCP sessions, so it sends no server-initiated notifications and serves no `GET` stream.
- A `find_pages` search offers a `nextCursor` only when a full page of results came back. Docmost drops pages the account can't open after counting, so a short page can still have more results after it.
- Docmost returns revisions only as editor JSON, so `get_page` converts them to Markdown itself when reading one; content Markdown can't hold, such as diagrams or embeds, comes back as a link or is left out.
- Accounts with MFA need `DOCMOST_AUTH_TOKEN`, which has to be copied again from a browser whenever the session expires.
- When the collaboration websocket can't be reached, `replace_page_text` falls back to writing the saved page. Docmost saves what people type 10 to 45 seconds after they type it, so in that case text typed in that window by someone with the page open can be lost.
- Docmost's import task doesn't record the pages it created, so `import_pages` takes the space's new root pages as the import's. A root page someone else creates in that space during the import is reported, and moved under `parentPageId`, with it.
- Before a whole-body rewrite the server compares the live text with the saved text, not formatting, so bold or colour added in the last 45 seconds without typing can still be lost by a rewrite.
## License
MIT
TDQS
Scored across 24 tools
Tools target distinct resources and actions, and descriptions clearly separate list_pages (tree browsing) from find_pages (search/filter/recent/trash). The main overlap is update_page versus replace_page_text, but their guidance on Markdown rewrites versus exact live-text edits is clear enough for selection.
Names consistently use snake_case verb_noun phrasing such as get_workspace, list_pages, create_comment, and delete_attachment. Qualifiers like list_page_history and replace_page_text follow the same convention without mixing camelCase or vague verbs.
At 24 tools this is on the heavy side, but each maps to a distinct operation across workspace, spaces, pages, comments, and attachments. The surface is broad but not obviously redundant for a full-featured wiki integration.
Page operations are especially complete, covering create/read/update/replace/move/restore/delete/history/links/import/export, while comments and attachments have create/list/update/delete coverage. Minor gaps remain around space deletion and member administration, but core wiki workflows are covered.