Skip to main content
Glama

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.

Claude Code moves a card, adds one and writes a doc through the MCP while AFFiNE updates live

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.

A doc and a Kanban board written through the MCP, as AFFiNE shows them

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

list_workspaces

workspaces the bot can open

tree

folders and docs with ids, like the sidebar

search

docs whose title or text has the words, with snippets

read_doc

a doc as Markdown

write_doc

Markdown into a doc, append or replace

create_doc

new doc from Markdown, optionally in a folder

trash_doc

move to trash or restore, nothing is deleted for good

create_folder

sidebar folder, at the top or inside another

move_doc

put a doc into a folder

list_boards

Kanban boards in a doc or the whole workspace, with lanes

read_board

cards lane by lane in board order, with fields and views

get_card

one card with its fields and its description as Markdown

create_board

new board in a doc: lanes (with colors), fields, optional Table view

edit_board

rename; add, rename, delete fields; add, rename, recolor, reorder, delete lanes; add a Kanban or Table view

delete_board

remove a board and its cards

add_card

new card with fields {"Status": "In Progress", "Author": "Yurii"}, a Markdown description and a place in the lane

update_card

change a card title, fields, description or place

move_card

move a card to another lane, optionally to the top, bottom, before or after a card

delete_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 /info must say so). 0.27.5 changed the sync join protocol, the server refuses to start against it with a clear message instead of breaking silently

  • Node.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-mcp

It reads its settings from environment variables:

Variable

Needed

Meaning

AFFINE_BASE_URL

yes

your AFFiNE, https://affine.example.com (plain http only for localhost)

AFFINE_EMAIL

yes

account the agent signs in as

AFFINE_PASSWORD

yes

its password

AFFINE_WORKSPACE_ID

no

default workspace, the id from /workspace/<id>/.... Without it tools take a workspace name

AFFINE_READ_ONLY

no

true = only the reading tools

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-mcp

or 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

# to ######

✅

✅

Paragraphs

text

✅

✅

Bold, italic, strike, inline code, links

**b** *i* ~~s~~ `c` [t](url)

✅

✅

Underline, text color, highlight

⚠️

❌

read as plain text, gone after a replace

Bulleted and numbered lists, nested

- item, 1. item

✅

✅

Todo lists

- [ ] todo, - [x] done

✅

✅

Quotes

> quote

✅

✅

Code blocks with language

fenced code

✅

✅

Dividers

---

✅

✅

Tables

GFM table

✅

✅

AFFiNE table block

Links to other docs (@ mention)

[Title](affine://<docId>)

✅

✅

Kanban board (database block)

<!-- board:... --> section

⚠️

⚠️

read as a table, kept as it is on replace, made and changed with the board tools

Images, attachments, embeds, bookmarks, callouts, LaTeX and other blocks

<!-- affine:block <id> <type> -->

⚠️

⚠️

read as a marker, kept in place on replace while the marker stays, new ones cannot be added

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

✅

list_boards

Read cards lane by lane in the order the board shows them

✅

read_board, lane order and card order as in the editor

Create a board with lanes, lane colors and fields

✅

create_board, added at the end of a doc

Rename a board, delete a board

✅

edit_board, delete_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 moveTo

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

✅

tree

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, AFFINE_WORKSPACE_ID is the default

Read only mode

✅

AFFINE_READ_ONLY=true

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 publish

Release: 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 tools
add_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_boardA
Destructive

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_cardC
Destructive

Delete a card from a board

Inputs: doc (required), card (required), board, workspace.

edit_boardA
Destructive

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_cardB
Read-only

One card: title, lane, fields and the Markdown inside it (its description)

Inputs: doc (required), card (required), board, workspace.

list_boardsB
Read-only

Kanban boards (database blocks) in one doc or in the whole workspace, with their lanes

Inputs: doc, workspace.

list_workspacesA
Read-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_boardB
Read-only

All cards of a board lane by lane in board order, with fields, lane options and views

Inputs: doc (required), board, workspace.

read_docC
Read-only

A doc as Markdown, with its id and link

Inputs: doc (required), workspace.

trash_docA
Destructive

Move a doc to the AFFiNE trash, or restore it with restore=true. Nothing is deleted for good

Inputs: doc (required), restore, workspace.

treeA
Read-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_docA
Destructive

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

    B3.3/5.0

    Scored across 19 tools

    Disambiguation4/5

    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.

    Naming Consistency3/5

    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.

    Tool Count4/5

    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.

    Completeness4/5

    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

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      A
      maintenance
      Enables 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.
      95
      1,280 npm
      338
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides 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