@punyamsingh/docmost-mcp 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Punyam Singh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,93 @@
1
- # Temporary Holding Version
1
+ # docmost-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An MCP server for **self-hosted [Docmost](https://docmost.com)**. Read, search, create and update wiki pages in Markdown from Claude Code, Claude Desktop, Cursor or any other MCP client.
4
+
5
+ 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.
6
+
7
+ ## Tools
8
+
9
+ | Tool | What it does |
10
+ |---|---|
11
+ | `list_spaces` | Lists the spaces the account can see, with their ids |
12
+ | `list_pages` | Lists the root pages of a space, or the children of a page |
13
+ | `search_pages` | Full-text search, optionally within one space |
14
+ | `get_page` | Returns a page as Markdown, 500 lines at a time by default, with its id, space, parent, URL and `updatedAt` |
15
+ | `create_page` | Creates a page from Markdown, at a space root or under a parent page |
16
+ | `update_page` | Replaces, appends to or prepends to a page body; can rename it or change its icon |
17
+ | `edit_page` | Replaces an exact piece of text in a page body by rewriting the body with the change |
18
+
19
+ Every tool that takes a page accepts a page id, a slug id, or the page URL copied from the browser.
20
+
21
+ Pass the `updatedAt` from `get_page` as `expectedUpdatedAt` to `update_page`, and a replace is refused if someone changed the page in the meantime. `edit_page` reads the current body itself, so it applies on top of other people's changes as long as the text still matches exactly once.
22
+
23
+ A replace, and so every `edit_page`, rewrites the whole body from Markdown. Content that Markdown cannot carry would be deleted, so the server refuses a replace 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.
24
+
25
+ Content updates go through Docmost's real-time collaboration layer, so if someone has the page open while it is updated, their editor picks up the change instead of overwriting it.
26
+
27
+ ## Requirements
28
+
29
+ - Node.js 20.12 or newer
30
+ - Docmost v0.70 or newer
31
+ - A Docmost account without MFA. Edits are attributed to this account in page history, so each person should use their own.
32
+
33
+ ## Setup
34
+
35
+ 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.
36
+
37
+ ### Claude Code: all projects
38
+
39
+ ```bash
40
+ claude mcp add docmost --scope user \
41
+ -e DOCMOST_URL=https://docs.example.com \
42
+ -e DOCMOST_EMAIL=you@example.com \
43
+ -e DOCMOST_PASSWORD='your-password' \
44
+ -- npx -y @punyamsingh/docmost-mcp
45
+ ```
46
+
47
+ ### Claude Desktop, Cursor and other clients
48
+
49
+ Add the following to the client's MCP config (`claude_desktop_config.json`, `~/.cursor/mcp.json`, …):
50
+
51
+ ```json
52
+ {
53
+ "mcpServers": {
54
+ "docmost": {
55
+ "command": "npx",
56
+ "args": ["-y", "@punyamsingh/docmost-mcp"],
57
+ "env": {
58
+ "DOCMOST_URL": "https://docs.example.com",
59
+ "DOCMOST_EMAIL": "you@example.com",
60
+ "DOCMOST_PASSWORD": "your-password"
61
+ }
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ 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.
68
+
69
+ 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.
70
+
71
+ 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.
72
+
73
+ ### From a clone
74
+
75
+ ```bash
76
+ git clone https://github.com/punyamsingh/docmost-mcp.git
77
+ cd docmost-mcp
78
+ npm install # also builds into build/
79
+ cp .env.example .env # then fill in DOCMOST_URL, DOCMOST_EMAIL, DOCMOST_PASSWORD
80
+ claude mcp add docmost --scope user -- node "$PWD/build/index.js"
81
+ ```
82
+
83
+ `.env` is git-ignored. Variables set in the client's config take precedence over it.
84
+
85
+ ## Limitations
86
+
87
+ - Uploading local image files is not supported yet; reference images that are already hosted somewhere by URL.
88
+ - No tools for deleting or moving pages, comments, or permissions.
89
+ - Accounts with MFA cannot log in, because the server has no way to complete the second factor.
90
+
91
+ ## License
92
+
93
+ MIT
@@ -0,0 +1,27 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { existsSync } from 'node:fs';
3
+ import { homedir } from 'node:os';
4
+ import { dirname, join } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ export const packageRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
7
+ const envFilePath = join(packageRoot, '.env');
8
+ const cacheDirectory = join(process.env.XDG_CACHE_HOME || join(homedir(), '.cache'), 'docmost-mcp');
9
+ export const loadConfig = () => {
10
+ if (existsSync(envFilePath)) {
11
+ process.loadEnvFile(envFilePath);
12
+ }
13
+ const missingVariables = ['DOCMOST_URL', 'DOCMOST_EMAIL', 'DOCMOST_PASSWORD'].filter((variableName) => !process.env[variableName]);
14
+ if (missingVariables.length > 0) {
15
+ throw new Error(`Missing ${missingVariables.join(', ')}. Pass them as env vars in your MCP client config, or put them in ${envFilePath}.`);
16
+ }
17
+ const baseUrl = new URL(process.env.DOCMOST_URL ?? '').origin;
18
+ const email = process.env.DOCMOST_EMAIL ?? '';
19
+ const accountKey = createHash('sha256').update(`${baseUrl}\n${email}`).digest('hex').slice(0, 16);
20
+ return {
21
+ baseUrl,
22
+ email,
23
+ password: process.env.DOCMOST_PASSWORD ?? '',
24
+ sessionFile: join(cacheDirectory, `session-${accountKey}.json`),
25
+ };
26
+ };
27
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AASzC,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAE/E,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAE9C,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,OAAO,EAAE,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 1000;
5
+ const PAGE_SIZE = 100;
6
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
7
+ const errorBodySchema = z.object({
8
+ message: z.union([z.string(), z.array(z.string())]),
9
+ });
10
+ const loginBodySchema = z.object({
11
+ data: z
12
+ .object({
13
+ userHasMfa: z.boolean().optional(),
14
+ requiresMfaSetup: z.boolean().optional(),
15
+ })
16
+ .nullish(),
17
+ });
18
+ const sessionFileSchema = z.object({
19
+ baseUrl: z.string(),
20
+ email: z.string(),
21
+ token: z.string(),
22
+ });
23
+ const paginatedSchema = (itemSchema) => z.object({
24
+ items: z.array(itemSchema),
25
+ meta: z.object({
26
+ hasNextPage: z.boolean(),
27
+ nextCursor: z.string().nullish(),
28
+ }),
29
+ });
30
+ const spaceSchema = z.object({
31
+ id: z.string(),
32
+ name: z.string(),
33
+ slug: z.string(),
34
+ description: z.string().nullish(),
35
+ });
36
+ const treePageSchema = z.object({
37
+ id: z.string(),
38
+ slugId: z.string(),
39
+ title: z.string().nullish(),
40
+ icon: z.string().nullish(),
41
+ parentPageId: z.string().nullish(),
42
+ hasChildren: z.boolean().nullish(),
43
+ });
44
+ const searchResultSchema = z.object({
45
+ id: z.string(),
46
+ slugId: z.string().nullish(),
47
+ title: z.string().nullish(),
48
+ highlight: z.string().nullish(),
49
+ parentPageId: z.string().nullish(),
50
+ updatedAt: z.string().nullish(),
51
+ space: z
52
+ .object({
53
+ id: z.string().nullish(),
54
+ name: z.string().nullish(),
55
+ slug: z.string().nullish(),
56
+ })
57
+ .nullish(),
58
+ });
59
+ const pageSchema = z.object({
60
+ id: z.string(),
61
+ slugId: z.string(),
62
+ title: z.string().nullish(),
63
+ icon: z.string().nullish(),
64
+ spaceId: z.string(),
65
+ parentPageId: z.string().nullish(),
66
+ content: z.unknown().optional(),
67
+ updatedAt: z.string().nullish(),
68
+ space: z
69
+ .object({
70
+ name: z.string().nullish(),
71
+ slug: z.string().nullish(),
72
+ })
73
+ .nullish(),
74
+ });
75
+ const editorNodeSchema = z.lazy(() => z.object({
76
+ type: z.string(),
77
+ attrs: z.record(z.string(), z.unknown()).optional(),
78
+ marks: z.array(z.object({ type: z.string() })).optional(),
79
+ content: z.array(editorNodeSchema).optional(),
80
+ }));
81
+ const editorPageSchema = z.object({
82
+ id: z.string(),
83
+ title: z.string().nullish(),
84
+ updatedAt: z.string().nullish(),
85
+ content: editorNodeSchema.nullish(),
86
+ });
87
+ const MARKDOWN_SAFE_NODES = new Set([
88
+ 'doc',
89
+ 'paragraph',
90
+ 'text',
91
+ 'hardBreak',
92
+ 'heading',
93
+ 'bulletList',
94
+ 'orderedList',
95
+ 'listItem',
96
+ 'taskList',
97
+ 'taskItem',
98
+ 'blockquote',
99
+ 'horizontalRule',
100
+ 'codeBlock',
101
+ 'mathBlock',
102
+ 'callout',
103
+ 'details',
104
+ 'detailsSummary',
105
+ 'detailsContent',
106
+ 'image',
107
+ 'table',
108
+ 'tableRow',
109
+ 'tableHeader',
110
+ 'tableCell',
111
+ ]);
112
+ const MARKDOWN_SAFE_MARKS = new Set(['bold', 'italic', 'strike', 'code', 'link']);
113
+ const isMergedCell = (node) => [node.attrs?.colspan, node.attrs?.rowspan].some((span) => typeof span === 'number' && span > 1);
114
+ export const findMarkdownLossyContent = (root) => {
115
+ const lossyContent = new Set();
116
+ const visit = (node) => {
117
+ if (!MARKDOWN_SAFE_NODES.has(node.type)) {
118
+ lossyContent.add(node.type);
119
+ }
120
+ if (isMergedCell(node)) {
121
+ lossyContent.add('merged table cell');
122
+ }
123
+ for (const mark of node.marks ?? []) {
124
+ if (!MARKDOWN_SAFE_MARKS.has(mark.type)) {
125
+ lossyContent.add(mark.type);
126
+ }
127
+ }
128
+ node.content?.forEach(visit);
129
+ };
130
+ visit(root);
131
+ return [...lossyContent];
132
+ };
133
+ export class DocmostError extends Error {
134
+ }
135
+ const readErrorMessage = async (response) => {
136
+ const rawBody = await response.text();
137
+ try {
138
+ const parsedBody = errorBodySchema.safeParse(JSON.parse(rawBody));
139
+ if (parsedBody.success) {
140
+ const { message } = parsedBody.data;
141
+ return Array.isArray(message) ? message.join('; ') : message;
142
+ }
143
+ }
144
+ catch {
145
+ // body was not JSON; fall through to the raw text
146
+ }
147
+ return rawBody.slice(0, 300) || response.statusText;
148
+ };
149
+ const request = async (url, init) => {
150
+ try {
151
+ return await fetch(url, init);
152
+ }
153
+ catch (error) {
154
+ const reason = error instanceof Error && error.cause instanceof Error ? error.cause.message : String(error);
155
+ throw new DocmostError(`Could not reach ${url}: ${reason}`);
156
+ }
157
+ };
158
+ const EMPTY_TABLE_ROW = /^\|(?:\s*\|)+$/;
159
+ const TABLE_SEPARATOR_ROW = /^\|(?:\s*:?-+:?\s*\|)+$/;
160
+ const TABLE_ROW = /^\|.*\|$/;
161
+ // Docmost exports a header row as an empty header followed by that row in the body; writing it back would add a blank header row.
162
+ export const restoreTableHeaders = (markdown) => {
163
+ const lines = markdown.split('\n');
164
+ for (let lineIndex = 0; lineIndex + 2 < lines.length; lineIndex++) {
165
+ const headerRow = lines[lineIndex] ?? '';
166
+ const separatorRow = lines[lineIndex + 1] ?? '';
167
+ const firstBodyRow = lines[lineIndex + 2] ?? '';
168
+ if (EMPTY_TABLE_ROW.test(headerRow) && TABLE_SEPARATOR_ROW.test(separatorRow) && TABLE_ROW.test(firstBodyRow)) {
169
+ lines.splice(lineIndex, 3, firstBodyRow, separatorRow);
170
+ }
171
+ }
172
+ return lines.join('\n');
173
+ };
174
+ const toPage = ({ content, ...page }) => ({
175
+ ...page,
176
+ markdown: typeof content === 'string' ? restoreTableHeaders(content) : '',
177
+ });
178
+ export const normalizePageReference = (pageReference) => {
179
+ const trimmedReference = pageReference.trim();
180
+ const pathMatch = trimmedReference.match(/\/p\/([^/?#]+)/);
181
+ if (!pathMatch?.[1]) {
182
+ return trimmedReference;
183
+ }
184
+ const pageSlug = pathMatch[1];
185
+ return pageSlug.slice(pageSlug.lastIndexOf('-') + 1);
186
+ };
187
+ export const createDocmostClient = (config) => {
188
+ let tokenPromise;
189
+ const readCachedToken = async () => {
190
+ try {
191
+ const cachedSession = sessionFileSchema.safeParse(JSON.parse(await readFile(config.sessionFile, 'utf8')));
192
+ if (cachedSession.success &&
193
+ cachedSession.data.baseUrl === config.baseUrl &&
194
+ cachedSession.data.email === config.email) {
195
+ return cachedSession.data.token;
196
+ }
197
+ }
198
+ catch {
199
+ // no usable cached session; a fresh login follows
200
+ }
201
+ return undefined;
202
+ };
203
+ const login = async () => {
204
+ const response = await request(`${config.baseUrl}/api/auth/login`, {
205
+ method: 'POST',
206
+ headers: { 'content-type': 'application/json' },
207
+ body: JSON.stringify({ email: config.email, password: config.password }),
208
+ });
209
+ if (!response.ok) {
210
+ throw new DocmostError(`Docmost login failed (${response.status}): ${await readErrorMessage(response)}`);
211
+ }
212
+ const tokenCookie = response.headers
213
+ .getSetCookie()
214
+ .find((cookie) => cookie.startsWith('authToken='));
215
+ const token = tokenCookie?.slice('authToken='.length).split(';')[0];
216
+ if (!token) {
217
+ const loginBody = loginBodySchema.safeParse(await response.json().catch(() => undefined));
218
+ const needsMfa = loginBody.success && (loginBody.data.data?.userHasMfa || loginBody.data.data?.requiresMfaSetup);
219
+ throw new DocmostError(needsMfa
220
+ ? 'Docmost login needs MFA for this account, which this server cannot complete; use an account without MFA.'
221
+ : 'Docmost login returned no session token.');
222
+ }
223
+ await mkdir(dirname(config.sessionFile), { recursive: true, mode: 0o700 })
224
+ .then(() => writeFile(config.sessionFile, JSON.stringify({ baseUrl: config.baseUrl, email: config.email, token }), {
225
+ mode: 0o600,
226
+ }))
227
+ .catch(() => undefined);
228
+ return token;
229
+ };
230
+ const setTokenPromise = (nextToken) => {
231
+ tokenPromise = nextToken;
232
+ nextToken.catch(() => {
233
+ if (tokenPromise === nextToken) {
234
+ tokenPromise = undefined;
235
+ }
236
+ });
237
+ return nextToken;
238
+ };
239
+ const getToken = () => tokenPromise ?? setTokenPromise(readCachedToken().then((cachedToken) => cachedToken ?? login()));
240
+ const post = async (endpoint, body, responseSchema) => {
241
+ const send = (token) => request(`${config.baseUrl}/api${endpoint}`, {
242
+ method: 'POST',
243
+ headers: { 'content-type': 'application/json', authorization: `Bearer ${token}` },
244
+ body: JSON.stringify(body),
245
+ });
246
+ const usedToken = getToken();
247
+ let response = await send(await usedToken);
248
+ if (response.status === 401) {
249
+ const freshToken = tokenPromise === usedToken ? setTokenPromise(login()) : getToken();
250
+ response = await send(await freshToken);
251
+ }
252
+ if (!response.ok) {
253
+ throw new DocmostError(`Docmost ${endpoint} failed (${response.status}): ${await readErrorMessage(response)}`);
254
+ }
255
+ const envelope = z.object({ data: z.unknown() }).safeParse(await response.json().catch(() => undefined));
256
+ const parsedData = responseSchema.safeParse(envelope.success ? envelope.data.data : undefined);
257
+ if (!parsedData.success) {
258
+ throw new DocmostError(`Unexpected response from Docmost ${endpoint}: ${z.prettifyError(parsedData.error)}`);
259
+ }
260
+ return parsedData.data;
261
+ };
262
+ const collectAllPages = async (endpoint, body, itemSchema) => {
263
+ const collectedItems = [];
264
+ let cursor;
265
+ do {
266
+ const result = await post(endpoint, { ...body, limit: PAGE_SIZE, cursor }, paginatedSchema(itemSchema));
267
+ collectedItems.push(...result.items);
268
+ cursor = result.meta.hasNextPage ? (result.meta.nextCursor ?? undefined) : undefined;
269
+ } while (cursor && collectedItems.length < MAX_LIST_ITEMS);
270
+ return collectedItems;
271
+ };
272
+ const pageUrl = (slugId) => `${config.baseUrl}/p/${slugId}`;
273
+ const listSpaces = () => collectAllPages('/spaces', {}, spaceSchema);
274
+ const searchPages = async (query, spaceId, limit = 20) => {
275
+ const result = await post('/search', { query, spaceId, limit }, z.object({ items: z.array(searchResultSchema) }));
276
+ return result.items;
277
+ };
278
+ const getPage = async (pageId) => toPage(await post('/pages/info', { pageId: normalizePageReference(pageId), format: 'markdown' }, pageSchema));
279
+ const resolvePageId = async (pageReference) => {
280
+ const normalizedReference = normalizePageReference(pageReference);
281
+ return UUID_PATTERN.test(normalizedReference) ? normalizedReference : (await getPage(normalizedReference)).id;
282
+ };
283
+ const listChildPages = async (target) => collectAllPages('/pages/sidebar-pages', 'spaceId' in target ? { spaceId: target.spaceId } : { pageId: await resolvePageId(target.parentPageId) }, treePageSchema);
284
+ const createPage = async (input) => {
285
+ let { spaceId, parentPageId } = input;
286
+ if (parentPageId) {
287
+ const parentPage = await getPage(parentPageId);
288
+ if (spaceId && spaceId !== parentPage.spaceId) {
289
+ throw new DocmostError(`Parent page ${parentPageId} is in space ${parentPage.spaceId}, not ${spaceId}.`);
290
+ }
291
+ parentPageId = parentPage.id;
292
+ spaceId = parentPage.spaceId;
293
+ }
294
+ if (!spaceId) {
295
+ throw new DocmostError('Provide spaceId, parentPageId, or both.');
296
+ }
297
+ return toPage(await post('/pages/create', { spaceId, parentPageId, title: input.title, icon: input.icon, content: input.markdown, format: 'markdown' }, pageSchema));
298
+ };
299
+ const updatePage = async (input) => {
300
+ if (input.markdown !== undefined && input.operation === 'replace') {
301
+ const expectedTime = input.expectedUpdatedAt === undefined ? undefined : Date.parse(input.expectedUpdatedAt);
302
+ if (Number.isNaN(expectedTime)) {
303
+ throw new DocmostError(`expectedUpdatedAt "${input.expectedUpdatedAt}" is not a timestamp; pass updatedAt from get_page.`);
304
+ }
305
+ const currentPage = await post('/pages/info', { pageId: normalizePageReference(input.pageId) }, editorPageSchema);
306
+ if (expectedTime !== undefined && Date.parse(currentPage.updatedAt ?? '') !== expectedTime) {
307
+ throw new DocmostError(`Page changed at ${currentPage.updatedAt ?? 'an unknown time'} (you read ${input.expectedUpdatedAt}); re-read it with get_page before replacing.`);
308
+ }
309
+ const lossyContent = currentPage.content ? findMarkdownLossyContent(currentPage.content) : [];
310
+ if (lossyContent.length > 0) {
311
+ throw new DocmostError(`Refused: ${currentPage.title ?? currentPage.id} holds content Markdown cannot carry (${lossyContent.join(', ')}), which rewriting the body would delete. Use append or prepend, or edit it in Docmost.`);
312
+ }
313
+ }
314
+ const contentFields = input.markdown === undefined
315
+ ? {}
316
+ : { content: input.markdown, operation: input.operation, format: 'markdown' };
317
+ return toPage(await post('/pages/update', { pageId: normalizePageReference(input.pageId), title: input.title, icon: input.icon, ...contentFields }, pageSchema));
318
+ };
319
+ const editPage = async (input) => {
320
+ const currentPage = await getPage(input.pageId);
321
+ const oldText = input.oldText.replaceAll('\r\n', '\n');
322
+ const bodyParts = currentPage.markdown.split(oldText);
323
+ const replacements = bodyParts.length - 1;
324
+ if (replacements === 0) {
325
+ throw new DocmostError(`oldText not found in ${currentPage.title ?? currentPage.id}; re-read the page with get_page and copy the text exactly.`);
326
+ }
327
+ if (replacements > 1 && !input.replaceAll) {
328
+ throw new DocmostError(`oldText appears ${replacements} times; include more surrounding text or set replaceAll.`);
329
+ }
330
+ const page = await updatePage({
331
+ pageId: currentPage.id,
332
+ markdown: bodyParts.join(input.newText.replaceAll('\r\n', '\n')),
333
+ operation: 'replace',
334
+ });
335
+ return { page, replacements };
336
+ };
337
+ return { pageUrl, listSpaces, listChildPages, searchPages, getPage, createPage, updatePage, editPage };
338
+ };
339
+ //# sourceMappingURL=docmost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docmost.js","sourceRoot":"","sources":["../src/docmost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,YAAY,GAAG,iEAAiE,CAAC;AAEvF,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAA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AG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;YAC1C,MAAM,IAAI,YAAY,CAAC,mBAAmB,YAAY,0DAA0D,CAAC,CAAC;QACpH,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC;YAC5B,MAAM,EAAE,WAAW,CAAC,EAAE;YACtB,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAChE,SAAS,EAAE,SAAS;SACrB,CAAC,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAChC,CAAC,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;AACzG,CAAC,CAAC"}
package/build/index.js ADDED
@@ -0,0 +1,203 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { z } from 'zod';
5
+ import { loadConfig } from './config.js';
6
+ import { createDocmostClient } from './docmost.js';
7
+ let docmostClient;
8
+ const getClient = () => {
9
+ docmostClient ??= createDocmostClient(loadConfig());
10
+ return docmostClient;
11
+ };
12
+ const runTool = async (action) => {
13
+ try {
14
+ return { content: [{ type: 'text', text: await action(getClient()) }] };
15
+ }
16
+ catch (error) {
17
+ const message = error instanceof Error ? error.message : String(error);
18
+ return { content: [{ type: 'text', text: message }], isError: true };
19
+ }
20
+ };
21
+ const toJson = (value) => JSON.stringify(value, null, 2);
22
+ const summarizePage = (client, page) => ({
23
+ id: page.id,
24
+ slugId: page.slugId,
25
+ title: page.title,
26
+ spaceId: page.spaceId,
27
+ parentPageId: page.parentPageId ?? null,
28
+ url: client.pageUrl(page.slugId),
29
+ updatedAt: page.updatedAt ?? null,
30
+ });
31
+ const DEFAULT_LINE_LIMIT = 500;
32
+ const MAX_WINDOW_CHARACTERS = 100_000;
33
+ const sliceLines = (markdown, offset, limit) => {
34
+ const lines = markdown === '' ? [] : markdown.split('\n');
35
+ const windowLines = [];
36
+ let characterCount = 0;
37
+ for (const line of lines.slice(offset - 1, offset - 1 + limit)) {
38
+ if (characterCount + line.length > MAX_WINDOW_CHARACTERS) {
39
+ if (windowLines.length === 0) {
40
+ windowLines.push(line.slice(0, MAX_WINDOW_CHARACTERS));
41
+ }
42
+ break;
43
+ }
44
+ windowLines.push(line);
45
+ characterCount += line.length + 1;
46
+ }
47
+ const lastLine = offset - 1 + windowLines.length;
48
+ return {
49
+ body: windowLines.join('\n'),
50
+ firstLine: offset,
51
+ lastLine,
52
+ totalLines: lines.length,
53
+ nextOffset: lastLine < lines.length ? lastLine + 1 : null,
54
+ };
55
+ };
56
+ const pageReferenceSchema = z
57
+ .string()
58
+ .min(1)
59
+ .describe('Page id, slug id, or the full page URL copied from the browser.');
60
+ const readOnlyAnnotations = { readOnlyHint: true, openWorldHint: true };
61
+ const server = new McpServer({ name: 'docmost', version: '0.2.0' }, {
62
+ instructions: 'Docmost wiki access. Every page argument accepts a page id, slug id or page URL. Read a page with get_page before changing it. For small changes use edit_page with text copied exactly from get_page output. For whole-body rewrites use update_page with operation replace and pass the updatedAt from your read as expectedUpdatedAt. Markdown bodies must not repeat the page title as a leading # heading.',
63
+ });
64
+ server.registerTool('list_spaces', {
65
+ title: 'List Docmost spaces',
66
+ description: 'Lists the Docmost spaces this account can see, with the space ids the other tools take.',
67
+ inputSchema: {},
68
+ annotations: readOnlyAnnotations,
69
+ }, () => runTool(async (client) => toJson(await client.listSpaces())));
70
+ server.registerTool('list_pages', {
71
+ title: 'List Docmost pages',
72
+ description: 'Lists the top-level pages of a space, or the direct children of a page when parentPageId is given.',
73
+ inputSchema: {
74
+ spaceId: z.string().optional().describe('Space id from list_spaces; lists the root pages of that space.'),
75
+ parentPageId: pageReferenceSchema.optional().describe('Lists the direct children of this page instead.'),
76
+ },
77
+ annotations: readOnlyAnnotations,
78
+ }, ({ spaceId, parentPageId }) => runTool(async (client) => {
79
+ if (!spaceId && !parentPageId) {
80
+ throw new Error('Provide spaceId or parentPageId.');
81
+ }
82
+ const pages = await client.listChildPages(parentPageId ? { parentPageId } : { spaceId: spaceId ?? '' });
83
+ return toJson(pages.map((page) => ({
84
+ id: page.id,
85
+ slugId: page.slugId,
86
+ title: page.title,
87
+ hasChildren: page.hasChildren ?? false,
88
+ url: client.pageUrl(page.slugId),
89
+ })));
90
+ }));
91
+ server.registerTool('search_pages', {
92
+ title: 'Search Docmost pages',
93
+ description: 'Full-text searches page titles and bodies, optionally within one space.',
94
+ inputSchema: {
95
+ query: z.string().min(1).max(200).describe('Words to search for.'),
96
+ spaceId: z.string().optional().describe('Restrict the search to this space id.'),
97
+ limit: z.number().int().min(1).max(100).optional().describe('Maximum results to return; defaults to 20.'),
98
+ },
99
+ annotations: readOnlyAnnotations,
100
+ }, ({ query, spaceId, limit }) => runTool(async (client) => {
101
+ const results = await client.searchPages(query, spaceId, limit);
102
+ return toJson(results.map((result) => ({
103
+ id: result.id,
104
+ slugId: result.slugId,
105
+ title: result.title,
106
+ space: result.space?.name ?? null,
107
+ highlight: result.highlight ?? null,
108
+ url: result.slugId ? client.pageUrl(result.slugId) : null,
109
+ })));
110
+ }));
111
+ server.registerTool('get_page', {
112
+ title: 'Read a Docmost page',
113
+ description: 'Returns a window of a page as Markdown along with its id, space, parent, URL and line counts.',
114
+ inputSchema: {
115
+ pageId: pageReferenceSchema,
116
+ offset: z.number().int().min(1).optional().describe('First line to return, starting at 1; defaults to 1.'),
117
+ limit: z
118
+ .number()
119
+ .int()
120
+ .min(1)
121
+ .max(2000)
122
+ .optional()
123
+ .describe(`Number of lines to return; defaults to ${DEFAULT_LINE_LIMIT}.`),
124
+ },
125
+ annotations: readOnlyAnnotations,
126
+ }, ({ pageId, offset, limit }) => runTool(async (client) => {
127
+ const page = await client.getPage(pageId);
128
+ const window = sliceLines(page.markdown, offset ?? 1, limit ?? DEFAULT_LINE_LIMIT);
129
+ const header = toJson({
130
+ ...summarizePage(client, page),
131
+ totalLines: window.totalLines,
132
+ nextOffset: window.nextOffset,
133
+ });
134
+ const continuation = window.nextOffset === null
135
+ ? ''
136
+ : `\n\n[lines ${window.firstLine}–${window.lastLine} of ${window.totalLines}; call get_page with offset ${window.nextOffset} for more]`;
137
+ return `${header}\n\n---\n\n${window.body}${continuation}`;
138
+ }));
139
+ server.registerTool('create_page', {
140
+ title: 'Create a Docmost page',
141
+ description: 'Creates a page from Markdown at the root of a space or under a parent page, and returns its URL.',
142
+ inputSchema: {
143
+ title: z.string().min(1).describe('Page title.'),
144
+ markdown: z.string().describe('Page body in Markdown; do not repeat the title as a leading # heading.'),
145
+ spaceId: z.string().optional().describe('Space id from list_spaces; optional when parentPageId is given.'),
146
+ parentPageId: pageReferenceSchema.optional().describe('Create the page under this page instead of at the space root.'),
147
+ icon: z.string().optional().describe('Optional emoji shown next to the title.'),
148
+ },
149
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
150
+ }, ({ title, markdown, spaceId, parentPageId, icon }) => runTool(async (client) => toJson(summarizePage(client, await client.createPage({ title, markdown, spaceId, parentPageId, icon })))));
151
+ server.registerTool('update_page', {
152
+ title: 'Update a Docmost page',
153
+ description: 'Replaces, appends to or prepends to a page body in Markdown, and can rename it or change its icon; a replace is refused on pages holding content Markdown cannot carry, such as mentions or comments.',
154
+ inputSchema: {
155
+ pageId: pageReferenceSchema,
156
+ markdown: z.string().min(1).optional().describe('New Markdown content; omit to change only the title or icon.'),
157
+ operation: z
158
+ .enum(['replace', 'append', 'prepend'])
159
+ .optional()
160
+ .describe('How markdown is applied to the existing body; defaults to replace.'),
161
+ title: z.string().min(1).optional().describe('New page title.'),
162
+ icon: z.string().optional().describe('New emoji icon.'),
163
+ expectedUpdatedAt: z
164
+ .string()
165
+ .optional()
166
+ .describe('updatedAt from your last get_page; a replace is refused if the page changed since.'),
167
+ },
168
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
169
+ }, ({ pageId, markdown, operation, title, icon, expectedUpdatedAt }) => runTool(async (client) => {
170
+ if (markdown === undefined && title === undefined && icon === undefined) {
171
+ throw new Error('Provide at least one of markdown, title or icon.');
172
+ }
173
+ const updatedPage = await client.updatePage({
174
+ pageId,
175
+ markdown,
176
+ operation: operation ?? 'replace',
177
+ title,
178
+ icon,
179
+ expectedUpdatedAt,
180
+ });
181
+ return toJson(summarizePage(client, updatedPage));
182
+ }));
183
+ server.registerTool('edit_page', {
184
+ title: 'Edit a Docmost page',
185
+ description: 'Replaces an exact piece of text in a page body with new Markdown by rewriting the whole body, and is refused on pages holding content Markdown cannot carry, such as mentions or comments.',
186
+ inputSchema: {
187
+ pageId: pageReferenceSchema,
188
+ oldText: z.string().min(1).describe('Exact text to replace, copied from get_page output; must match once unless replaceAll is set.'),
189
+ newText: z.string().describe('Replacement Markdown; an empty string deletes oldText.'),
190
+ replaceAll: z.boolean().optional().describe('Replace every occurrence of oldText; defaults to false.'),
191
+ },
192
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
193
+ }, ({ pageId, oldText, newText, replaceAll }) => runTool(async (client) => {
194
+ const { page, replacements } = await client.editPage({
195
+ pageId,
196
+ oldText,
197
+ newText,
198
+ replaceAll: replaceAll ?? false,
199
+ });
200
+ return toJson({ ...summarizePage(client, page), replacements });
201
+ }));
202
+ await server.connect(new StdioServerTransport());
203
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;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O,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;IACvB,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;QACnD,MAAM;QACN,OAAO;QACP,OAAO;QACP,UAAU,EAAE,UAAU,IAAI,KAAK;KAChC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,EAAE,GAAG,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;AAClE,CAAC,CAAC,CACL,CAAC;AAEF,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,50 @@
1
1
  {
2
2
  "name": "@punyamsingh/docmost-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "description": "MCP server for self-hosted Docmost: read, search, create and update pages in Markdown",
5
+ "type": "module",
6
+ "main": "./build/index.js",
7
+ "bin": {
8
+ "docmost-mcp": "build/index.js"
9
+ },
10
+ "files": [
11
+ "build/**/*",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "keywords": [
16
+ "mcp",
17
+ "docmost",
18
+ "model-context-protocol",
19
+ "wiki",
20
+ "markdown"
21
+ ],
22
+ "author": "Punyam Singh",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/punyamsingh/docmost-mcp.git"
27
+ },
28
+ "homepage": "https://github.com/punyamsingh/docmost-mcp#readme",
29
+ "bugs": {
30
+ "url": "https://github.com/punyamsingh/docmost-mcp/issues"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "engines": {
36
+ "node": ">=20.12.0"
37
+ },
38
+ "dependencies": {
39
+ "@modelcontextprotocol/sdk": "^1.32.1",
40
+ "zod": "^4.6.7"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^24.19.2",
44
+ "typescript": "^5.9.3"
45
+ },
46
+ "scripts": {
47
+ "build": "tsc && node -e \"require('fs').chmodSync('build/index.js', 0o755)\"",
48
+ "start": "node build/index.js"
49
+ }
6
50
  }