AFFiNE MCP Server
The AFFiNE MCP Server enables AI assistants to comprehensively manage AFFiNE workspaces and documents through the Model Context Protocol (MCP) via a stdio interface.
Workspace Management: Create, list, retrieve, update settings (public access, AI features), and delete workspaces, including creating workspaces with initial documents
Document Operations: List, get metadata, search, publish/revoke public access, and retrieve recently updated documents. WebSocket-based tools (v1.2.0+) support creating documents, appending paragraphs, and deletion with real-time editing capabilities
Comment System: Full CRUD operations on comments including listing, creating, updating, deleting, resolving, and unresolving
Version Control: List document version histories by timestamp and recover documents to previous states
User Management: Get current user info, sign in with email/password, update profiles and settings, manage email verification, password changes/resets, and account deletion
Token Management: Generate, list, and revoke personal access tokens with session cookie establishment
Blob Storage: Upload, delete, and permanently cleanup files/blobs in workspace storage
Notifications: List notifications and mark them as read (individually or all at once)
Advanced Operations: Apply CRDT updates to documents for advanced document manipulation
Provides comprehensive tools for managing AFFiNE workspaces, documents, search, comments, and version history through GraphQL API integration, enabling full workspace collaboration and document management capabilities.
Click on "Install 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 MCP Serversearch for documents about project planning"
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 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.
Table of Contents
Related MCP server: Shopify MCP Server
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 | |
Run the server in Docker or another OCI runtime | |
Configure Claude Code, Claude Desktop, Codex CLI, or Cursor | |
Run the server remotely over HTTP or behind OAuth | |
Lock down tool exposure for least-privilege deployments | docs/configuration-and-deployment.md#least-privilege-tool-exposure |
Learn common AFFiNE workflows and tool sequences | |
Browse the tool catalog by domain |
Quick Start
1. Install the CLI
npm i -g affine-mcp-server
affine-mcp --versionYou can also run the package ad hoc:
npx -y -p affine-mcp-server affine-mcp -- --version2. 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:latestThen 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 loginThis stores credentials in ~/.config/affine-mcp/config with mode 600.
For AFFiNE Cloud, use an API token from
Settings -> Integrations -> MCP ServerFor 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-mcpMore client-specific setup is in docs/client-setup.md.
5. Verify the connection
affine-mcp status
affine-mcp doctorIf 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 | |
Claude Desktop | stdio | Saved config or API token | |
Codex CLI | stdio | Saved config or API token | |
Cursor | stdio | Saved config or API token | |
Containerized remote deployment | HTTP | Bearer token or OAuth | |
Remote MCP clients | HTTP | Bearer token or OAuth | |
AFFiNE Cloud | stdio or HTTP | API token | |
Self-hosted AFFiNE | stdio or HTTP | API token, cookie, or email/password |
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 |
First-run setup paths and verification | |
Client-specific configuration snippets and tips | |
Environment variables, auth modes, Docker, HTTP mode, and deployment guidance | |
End-to-end workflows and example tool sequences | |
Tool catalog grouped by domain | |
Contributor workflow | |
Security reporting |
Verify Your Setup
Useful CLI commands:
affine-mcp status- test the effective configurationaffine-mcp status --json- machine-readable status outputaffine-mcp doctor- diagnose config and connectivity issuesaffine-mcp show-config- print the effective config with secrets redactedaffine-mcp config-path- print the config file pathaffine-mcp snippet <claude|cursor|codex|all> [--env]- generate ready-to-paste client configaffine-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_GROUPSandAFFINE_DISABLED_TOOLSfor least-privilege setupsUse
/healthzand/readyzwhen 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:checkAdditional validation:
npm run test:comprehensiveboots a local Docker AFFiNE stack and validates the tool surfacenpm run test:e2eruns Docker, MCP, and Playwright togethernpm run test:playwrightruns the Playwright suite onlyFocused 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, andnode 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.jsRelease Notes
License
MIT License - see LICENSE.
Support
Open an issue on GitHub
Review AFFiNE product documentation at docs.affine.pro
Acknowledgments
Built for the AFFiNE knowledge base platform
Uses the Model Context Protocol specification
Powered by @modelcontextprotocol/sdk
Maintenance
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/DAWNCR0W/affine-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server