Doco
Doco
📖 中文版
人类与 AI 智能体共同写作的文档空间。 一款开源富文本协作编辑器,将数据掌控权交还给你——并以同样的用心对待你的 AI 智能体:块级稳定寻址、乐观并发控制,以及一个包含 29 个工具的 MCP 服务器,让智能体像一位细心的人类编辑一样安全地读写你的知识库。
在线版: doco.page — 测试期间免费
连接你的智能体:
claude mcp add doco -- npx -y --package doco-agent-cli doco mcpCLI:
npm i -g doco-agent-cli && doco loginnpm: doco-agent-cli · API 文档: doco.page/api-docs
Claude Code 插件市场
/plugin marketplace add songofhawk/doco
/plugin install doco@doco该市场捆绑了 Doco MCP 服务器以及安全的 读取 → 版本校验 → 受保护写入 操作协议。令牌保留在 Claude Code 的本地配置中,绝不会包含在插件仓库内。

为什么智能体在这里是安全的
能力 | 含义 |
块级稳定寻址 | 每个段落都有一个 |
乐观并发 | 读取返回 |
Markdown 往返 | 使用 |
人机协同编辑 | 智能体的写入流经同一个 Yjs 文档——更改在浏览器中实时呈现 |
事务与幂等性 | 批量操作原子提交; |
Related MCP server: Writespace
功能特性
编辑体验
富文本编辑:标题、列表、引用块、任务列表、代码块(语法高亮)、表格、图片、链接、文本样式等
/斜杠命令:输入/打开带模糊搜索的命令面板——支持中文拼音缩写浮动工具栏:选中文本时自动出现,所有格式化操作都在光标两厘米范围内
块拖拽:悬停任意段落左侧边缘即可显示拖拽手柄——像搭积木一样重排内容
可折叠区块:折叠暂不处理的部分;折叠状态在会话间保持
标题自动编号:一键切换——H1–H4 标题自动维护层级编号(
1.1.11.1.1)键盘快捷键:
⌥↑/↓移动块,⌘D复制块,⌘⌥1/2/3/0切换标题级别
文本转图表
直接在文档中编写 Mermaid 或 PlantUML 源代码。图表就地渲染。双击编辑、全屏查看、双指缩放——告别 draw.io 的导出-导入-替换循环。
Mermaid:流程图、时序图、类图、甘特图、状态图等
PlantUML:时序图、类图、用例图、组件图等
电子表格
内嵌于文档中的完整电子表格引擎:
公式计算、单元格格式化
冻结窗格、排序与筛选
单元格合并 / 拆分
CSV 导入 / 导出
可内联作为内容块使用,也可弹出为独立的全屏电子表格。
知识库
知识库 → 文件夹(可嵌套)→ 文档——三级结构
侧边栏中拖拽重排、重命名和移动
整个知识库 ZIP 导出,保留文件夹层级并打包图片
支持文档、文件夹或整个知识库的无损原生
.doco.zip传输
实时协作
基于 Yjs CRDT 算法构建:
无需保存按钮——更改自动同步
离线优先:浏览器 IndexedDB 是主存储;服务器保存快照。无网络也能编辑,重新连接后自动合并
无缝设备切换:合上笔记本电脑,拿起手机,继续写作
导入 / 导出
格式 | 导入 | 导出 |
Doco 原生包 | ✅ 文档 / 文件夹 / 知识库 | ✅ 无损文档 / 文件夹 / 知识库 |
Markdown | ✅ 粘贴 / 文件上传 | ✅ 单文档与知识库打包 |
Word (DOCX) | ✅ | ✅ |
✅ | ✅ | |
HTML | ✅ | — |
微信公众号 | — | ✅(带主题预览) |
图片(文档内) | ✅(粘贴 / 拖拽) | ✅(打包在 ZIP 中) |
API · MCP · CLI
三个通道,同一契约:
REST API:OpenAPI 3.1 规范、Bearer Token 认证、ETag 版本控制、游标分页、幂等键
MCP 服务器:
doco mcp(随doco-agent-cli内置)——29 个工具及doco://资源doco CLI:
login / whoami / docs / blocks / edit / mcp,全局--json,写入时自动处理 ETag/If-Match
将你的文档变成可编程资产——编写自己的备份脚本,让智能体整理你的知识库,将发布工作流中的文档直接推送到博客。内置 API 文档页面,开箱即用。
技术栈
层级 | 技术 |
前端框架 | React 18 + Vite + TypeScript |
CSS | Tailwind CSS v4 |
编辑器 | Tiptap v3 (ProseMirror) |
协作 | Yjs (CRDT) + Hocuspocus |
图表 | Mermaid + PlantUML |
后端 | Node.js + Express + Hocuspocus Server |
数据库 | better-sqlite3 (SQLite, WAL 模式) |
UI 组件 | Radix UI, Lucide React, Tippy.js |
快速开始
前置要求
Node.js >= 22
pnpm
安装与运行
# Install frontend dependencies
pnpm install
# Install backend dependencies
cd backend && npm install && cd ..
# Start the frontend dev server (Vite, default :5173)
pnpm run dev
# In another terminal, start the backend (Express + WebSocket, default :8000)
cd backend
npm run dev打开 http://localhost:5173——它将自动连接后端 WebSocket 服务。
Docker 部署(推荐)
完整的自托管方案包含 Caddy 前端、Node.js 协作后端、持久化 SQLite 存储、健康检查以及同源 WebSocket 代理。公开镜像同时支持 linux/amd64 和 linux/arm64。
git clone https://github.com/songofhawk/doco.git
cd doco
cp .env.docker.example .env.docker
# Review .env.docker first, then start with prebuilt Docker Hub images
docker compose --env-file .env.docker up -d
# Verify the deployment
docker compose --env-file .env.docker ps
curl --fail http://localhost:8080/healthz默认打开 http://localhost:8080。在 .env.docker 中为你的环境设置 ALLOWED_ORIGINS、COOKIE_SECURE、Google OAuth 和 SMTP 值。这些值在容器启动时注入,不会烘焙进镜像。应用数据存储在 doco-data 命名卷中。
Docker Hub:songofhawkg/doco-frontend · songofhawkg/doco-backend
如需从源码构建相同镜像:
docker compose --env-file .env.docker up -d --build所有配置选项、HTTPS、日志、备份、恢复和升级,请参阅 Docker 部署指南。除非你确实打算删除数据库和附件,否则不要运行 docker compose down -v。
手动构建与部署
# Frontend build
pnpm run build # output → dist/
pnpm run deploy # deploy to Cloudflare Pages
# Backend (production)
cd backend
npm start项目结构
doco/
├── src/
│ ├── main.tsx # App entry point
│ ├── App.tsx # Root component, routing, import/export
│ ├── components/
│ │ └── Sidebar.tsx # KB sidebar (document tree)
│ └── editor/ # Editor module
│ ├── index.ts # Entry, exports DocoEditor component
│ ├── DocoEditor.tsx # Editor core (Yjs/Hocuspocus init, extension registration)
│ ├── types.ts # DocoEditor Props/Ref type definitions
│ └── components/
│ ├── BubbleMenu.tsx # Selection floating toolbar
│ ├── BlockHandle.tsx # Block drag handle
│ ├── SlashCommand.ts # / command palette
│ ├── CommandList.tsx # Command palette UI
│ ├── suggestions.ts # Command menu data
│ ├── CollapseExtension.ts # Block collapse extension
│ ├── DocSettings.tsx # Document settings (heading numbering, background)
│ ├── MermaidBlock.ts # Mermaid node definition
│ ├── MermaidComponent.tsx # Mermaid renderer
│ ├── PlantUMLBlock.ts # PlantUML node definition
│ ├── PlantUMLComponent.tsx # PlantUML renderer
│ ├── CalloutBlock.ts # Callout block definition
│ ├── CalloutComponent.tsx # Callout renderer
│ ├── SpreadsheetBlock.ts # Spreadsheet node definition
│ ├── SpreadsheetComponent.tsx # Spreadsheet renderer
│ ├── spreadsheetEngine.ts # Spreadsheet calculation engine
│ ├── WeChatExportDialog.tsx # WeChat Official Account export
│ ├── KeyboardShortcuts.ts # Keyboard shortcuts
│ ├── TableOfContents.tsx # Table of contents
│ ├── CodeBlockComponent.tsx # Code block (highlight + copy)
│ └── ImageComponent.tsx # Image renderer
├── backend/
│ ├── server.js # Entry: Express + Hocuspocus + export routes
│ ├── database.js # better-sqlite3 init & schema
│ ├── api.js # KB / folder / document REST API
│ ├── auth.js # Auth (OAuth + Email + API Token)
│ ├── markdown.js # YDoc → Markdown server-side export
│ ├── permissions.js # Permission management
│ ├── quota.js # Quota management
│ ├── openapi.js # OpenAPI spec definition
│ └── tests/ # Backend tests
└── docs/ # Design docs & proposals独立前端组件
编辑器核心也已发布为 doco-text-editor。它包含完整的 Doco 编辑体验和内置样式,但不依赖 Doco 认证、REST API、协作服务或 IndexedDB。宿主应用自行决定内容存放在内存、浏览器存储、自有后端,还是 ClickUp 等外部系统中。
npm install doco-text-editorimport { useRef } from 'react'
import {
DocoTextEditor,
type DocoTextEditorRef,
} from 'doco-text-editor'
import 'doco-text-editor/style.css'
const editorRef = useRef<DocoTextEditorRef>(null)
<DocoTextEditor
ref={editorRef}
defaultValue="# Browser-only draft"
format="markdown"
onChange={({ steps }) => {
// Only the ProseMirror steps changed by this transaction.
queueIncrementalChanges(steps)
}}
/>
// Read the complete document only when needed.
const json = editorRef.current?.getContent('tiptap-json')
const markdown = editorRef.current?.getContent('markdown')
const html = editorRef.current?.getContent('html')
const text = editorRef.current?.getContent('text')该包包含标题、行内格式、引用块、有序/无序/任务列表、代码块、图片、表格、标注、Mermaid、可选的 PlantUML 渲染以及内嵌电子表格。完整的 API 和集成说明请参阅 src/editor/README.md。
完整 Doco 编辑器组件用法
import { DocoEditor } from './editor'
import type { DocoEditorRef } from './editor/types'
const editorRef = useRef<DocoEditorRef>(null)
<DocoEditor
ref={editorRef}
docId="doc-001"
userId="user-001"
collaboration={{
websocketUrl: 'ws://localhost:8000',
}}
onTitleChange={(docId, title) => console.log('Title changed:', title)}
placeholder="Start writing…"
/>
{/* Call export methods via ref */}
<button onClick={() => editorRef.current?.exportMarkdown()}>Export MD</button>协作架构
Browser IndexedDB (y-indexeddb) ← local primary store
↕
Browser Y.Doc ← @hocuspocus/provider (WebSocket)
↕ Yjs binary delta messages
Server @hocuspocus/server → SQLite ydoc_state (one merged snapshot per doc)浏览器 IndexedDB 是主存储;服务器快照为辅助。如果服务器快照丢失,只需在浏览器中打开文档即可重新填充。
离线编辑无缝工作;网络恢复后更改自动同步。
协作光标:框架支持,默认未启用。
Markdown 导出
单文档和知识库打包均支持 Markdown 导出,由服务器端从 YDoc 实时生成:
# Single document export
curl http://localhost:8000/api/docs/{id}/export.md
# KB ZIP bundle
curl http://localhost:8000/api/kb/{id}/export.zip自定义节点(Mermaid、PlantUML、Callout 等)在 backend/markdown.js 中有对应的序列化规则。新增自定义节点时,请同步更新服务器端序列化器。
无损 Doco 传输
在文档、文件夹或知识库菜单中使用 导出 Doco 文件。生成的 .doco.zip 包含原始 Yjs 状态、层级结构、文档设置、独立电子表格和附件。导入时始终创建带有全新资源和附件 ID 的副本,因此可以在独立的 Doco 部署之间安全迁移,不会与现有数据冲突。
使用知识库标题旁的上传按钮可导入整个知识库。要导入文档或文件夹包,请从目标知识库或文件夹菜单中选择 导入 Doco 文件。
许可证
MIT
Available Tools
29 toolsdoco_batch_editDoco Batch EditADestructive
单事务批量编辑(1–100 个操作,全有或全无):operations 为 {op: insert|replace|delete, ...} 数组。base_version 必填语义由服务端强制(不填自动读取)。
Inputs: operations (required), document_id (required), base_version, idempotency_key. Returns: object
doco_changesDoco ChangesARead-onlyIdempotent
建立或增量读取文档的块级变更水位。首次不传 after 返回 manifest 与 cursor;后续传 cursor 获取 added/removed/modified/moved。sync_required=true 时必须重新读取正文并建立新基线。
Inputs: document_id (required), after, limit, locale. Returns: object
doco_conceptsDoco ConceptsARead-onlyIdempotent
统一读取概念层:列出/获取显式概念、沿概念关系遍历,或列出待审核候选。候选与显式概念严格分离。
Inputs: action (required), q, limit, cursor, +6 more. Returns: object
doco_create_documentDoco Create DocumentA
新建文档,可同时灌入初始正文(content: {format: markdown|tiptap-json|html, content|document})
Inputs: title (required), content, folder_id, idempotency_key, +1 more. Returns: object
doco_create_relationDoco Create RelationA
从稳定来源块创建一条显式、可审计的类型关系。target_uri 使用 doco://doc/{id}#block={block_id};创建前服务端校验两端权限与块存在性。
Inputs: target_uri (required), source_block_id (required), source_document_id (required), predicate, +2 more. Returns: object
doco_delete_blockDoco Delete BlockCDestructiveIdempotent
删除单个块
Inputs: block_id (required), document_id (required), base_version. Returns: object
doco_edit_conceptsDoco Edit ConceptsADestructive
统一写入显式概念:创建、更新、补来源/关系、合并,以及接受/拒绝候选。客户端自动读取 ETag、发送 If-Match,并为每次写入生成幂等键。
Inputs: action (required), name, reason, status, +9 more. Returns: object
doco_get_blocksDoco Get BlocksARead-onlyIdempotent
按块读取文档:返回顶层(或 recursive=true 时全部)块及其稳定 block_id 与 version
Inputs: document_id (required), recursive. Returns: object
doco_get_documentDoco Get DocumentARead-onlyIdempotent
读取整篇文档正文。format: markdown(读懂语义,附带 warnings 降级提示)/ tiptap-json(无损,精确编辑用)/ html。返回含 version(后续写入需携带)。annotate=anchors 时 markdown 每个顶层块带 锚点,改完整篇写回(PUT content format=markdown)可按锚点保留未改动块的 ID。
Inputs: document_id (required), format, locale, annotate. Returns: object
doco_get_treeDoco Get TreeARead-onlyIdempotent
获取一个知识库的完整目录树(文件夹 + 文档)
Inputs: kb_id (required). Returns: object
doco_insert_blocksDoco Insert BlocksA
在指定位置插入一个或多个块。position 六选一:after_block_id / before_block_id / parent_block_id(+child_index) / document_start / document_end / after_heading(按标题文本定位,服务端匹配)
Inputs: nodes (required), position (required), document_id (required), base_version. Returns: object
doco_list_documentsDoco List DocumentsARead-onlyIdempotent
按知识库 / 文件夹 / 关键词搜索文档列表(分页)
Inputs: q, limit, cursor, locale, +3 more. Returns: object
doco_list_knowledge_basesDoco List Knowledge BasesARead-onlyIdempotent
列出当前用户可见的全部知识库
Inputs: no named parameters. Returns: object
doco_outlineDoco OutlineARead-onlyIdempotent
读取文档结构大纲:每个标题以稳定 block_id、heading_path 和顶层块区间表达,适合先规划再局部读取。
Inputs: document_id (required). Returns: object
doco_patch_blockDoco Patch BlockAIdempotent
更新单个块:提供完整 node 替换,或用 attrs/content 局部修改。带 base_version 做乐观并发校验;不带则自动读取最新版本。409 时请重读合并重试。
Inputs: block_id (required), document_id (required), node, attrs, +2 more. Returns: object
doco_readDoco ReadARead-onlyIdempotent
按 token 预算局部读取文档。可用 around 锚定任意嵌套 block_id,或用 next_cursor 续读;游标绑定正文版本,read_cursor_stale 时必须重新规划。
Inputs: document_id (required), view, around, cursor, +4 more. Returns: object
doco_rebuild_summaryDoco Rebuild SummaryAIdempotent
重建摘要。deterministic 同步返回可追溯 fallback;model 只创建异步任务,必须随后用 doco_summary(job_id) 查询,来源变化或摘要被钉住时结果会 obsolete 而不会覆盖。
Inputs: target_id (required), scope, block_id, generator, +2 more. Returns: object
doco_refresh_concept_candidatesDoco Refresh Concept CandidatesAIdempotent
触发概念候选抽取/刷新。只生成待审核候选,不会直接污染显式概念层;写入自动带幂等键。
Inputs: document_id (required). Returns: object
doco_review_translation_unitDoco Review Translation UnitAIdempotent
在具体目标语言文档上确认当前译文或忽略单元;不接受机器结果直接覆盖,遇到 409 必须重读目标版本。
Inputs: unit_id (required), document_id (required), review_status (required), target_document_id (required), +2 more. Returns: object
doco_save_summaryDoco Save SummaryAIdempotent
人工编辑并可钉住摘要。客户端会先读取当前 summary/source 双版本后带保护写入;pinned 只防自动覆盖,来源变化后仍会显示 stale。
Inputs: summary (required), target_id (required), scope, pinned, +3 more. Returns: object
doco_searchDoco SearchARead-onlyIdempotent
按标题和正文全文搜索文档。正文命中返回稳定 block_id 与摘要,适合先定位再用块 API 精确读取或修改。
Inputs: q (required), limit, locale, knowledge_base_id. Returns: object
doco_search_v2Doco Search V2ARead-onlyIdempotent
带查询级完整性证明的全文搜索。返回目录路径、标题路径、前后文、分数解释、source/indexed 水位;exhaustive 模式可用 cursor 完整遍历。projection.complete=false 时结果不完整,不能据此断言“知识不存在”。
Inputs: q (required), mode, limit, cursor, +2 more. Returns: object
doco_summaryDoco SummaryARead-onlyIdempotent
读取章节、文档、文件夹或知识库摘要,或查询异步生成任务。结果带来源块、来源版本、覆盖率、freshness 与 fallback 语义;模型关闭时仍始终可用。
Inputs: query, scope, job_id, block_id, +1 more. Returns: object
doco_translationsDoco TranslationsBRead-onlyIdempotent
读取一个具体文档的 Document Set、源语言、可用语言版本和每种语言的新鲜度。
Inputs: document_id (required). Returns: object
doco_translation_unitsDoco Translation UnitsARead-onlyIdempotent
读取目标语言的块级翻译单元、稳定块映射、source_version 和 missing/current/conflict 等状态。
Inputs: document_id (required), locale, status, target_document_id. Returns: object
doco_traverseDoco TraverseARead-onlyIdempotent
沿显式关系遍历文档。返回正向/反向关系、注册谓词、来源块与来源版本;status=dangling_* 时目标已失效,evidence_freshness=stale 时应重新确认证据,projection_freshness=stale 时不得当作完整关系图。
Inputs: document_id (required), direction, predicate. Returns: object
doco_update_documentDoco Update DocumentADestructiveIdempotent
整篇写回文档正文。markdown 写回凭 锚点保留未改动块 ID(配合 doco_get_document 的 annotate=anchors);tiptap-json 为整篇无损替换。强烈建议带 base_version,409 时重读合并重试。
Inputs: format (required), document_id (required), content, document, +1 more. Returns: object
doco_upload_attachmentDoco Upload AttachmentA
上传附件(图片/PDF/文本/Word),返回 attachment_id 与 URL;在文档块中用 image 节点 attrs.attachmentId 引用
Inputs: file_path (required), document_id (required), filename, idempotency_key. Returns: object
doco_whoamiDoco WhoamiARead-onlyIdempotent
自检身份:当前 Token 对应的用户与权限 scope
Inputs: no named parameters. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 29 tools
Most tools map to a distinct resource and action (documents, blocks, translations, relations, concepts, summaries), so an agent can generally pick the right one. The main ambiguities are doco_search vs. doco_search_v2 and the easily confused doco_translations vs. doco_translation_units, though the descriptions give enough detail to resolve them.
The doco_ prefix, snake_case, and familiar verb_noun forms (list_, get_, create_, update_, delete_, insert_, patch_) give the set a strong, predictable pattern. A few noun-only readers (doco_changes, doco_outline, doco_concepts, doco_summary) and the doco_search_v2 suffix are minor deviations.
29 tools is a large surface, but the server covers many distinct subdomains: knowledge-base navigation, document/block editing, search, translations, relations, concepts, summaries, and attachments. Still, the count is heavy and some functions (search_v2, separate block readers) could plausibly be merged, so the set is borderline rather than tightly scoped.
The tool set covers document create/read/update, block-level editing, search, summaries, concepts, and translations, so most core workflows are supported. Notable gaps are the lack of document deletion, relation deletion, and attachment lifecycle operations (list/download/delete), which agents cannot work around easily.
Maintenance
Related MCP Connectors
Real-time chat for AI agents. Claude Code, Cursor, Cline and Codex join channels over MCP.
An agent-first office suite Claude & ChatGPT read and write over one MCP URL.
MCP-native collaborative markdown editor with real-time AI document editing
MarkupBase turns AI-generated Markdown and HTML into durable, versioned artifacts that people can review and discuss. Its MCP server lets agents publish new versions, preserve contextual comments, include hosted images, and respond to feedback through secure account-linked identities, creating a clear human review boundary without requiring real-time editing.
Related MCP Servers
- AlicenseAqualityBmaintenanceMCP server that gives AI coding agents on-demand access to private project docs via BM25 ranked search. One setup for Claude Code, Cursor, Codex, Gemini CLI, and more. Docs stay private, never in public repos.1518Apache 2.0

Writespaceofficial
AlicenseNot gradedqualityDmaintenancePersistent docs and memory for AI agents. Writespace is a collaborative markdown editor with a built-in MCP server — your model reads, writes, organizes, and searches a shared workspace while humans edit the same docs live. Drop the ranked full-text search straight in as RAG retrieval.MIT- AlicenseNot gradedqualityFmaintenanceMCP server for collaborative markdown editing, allowing agents to write documents and humans to comment, with comments fed back as agent input.MIT
- AlicenseNot gradedqualityBmaintenanceMCP server for Nyxdoc, a document system where humans and external agents collaborate on documents with version history, agent to-dos, and workspace permissions.MIT