freshcrate
Skin:/
Home > MCP Servers > affine-mcp-server

affine-mcp-server

Model Context Protocol server for AFFiNE. Connect AI assistants to AFFiNE workspaces, documents, databases, and collaboration APIs over stdio or HTTP.

Why this rank:Strong adoptionRecent releaseHealthy release cadence

Description

Model Context Protocol server for AFFiNE. Connect AI assistants to AFFiNE workspaces, documents, databases, and collaboration APIs over stdio or HTTP.

README

AFFiNE MCP Server

A Model Context Protocol (MCP) server for AFFiNE. It exposes AFFiNE workspaces and documents to AI assistants over stdio (default) or HTTP (/mcp) and supports both AFFiNE Cloud and self-hosted deployments.

Version MCP SDK CI License

AFFiNE Server MCP server

Table of Contents

Overview

AFFiNE MCP Server is designed for three common scenarios:

  • Run a local stdio MCP server for Claude Code, Codex CLI, Cursor, or Claude Desktop
  • Expose a remote HTTP MCP endpoint for hosted or browser-connected clients
  • Automate AFFiNE workspace, document, database, organization, and comment workflows through a stable MCP tool surface

Highlights:

  • Supports AFFiNE Cloud and self-hosted AFFiNE instances
  • Supports stdio and HTTP transports
  • Supports token, cookie, and email/password authentication
  • Exposes 87 canonical MCP tools backed by AFFiNE GraphQL and WebSocket APIs
  • Includes semantic page composition, native template instantiation, database intent composition, capability and fidelity reporting, and workspace blueprint helpers
  • Includes Docker images, health probes, and end-to-end test coverage

Scope boundaries:

  • This server can access only server-backed AFFiNE workspaces
  • Browser-local workspaces stored only in local storage are not available through AFFiNE server APIs
  • AFFiNE Cloud requires API-token-based access for MCP usage; programmatic email/password sign-in is blocked by Cloudflare

New in v1.13.0: Added high-level semantic page, native template, fidelity, and workspace blueprint workflows, plus structured receipts and productized setup docs.

Choose Your Path

Goal Start here
Set up a local stdio server with the least friction docs/getting-started.md
Run the server in Docker or another OCI runtime docs/getting-started.md#path-c-run-from-the-docker-image
Configure Claude Code, Claude Desktop, Codex CLI, or Cursor docs/client-setup.md
Run the server remotely over HTTP or behind OAuth docs/configuration-and-deployment.md
Lock down tool exposure for least-privilege deployments docs/configuration-and-deployment.md#least-privilege-tool-exposure
Learn common AFFiNE workflows and tool sequences docs/workflow-recipes.md
Browse the tool catalog by domain docs/tool-reference.md

Quick Start

1. Install the CLI

npm i -g affine-mcp-server
affine-mcp --version

You can also run the package ad hoc:

npx -y -p affine-mcp-server affine-mcp -- --version

2. Or run the server in Docker

docker run -d \
  -p 3000:3000 \
  -e MCP_TRANSPORT=http \
  -e AFFINE_BASE_URL=https://your-affine-instance.com \
  -e AFFINE_API_TOKEN=ut_your_token \
  -e AFFINE_MCP_AUTH_MODE=bearer \
  -e AFFINE_MCP_HTTP_TOKEN=your-strong-secret \
  ghcr.io/dawncr0w/affine-mcp-server:latest

Then point your client at:

{
  "mcpServers": {
    "affine": {
      "type": "http",
      "url": "http://localhost:3000/mcp",
      "headers": {
        "Authorization": "Bearer your-strong-secret"
      }
    }
  }
}

For Docker, health checks, and remote deployment details, see docs/configuration-and-deployment.md#docker.

3. Save credentials with interactive login

affine-mcp login

This stores credentials in ~/.config/affine-mcp/config with mode 600.

  • For AFFiNE Cloud, use an API token from Settings -> Integrations -> MCP Server
  • For self-hosted AFFiNE, you can use either an API token or email/password

4. Register the server with your client

Claude Code project config:

{
  "mcpServers": {
    "affine": {
      "command": "affine-mcp"
    }
  }
}

Codex CLI:

codex mcp add affine -- affine-mcp

More client-specific setup is in docs/client-setup.md.

