Replace the removed enterprise EE MCP (private apps/server/src/ee submodule,
license-gated /mcp route) with our docmost-mcp, vendored as an isolated ESM
workspace package and served by the server over HTTP — no enterprise license.
Backend:
- Add packages/mcp (@docmost/mcp): vendored docmost-mcp refactored into a
side-effect-free createDocmostMcpServer() factory (38 tools preserved),
stdio entry kept in stdio.ts, Streamable-HTTP session manager in http.ts.
- Add apps/server McpModule: @Post/@Get/@Delete('mcp') (served at /mcp via the
existing global-prefix exclude), @SkipTransform + reply.hijack to bridge raw
Fastify req/res into the SDK transport. The module dynamically imports the
ESM-only package from CommonJS via a Function-indirected import resolved with
require.resolve + file:// URL. Gated by the workspace ai.mcp toggle, a
service-account (MCP_DOCMOST_EMAIL/PASSWORD/API_URL) and optional MCP_TOKEN;
per-session idle eviction (MCP_SESSION_IDLE_MS).
- Drop the enterprise license check on mcpEnabled in workspace.service.
- Dockerfile: copy packages/mcp into the production image.
- .env.example: document MCP_DOCMOST_*, MCP_TOKEN, MCP_SESSION_IDLE_MS.
Frontend:
- Recreate the community "AI & MCP" workspace-settings panel (mcp-settings.tsx):
admin-only toggle on settings.ai.mcp with optimistic update, copyable
${APP_URL}/mcp URL; wired into workspace-settings page. Reuses existing i18n.
Fixes:
- Pin packages/mcp tiptap deps to 3.20.4 (matching the client) and inline
getStyleProperty, preventing a duplicate @tiptap/core@3.26.1 from leaking into
the client editor via pnpm shamefully-hoist (was breaking apps/client tsc).
78 lines
2.8 KiB
JavaScript
78 lines
2.8 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
docmostExtensions,
|
|
clampCalloutType,
|
|
} from "../../build/lib/docmost-schema.js";
|
|
import { TiptapTransformer } from "@hocuspocus/transformer";
|
|
|
|
test("clampCalloutType: a known type passes through", () => {
|
|
assert.equal(clampCalloutType("warning"), "warning");
|
|
});
|
|
|
|
test("clampCalloutType: an uppercase known type folds to lower case", () => {
|
|
assert.equal(clampCalloutType("WARNING"), "warning");
|
|
assert.equal(clampCalloutType("Info"), "info");
|
|
});
|
|
|
|
test("clampCalloutType: an unknown type falls back to info", () => {
|
|
assert.equal(clampCalloutType("bogus"), "info");
|
|
});
|
|
|
|
test("clampCalloutType: null and undefined fall back to info", () => {
|
|
assert.equal(clampCalloutType(null), "info");
|
|
assert.equal(clampCalloutType(undefined), "info");
|
|
});
|
|
|
|
// Minimal-doc builders for the toYdoc acceptance loop.
|
|
const text = (t) => ({ type: "text", text: t });
|
|
const paragraph = (inline) => ({ type: "paragraph", content: inline });
|
|
const docOf = (...content) => ({ type: "doc", content });
|
|
|
|
// Each entry is a minimal valid doc for one Docmost node type. Inline atoms
|
|
// (mention, mathInline) and inline-capable nodes go inside a paragraph; block
|
|
// atoms and block containers go at the top level.
|
|
const cases = {
|
|
mention: docOf(
|
|
paragraph([{ type: "mention", attrs: { id: "u1", label: "Bob" } }]),
|
|
),
|
|
mathInline: docOf(paragraph([{ type: "mathInline", attrs: { text: "x^2" } }])),
|
|
mathBlock: docOf({ type: "mathBlock", attrs: { text: "x^2" } }),
|
|
details: docOf({
|
|
type: "details",
|
|
content: [
|
|
{ type: "detailsSummary", content: [text("Summary")] },
|
|
{ type: "detailsContent", content: [paragraph([text("body")])] },
|
|
],
|
|
}),
|
|
attachment: docOf({
|
|
type: "attachment",
|
|
attrs: { url: "http://x/f.zip", name: "f.zip" },
|
|
}),
|
|
video: docOf({ type: "video", attrs: { src: "http://x/v.mp4" } }),
|
|
youtube: docOf({ type: "youtube", attrs: { src: "http://y/watch" } }),
|
|
embed: docOf({ type: "embed", attrs: { src: "http://e", provider: "iframe" } }),
|
|
drawio: docOf({ type: "drawio", attrs: { src: "http://d" } }),
|
|
excalidraw: docOf({ type: "excalidraw", attrs: { src: "http://e" } }),
|
|
columns: docOf({
|
|
type: "columns",
|
|
content: [
|
|
{ type: "column", content: [paragraph([text("c1")])] },
|
|
{ type: "column", content: [paragraph([text("c2")])] },
|
|
],
|
|
}),
|
|
subpages: docOf({ type: "subpages" }),
|
|
audio: docOf({ type: "audio", attrs: { src: "http://a.mp3" } }),
|
|
pdf: docOf({ type: "pdf", attrs: { src: "http://p.pdf" } }),
|
|
pageBreak: docOf({ type: "pageBreak" }),
|
|
};
|
|
|
|
for (const [name, doc] of Object.entries(cases)) {
|
|
test(`toYdoc accepts a ${name} node without throwing`, () => {
|
|
assert.doesNotThrow(() => {
|
|
TiptapTransformer.toYdoc(doc, "default", docmostExtensions);
|
|
});
|
|
});
|
|
}
|