affine-markdown-mcp
Provides tools for interacting with a self-hosted AFFiNE workspace: browse the folder tree and search docs, read and write docs as Markdown, create/move/trash docs and folders, and manage Kanban boards including lanes, fields, views, cards, card order, and Markdown card descriptions.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@affine-markdown-mcp move the "Fix login" card to Done on the Sprint board"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
affine-markdown-mcp
MCP server for self-hosted AFFiNE. Lets an AI agent (Claude Code, Claude Desktop, Cursor, any MCP client) work with your AFFiNE workspace like a teammate:
see the folder tree like the sidebar
read docs as Markdown and write Markdown back (append or replace)
run Kanban boards fully: create boards, edit lanes, fields and views, add and move cards, put them in order, give them a Markdown description
create docs and folders, move docs, trash and restore
It talks to AFFiNE the same way the web app does (Yjs over the sync socket), so changes show up live for everyone who has the doc open.

Left: Claude Code gets one sentence of task and uses the MCP. Right: the AFFiNE board and the new doc update live. Sped up. MP4 version.

Everything on this page was written by the MCP: the Markdown (heading, bold, italic, todos, table, code) and the card moved to Complete with a new Author value.
Tools
Tool | What it does |
| workspaces the bot can open |
| folders and docs with ids, like the sidebar |
| docs whose title or text has the words, with snippets |
| a doc as Markdown |
| Markdown into a doc, |
| new doc from Markdown, optionally in a folder |
| move to trash or restore, nothing is deleted for good |
| sidebar folder, at the top or inside another |
| put a doc into a folder |
| Kanban boards in a doc or the whole workspace, with lanes |
| cards lane by lane in board order, with fields and views |
| one card with its fields and its description as Markdown |
| new board in a doc: lanes (with colors), fields, optional Table view |
| rename; add, rename, delete fields; add, rename, recolor, reorder, delete lanes; add a Kanban or Table view |
| remove a board and its cards |
| new card with fields |
| change a card title, fields, description or place |
| move a card to another lane, optionally to the top, bottom, before or after a card |
| remove a card |
Docs, folders, boards and cards can be named by id or by title, so the agent can just say move_card {"doc": "Sprint", "card": "Fix login", "lane": "Done"}. A new select value (status, author) is added to the board automatically.
Set AFFINE_READ_ONLY=true to register only the reading tools.
Related MCP server: AppFlowy MCP Server
Requirements
AFFiNE server 0.20 to 0.27.4, self-hosted (
GET /infomust say so). 0.27.5 changed the sync join protocol, the server refuses to start against it with a clear message instead of breaking silentlyNode.js 20.19+ for the npm package (22.18+ to run the sources from a clone)
an AFFiNE account for the agent, a separate bot user is best (see below)
Install
Nothing to install by hand, MCP clients start it with npx:
npx -y affine-markdown-mcpIt reads its settings from environment variables:
Variable | Needed | Meaning |
| yes | your AFFiNE, |
| yes | account the agent signs in as |
| yes | its password |
| no | default workspace, the id from |
| no |
|
Bot user (recommended). Edits then show up as the bot, and your own password stays out of config. In the AFFiNE admin panel (/admin, Accounts) create a user such as claude@example.com with a long random password, then invite it to your workspace from Settings > Members and accept the invite once as that user. A collaborator is enough for everything the tools do.
Use it from Claude Code
claude mcp add affine \
--env AFFINE_BASE_URL=https://affine.example.com \
--env AFFINE_EMAIL=claude@example.com \
--env AFFINE_PASSWORD=... \
--env AFFINE_WORKSPACE_ID=<workspace id> \
-- npx -y affine-markdown-mcpor in a project .mcp.json (values come from your environment, nothing secret in the file). Claude Desktop, Cursor and other clients take the same command / args / env block
{
"mcpServers": {
"affine": {
"command": "npx",
"args": ["-y", "affine-markdown-mcp"],
"env": {
"AFFINE_BASE_URL": "${AFFINE_BASE_URL}",
"AFFINE_EMAIL": "${AFFINE_EMAIL}",
"AFFINE_PASSWORD": "${AFFINE_PASSWORD}",
"AFFINE_WORKSPACE_ID": "${AFFINE_WORKSPACE_ID}"
}
}
}
}A line in the project's CLAUDE.md helps the agent use it, for example "Tasks are cards on the board in the AFFiNE doc Sprint, docs are in the AFFiNE folder Engineering. Use the affine tools, start with tree."
What is supported
✅ works, ⚠️ works with a limit, ❌ not supported
Doc content (read gives Markdown, write takes Markdown)
AFFiNE | Markdown | Read | Write | Note |
Headings 1 to 6 |
| ✅ | ✅ | |
Paragraphs | text | ✅ | ✅ | |
Bold, italic, strike, inline code, links |
| ✅ | ✅ | |
Underline, text color, highlight | ⚠️ | ❌ | read as plain text, gone after a | |
Bulleted and numbered lists, nested |
| ✅ | ✅ | |
Todo lists |
| ✅ | ✅ | |
Quotes |
| ✅ | ✅ | |
Code blocks with language | fenced code | ✅ | ✅ | |
Dividers |
| ✅ | ✅ | |
Tables | GFM table | ✅ | ✅ | AFFiNE table block |
Links to other docs ( |
| ✅ | ✅ | |
Kanban board (database block) |
| ⚠️ | ⚠️ | read as a table, kept as it is on |
Images, attachments, embeds, bookmarks, callouts, LaTeX and other blocks |
| ⚠️ | ⚠️ | read as a marker, kept in place on |
Edgeless (canvas) content | ❌ | ❌ | only the document view | |
Doc properties (Info), comments | ❌ | ❌ |
Boards
Feature | Note | |
Find boards in a doc or the whole workspace, with lanes | ✅ |
|
Read cards lane by lane in the order the board shows them | ✅ |
|
Create a board with lanes, lane colors and fields | ✅ |
|
Rename a board, delete a board | ✅ |
|
Add, rename, delete fields | ✅ | the field that holds the lanes cannot be deleted |
Add, rename, recolor, reorder, delete lanes | ✅ | a lane with cards is deleted only with |
Kanban and Table views | ✅ | add a Table view or a second Kanban grouped by another select |
Add, rename, move, delete cards | ✅ | by card title or id |
Card order inside a lane | ✅ | top, bottom, before or after a card |
Card description (what opens when you click a card) | ✅ | Markdown, kept in a doc linked from the card, the way the AFFiNE editor does it |
Fields: select, multi-select, text, number, checkbox, date, link, progress | ✅ | new select values (a new status, a new author) are added to the board |
Other field types (member, created time, attachments, ...) | ⚠️ | read as stored, not created |
Filters, sorting, hidden fields of a view | ❌ | set them in the editor, they are kept |
Calendar and other view types | ❌ |
Workspace
Feature | Note | |
Folder tree like the sidebar | ✅ |
|
Search docs by title and text | ⚠️ | reads docs one by one, max 300 |
Create, rename and move docs | ✅ | |
Create folders | ✅ | at the top or inside another |
Rename or delete folders | ❌ | |
Trash and restore docs | ✅ | |
Delete a doc for good | ❌ | on purpose, empty the trash in AFFiNE |
Tags, collections | ❌ | |
Several workspaces | ✅ | by id or name, |
Read only mode | ✅ |
|
Edits next to people working in the same doc | ✅ | changes merge through Yjs, nothing is overwritten whole |
Server
Setup | Note | |
Self-hosted AFFiNE 0.20 to 0.27.4 | ✅ | |
Self-hosted AFFiNE 0.27.5 and newer | ❌ | new sync join protocol, the server stops with a clear message |
AFFiNE Cloud (app.affine.pro) | ❌ | self-hosted only |
stdio (Claude Code, Claude Desktop, Cursor, ...) | ✅ | |
HTTP transport | ❌ | planned |
Sign in with email and password | ✅ | a bot user is best |
Accounts with OAuth or magic link only | ❌ | give the bot user a password |
When the agent writes a doc back with replace and leaves a marker or the board section in place, that block stays exactly as it was (at the new position). Taking a marker out removes the block, so replace is marked destructive for the client.
Development
Node 22.18+ runs the TypeScript sources directly (the npm package is plain JS and runs on Node 20.19+).
npm ci
cp .env.example .env # bot login, see above
npm start # the server on stdio, for an MCP client or the MCP Inspector
npm test # unit tests, no network (node:test)
npm run test:integration # real server against AFFINE_TEST_WORKSPACE_ID (a throwaway workspace), writes and trashes docs there
npm run typecheck
npm run lint
npm pack # builds dist/ and the .tgz that npm would publishRelease: automatic. Every push to main that changes the package (src/, package.json, README.md, ...) runs the Publish workflow: checks, raises the patch version, adds a CHANGELOG.md entry from the commit subjects, commits and tags v<version>, publishes to npm through trusted publishing (no token) and makes a GitHub release. Put #minor or #major in the commit message for a bigger step, [skip release] to skip it, or run the workflow by hand and pick the part. The server reads its version from package.json, nothing else to bump.
Code layout: src/types (plain types), src/domain (Markdown and board rendering, no I/O), src/infrastructure/affine (HTTP session, sync socket, Yjs page/board/folder adapters), src/application (use cases, id or title resolution), src/api/mcp-server.ts (tools), src/main.ts (wiring). Style: .editorconfig and eslint.config.js (4 spaces, single quotes, Allman braces). Only erasable TypeScript, so Node runs the sources directly.
Credits
The sync protocol details (join, load, push update, folder and table storage) were learned from DAWNCR0W/affine-mcp-server (MIT). This is a separate, smaller implementation focused on Markdown and Kanban.
License: MIT
Available Tools
19 toolsadd_cardA
Add a card to a board, with optional fields (Status, Author, ...), a Markdown description and a place in its lane
Inputs: doc (required), title (required), board, fields, +3 more.
create_boardA
Add a Kanban board at the end of a doc, with lanes and fields. Make the doc first with create_doc if needed
Inputs: doc (required), title (required), lanes, fields, +3 more.
create_docC
New doc from Markdown, optionally inside a folder
Inputs: title (required), folder, markdown, workspace.
create_folderC
New sidebar folder, at the top or inside another folder
Inputs: name (required), parent, workspace.
delete_boardADestructive
Delete a board with all its cards from a doc. Description docs of cards stay in All docs. Cannot be undone from here, AFFiNE history can
Inputs: doc (required), board, workspace.
delete_cardCDestructive
Delete a card from a board
Inputs: doc (required), card (required), board, workspace.
edit_boardADestructive
Change a board: rename it, add / rename / delete fields, add / rename / recolor / delete / reorder lanes, add a view. Give only what changes
Inputs: doc (required), board, title, addView, +9 more.
get_cardBRead-only
One card: title, lane, fields and the Markdown inside it (its description)
Inputs: doc (required), card (required), board, workspace.
list_boardsBRead-only
Kanban boards (database blocks) in one doc or in the whole workspace, with their lanes
Inputs: doc, workspace.
list_workspacesARead-only
Workspaces the bot user can open, with id, name and role
Inputs: no named parameters.
move_cardA
Move a card to another Kanban lane (sets the lane field, usually Status), optionally to a place in that lane
Inputs: doc (required), card (required), lane (required), board, +2 more.
move_docA
Put a doc into a folder (moves it out of its current folder)
Inputs: doc (required), folder (required), workspace.
read_boardBRead-only
All cards of a board lane by lane in board order, with fields, lane options and views
Inputs: doc (required), board, workspace.
read_docCRead-only
A doc as Markdown, with its id and link
Inputs: doc (required), workspace.
searchBRead-only
Find docs whose title or text contains the words, with short snippets
Inputs: query (required), limit, workspace.
trash_docADestructive
Move a doc to the AFFiNE trash, or restore it with restore=true. Nothing is deleted for good
Inputs: doc (required), restore, workspace.
treeARead-only
Folder tree of a workspace with every doc (id and title), like the AFFiNE sidebar
Inputs: workspace.
update_cardC
Change a card title, fields, description or its place in the lane
Inputs: doc (required), card (required), board, title, +4 more.
write_docADestructive
Write Markdown into a doc. mode "append" adds at the end, "replace" rewrites the body (keep the markers from read_doc to keep boards and images)
Inputs: doc (required), mode (required), markdown (required), title, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 19 tools
Most tools target clearly distinct resources and actions (docs vs boards vs cards vs folders), and the read/list tools are separated by scope (list_boards vs read_board vs get_card vs read_doc). A few names are generic or could be confused, such as 'tree' and 'search', and 'read_doc' vs 'get_card' when cards contain Markdown, but descriptions generally resolve the ambiguity.
The majority follow verb_noun (create_board, add_card, delete_card, move_doc), but conventions are mixed: bare names like 'tree' and 'search', and inconsistent verbs for similar actions (read vs get, create vs add, write vs update, delete vs trash). It remains readable, but the set does not maintain a single predictable pattern.
19 tools is slightly above the ideal 3–15 range, but the domain covers workspaces, docs, boards, cards, and folders, so each tool largely earns its place. The surface is broad but not bloated, with no obvious duplicate tools.
Core lifecycle operations are well covered for docs (create/read/write/trash/move), boards (create/read/edit/delete/list), and cards (add/get/update/move/delete). Gaps remain around folder lifecycle (no delete/rename folder), doc title updates, and view deletion, but these are minor workaroundable omissions for the main workflow.
Maintenance
Related MCP Connectors
Markdown workspace for AI agents: read, write, organize, and share markdown documents.
Persistent docs and memory for AI agents — read, write, organize & search a shared workspace.
Docs, tables, issues, projects, calendar and designs of an Airsurf workspace: search, read, write.
Self-hostable shared brain for you and your AI agents — docs, flows, meetings, decisions, rationale
Related MCP Servers
- AlicenseAqualityAmaintenanceEnables interaction with AFFiNE workspaces through GraphQL API to manage documents, search content, handle comments, and access version history. Supports comprehensive workspace operations including document publishing, comment management, and user authentication via session cookies or personal access tokens.951,280 npm338MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with full read/write access to AppFlowy Cloud, enabling management of workspaces, pages, databases, trash, and favorites, plus conversion of Markdown into formatted AppFlowy document blocks.MIT
- AlicenseBqualityDmaintenanceAn MCP server for AFFiNE that exposes workspaces, documents, databases, comments, and more to AI assistants over stdio or HTTP, supporting both AFFiNE Cloud and self-hosted deployments.96MIT
- AlicenseAqualityCmaintenanceEnables AI agents to read and write a self-hosted AppFlowy instance, decoding its Yjs CRDT pages into Markdown.5MIT