5. Verify the connection

affine-mcp status
affine-mcp doctor

If you want to expose the server remotely over HTTP instead of stdio, start with docs/configuration-and-deployment.md.

Compatibility Matrix

Target Transport Recommended auth Recommended path
Claude Code stdio Saved config or API token docs/client-setup.md#claude-code
Claude Desktop stdio Saved config or API token docs/client-setup.md#claude-desktop
Codex CLI stdio Saved config or API token docs/client-setup.md#codex-cli
Cursor stdio Saved config or API token docs/client-setup.md#cursor
Containerized remote deployment HTTP Bearer token or OAuth docs/getting-started.md#path-c-run-from-the-docker-image
Remote MCP clients HTTP Bearer token or OAuth docs/configuration-and-deployment.md#http-mode
AFFiNE Cloud stdio or HTTP API token docs/configuration-and-deployment.md#auth-strategy-matrix
Self-hosted AFFiNE stdio or HTTP API token, cookie, or email/password docs/configuration-and-deployment.md#auth-strategy-matrix

Tool Surface

tool-manifest.json is the source of truth for canonical tool names. The MCP server exposes those tools through tools/list and tools/call.

Domains:

  • Workspace: create, inspect, update, delete, and traverse workspaces
  • Organization: collections, collection-rule sync, workspace blueprints, and experimental organize or folder helpers
  • Documents: search, read, create, publish, move, tag, import/export, semantic composition, template inspection and native instantiation, capability and fidelity reporting, and text mutation
  • Databases: create columns, add rows, update cells, inspect schema, and compose database structures from intent
  • Comments: list, create, update, delete, resolve, and list unresolved threads
  • History: version history listing
  • Users and tokens: current user, sign-in, profile/settings, personal access tokens
  • Notifications: list and mark notifications as read
  • Blob storage: upload, delete, and cleanup blobs

For the grouped catalog, notes, and operational caveats, see docs/tool-reference.md.

Documentation Map

Document Purpose
docs/getting-started.md First-run setup paths and verification
docs/client-setup.md Client-specific configuration snippets and tips
docs/configuration-and-deployment.md Environment variables, auth modes, Docker, HTTP mode, and deployment guidance
docs/workflow-recipes.md End-to-end workflows and example tool sequences
docs/tool-reference.md Tool catalog grouped by domain
CONTRIBUTING.md Contributor workflow
SECURITY.md Security reporting

Verify Your Setup

Useful CLI commands:

  • affine-mcp status - test the effective configuration
  • affine-mcp status --json - machine-readable status output
  • affine-mcp doctor - diagnose config and connectivity issues
  • affine-mcp show-config - print the effective config with secrets redacted
  • affine-mcp config-path - print the config file path
  • affine-mcp snippet <claude|cursor|codex|all> [--env] - generate ready-to-paste client config
  • affine-mcp logout - remove stored credentials

For common failures, see:

Security and Scope

  • Never commit secrets or long-lived tokens
  • Prefer API tokens over cookies or passwords in production
  • Use HTTPS for non-local deployments
  • Rotate access tokens regularly
  • Restrict exposed tools with AFFINE_DISABLED_GROUPS and AFFINE_DISABLED_TOOLS for least-privilege setups
  • Use /healthz and /readyz when running the HTTP server behind a container platform or load balancer

Development

Run the main quality gates before opening a PR:

npm run build
npm run test:tool-manifest
npm run pack:check

Additional validation:

  • npm run test:comprehensive boots a local Docker AFFiNE stack and validates the tool surface
  • npm run test:e2e runs Docker, MCP, and Playwright together
  • npm run test:playwright runs the Playwright suite only
  • Focused runners for the new high-level tool surface include npm run test:create-placement, npm run test:capabilities-fidelity, npm run test:native-template, node tests/test-database-intent.mjs, node tests/test-semantic-page-composer.mjs, node tests/test-structured-receipts.mjs, node tests/test-organize-tools.mjs, and node tests/test-supporting-tools.mjs

Local clone flow:

git clone https://github.com/dawncr0w/affine-mcp-server.git
cd affine-mcp-server
npm install
npm run build
node dist/index.js

Release Notes

License

MIT License - see LICENSE.

Support

Acknowledgments

Release History

VersionChangesUrgencyDate
v2.1.0 ### Highlights - Added `find_doc_by_title` for fast exact-title lookup from AFFiNE workspace metadata, including duplicate-title results, timestamps, result limits, optional case-insensitive matching, and truncation reporting. - Added `folderId` support to `create_doc` so new documents can be placed directly inside AFFiNE organize folders. - Migrated npm publishing to GitHub Actions trusted publishing with OIDC on Node.js 24. - Cleared npm audit findings by refreshing locked transitive dependenHigh5/21/2026
v2.0.0 ### Highlights - Added native edgeless canvas coverage for surface elements, edgeless blocks, frame ownership, connector auto-snap, and canvas inspection. - Added least-privilege tool profiles for `full`, `read_only`, `core`, and `authoring` deployments. - Reduced the public MCP surface to 84 canonical tools by removing redundant convenience tools that overlapped with canonical document, search, database, comment, and template flows. - Hardened tool-surface reporting so `tools/list`, `get_capabHigh5/7/2026
v1.13.0 ### Highlights - Added high-level AFFiNE-native authoring workflows for semantic pages, native templates, fidelity analysis, and workspace blueprints. - Added structured mutation receipts so MCP clients can reliably consume IDs, warnings, and follow-up handles from write operations. - Expanded public docs into a productized landing page plus dedicated setup, deployment, workflow, and tool reference guides. - Refreshed CI and release dependencies across GitHub Actions, Docker publishing, and runHigh4/10/2026
v1.12.0## Version 1.12.0 (2026-04-09) ### Highlights - Added linked-document support on database rows so a row can open an AFFiNE doc in center peek. - Restored MCP CRUD compatibility for database rows created directly in the AFFiNE UI. - Fixed self-hosted `affine:table` exports that store row, column, and cell data as flat dot-notation Y.js keys. - Added GHCR Docker publishing on release tags, guarded so image publication only proceeds when the tagged commit is reachable from `origin/main`. ### WhatMedium4/9/2026
v1.11.2## Version 1.11.2 (2026-03-31) ### Highlights - Corrected stale `list_docs` edge results so deleted documents no longer linger after `delete_doc`. - Completed the delete/list_docs hardening started in `v1.11.1` by keeping the visible edge list aligned with workspace metadata. - Revalidated the delete/list workflow live against AFFiNE `0.26.4`. ### What Changed - `src/tools/docs.ts` - Filter out deleted documents that remain in GraphQL edges after the workspace snapshot has already dropped thMedium3/31/2026
v1.11.1## Version 1.11.1 (2026-03-31) ### Highlights - Corrected stale `list_docs` metadata after `delete_doc` so callers no longer see a pre-delete `totalCount`. - Aligned `list_docs.pageInfo.endCursor` with the returned edge list after delete-driven metadata drift. - Added live regression coverage to keep the delete/list_docs workflow stable against AFFiNE `0.26.4`. ### What Changed - `src/tools/docs.ts` - Clamp `list_docs.totalCount` downward when the workspace snapshot shows fewer pages than GrMedium3/31/2026
v1.11.0 ### Highlights - Added full sidebar organize workflows for collections, folders, and links inside AFFiNE workspace trees. - Added configurable tool-surface filtering with `AFFINE_DISABLED_GROUPS` and `AFFINE_DISABLED_TOOLS`. - Added `delete_database_row` and fixed markdown import so list items and table cells keep inline rich-text marks in AFFiNE. ### What Changed - `src/tools/organize.ts`, `README.md`, `tests/test-organize-tools.mjs` - Added collection and folder management tools plus live Medium3/27/2026
v1.10.1### Highlights - Refreshed the packaged README and release metadata so the published v1.10.x docs match the shipped toolset. - Tightened tag-based npm publication by requiring Docker-backed E2E validation before publish. - Kept the runtime/tool surface unchanged from `v1.10.0`; this is a documentation and release-process patch. ### What Changed - `README.md`, `CHANGELOG.md`, `RELEASE_NOTES.md`, `tool-manifest.json`, `package.json` - Bumped release metadata to `1.10.1`. - Brought the packageLow3/18/2026
v1.10.0 ### Highlights - Expanded document discovery and navigation with search, title lookup, backlinks, child/orphan traversal, and workspace tree tools. - Added template, batch, cleanup, and move workflows to cover higher-volume AFFiNE document operations. - Hardened remote HTTP deployments with optional OAuth mode, richer diagnostics, and a fix for repeated sessions using email/password authentication. ### What Changed - `src/tools/docs.ts` - Added `search_docs`, `get_doc_by_title`, `get_docs_byLow3/18/2026
v1.9.0### Highlights - Added dedicated database schema discovery with `read_database_columns`, so empty AFFiNE databases are now self-describing. - Added preset-backed `data_view` creation with kanban-oriented verification and richer exposed view metadata. - Hardened test infrastructure with a self-bootstrapping comprehensive runner, focused supporting-tools coverage, markdown callout round-trips, and a more reliable end-to-end Docker pipeline. ### What Changed - `src/tools/docs.ts` - Added `read_dLow3/10/2026
v1.8.0### Highlights - Added database cell read/write tools for AFFiNE databases, including Kanban stage sync workflows. - Fixed row title persistence so `add_database_row` now renders Kanban card headers correctly when `title` / `Title` is provided. - Added CLI version commands for direct and wrapped installs: `--version`, `-v`, and `version`. ### What Changed - `src/tools/docs.ts` - Added `read_database_cells` to read database rows with per-column values and optional row/column filters. - AddedLow3/10/2026
v1.7.2### Highlights - Fixed MCP tag persistence so tags are visible in AFFiNE Web/App UI. - Added end-to-end regression coverage for tag visibility (MCP setup + Playwright UI verification). - Hardened E2E startup reliability by enforcing auth-readiness checks before running pipeline tests. ### What Changed - `src/tools/docs.ts` - Aligned tag persistence with AFFiNE canonical tag option schema (`meta.properties.tags.options`) by storing option IDs. - Added backward-compatible normalization for leLow3/4/2026
v1.7.1### Highlights - Fixed MCP-created document structure to match AFFiNE UI parent-link expectations. - Fixed callout text rendering so MCP-created callouts display content correctly in AFFiNE Web UI. - Added regression coverage for document-visibility-sensitive creation and append paths. ### What Changed - `src/tools/docs.ts` - Aligned MCP block parent linkage to UI parity by writing `sys:parent = null` where applicable. - Added placement fallback via `sys:children` traversal when parent refeLow3/3/2026
v1.7.0### Highlights - Added remote-ready MCP HTTP hosting mode with Streamable HTTP protocol support on `/mcp`. - Kept compatibility paths for older clients through legacy SSE endpoints (`/sse`, `/messages`). - Hardened HTTP transport behavior for larger requests and broader Bearer token client compatibility. ### What Changed - `src/index.ts`, `src/sse.ts`, `package.json` - Added transport switching via `MCP_TRANSPORT` with modes: `stdio` (default), `http`/`streamable`, and `sse` (legacy alias). Low2/27/2026
v1.6.0 ### Highlights - Expanded the MCP surface from 32 to 43 tools with tag workflows, markdown roundtrip workflows, and direct database row/column editing tools. - Added interactive CLI account setup and diagnostics commands (`login`, `status`, `logout`) with secure local config storage. - Added Docker-based E2E verification (email/password + bearer token auth modes) and Playwright UI checks in CI. ### What Changed - `src/tools/docs.ts` - Added tag operations: `list_tags`, `list_docs_by_tag`, `cLow2/24/2026
v1.5.0## Summary This release completes the `append_block` Step1..Step4 expansion with stronger validation and AFFiNE-compatible block handling, especially for database and edgeless scenarios. ## Added - Added Step4 block types for `append_block`: `database`, `data_view`, `surface_ref`, `frame`, `edgeless_text`, `note`. - Added local integration coverage for all append profiles (`step1`..`step4`) in `scripts/test-append-block-expansion.mjs`. ## Changed - Expanded `append_block` canonical type coveraLow2/13/2026
v1.4.0## Summary This release adds document content reading support and improves integration guidance for MCP clients. ## Added - Added `read_doc` to read document block snapshots and plain text via WebSocket. ## Changed - Updated README with Cursor MCP setup examples and troubleshooting for JSON-RPC `Method not found` misuse. - Clarified that browser local-storage workspaces are not accessible through server APIs. ## Fixed - Updated runtime MCP server metadata version to `1.4.0`. ## Upgrade NotesLow2/13/2026
v1.3.0## Summary This release improves open-source project readiness and introduces stronger release quality gates. ## Added - Added open-source community health files: `CODE_OF_CONDUCT.md`, `CONTRIBUTING.md`, `SECURITY.md`. - Added GitHub community templates for issues and pull requests. - Added CI workflow and Dependabot configuration. - Added `tool-manifest.json` and static verification script (`npm run test:tool-manifest`). ## Changed - Simplified the MCP tool surface to 31 canonical tools with Low2/13/2026
v1.2.2## Summary This patch release improves CLI startup reliability by ensuring the binary always launches through Node. ## Changed - Updated CLI binary behavior so `bin/affine-mcp` consistently executes via Node, preventing shell misinterpretation of ESM JavaScript files. ## Fixed - Fixed false startup timeout/mis-execution scenarios in some environments caused by shell-level execution of ESM entrypoints. ## Documentation - Removed `.env`-based configuration guidance. - Standardized environment vLow9/18/2025
v1.2.1## Summary This release changes startup authentication behavior to reduce MCP stdio handshake timeouts. ## Added - Added `AFFINE_LOGIN_AT_START` with modes `async` (default) and `sync`. ## Changed - Default email/password startup authentication is now asynchronous to avoid blocking MCP initialization. - Refreshed documentation for Codex CLI and Claude Desktop workflows (npm, npx, and local clone usage). ## Removed - Removed unnecessary repository artifacts (for example, `.env.example` and `.dLow9/17/2025
v1.2.0## Summary This release introduces WebSocket-backed document mutation tools and npm-distributed CLI integration. ## Added - Added WebSocket-based document tools: `create_doc`, `append_paragraph`, `delete_doc`. - Added CLI binary `affine-mcp` for stdio MCP integration. - Added dual tool aliases (prefixed `affine_*` and non-prefixed names). - Published package on npm for one-line global install. ## Changed - Switched TypeScript ESM resolution to `NodeNext` for stable `.js` imports. - Updated docLow9/16/2025
v1.1.0## Summary This release significantly improves production readiness by fixing workspace creation and expanding core operational tooling. ## Added - Added workspace creation with initial document support. - Added blob storage management tools. - Added notification management tools. - Added user CRUD operations. - Added comprehensive test coverage. ## Changed - Simplified tool names by removing the `affine_` prefix from primary commands. - Consolidated workspace tooling into a single module. - ILow8/12/2025
v1.0.0## Summary Initial stable public release of `affine-mcp-server`. ## Added - Added 21 core tools for AFFiNE workspace/document operations. - Added MCP SDK compatibility (`@modelcontextprotocol/sdk` 1.17.2 baseline). - Added complete authentication support (Token, Cookie, Email/Password). - Added GraphQL API integration. - Added project documentation for initial setup and usage. ## Features - Workspace management. - Document operations. - Comments and collaboration workflow. - Document history aLow8/12/2025

Dependencies & License Audit

Loading dependencies...

Similar Packages

better-notion-mcpMarkdown-first MCP server for Notion API - composite tools optimized for AI agentsv2.34.4
@actwith-ai/mcp-serverGive your AI agent a career. Persistent memory, reputation, expertise, and community — for any MCP-compatible AI agent.0.15.1
mcp-safe-runTired of hardcoding secrets like API keys in your MCP client configuration (e.g., mcp.json, claude_desktop_config.json)? mcp-secure-launcher lets you run your existing MCP servers securely without mod2.4.6
google-workspace-mcp-with-scriptNo descriptionmain@2026-06-07
automagik-genieSelf-evolving AI agent orchestration framework with Model Context Protocol supportv4.260606.2

More in MCP Servers

PlanExeCreate a plan from a description in minutes
agentroveYour own Claude Code UI, sandbox, in-browser VS Code, terminal, multi-provider support (Anthropic, OpenAI, GitHub Copilot, OpenRouter), custom skills, and MCP servers.
ProxmoxMCP-PlusEnhanced Proxmox MCP server with advanced virtualization management and full OpenAPI integration.
node9-proxyThe Execution Security Layer for the Agentic Era. Providing deterministic "Sudo" governance and audit logs for autonomous AI agents.