AFFiNE MCP Server
Provides tools for interacting with AFFiNE workspaces, documents, databases, organizations, comments, notifications, and blob storage, supporting both AFFiNE Cloud and self-hosted AFFiNE instances.
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 Serverlist my recent documents from all workspaces"
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: MindOS
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 session-cookie and email/password authentication, plus compatible bearer tokens for older deployments
Exposes 96 canonical MCP tools backed by AFFiNE GraphQL and WebSocket APIs
Includes official AFFiNE LLM prompt catalog integration and native MCP Prompts (
prompts/list,prompts/get)Includes rich visual dashboard generation, mindmaps, presentation slide decks, 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 0.27+ removed the legacy personal-access-token GraphQL API; this server no longer exposes token-management tools
AFFiNE Cloud requires browser-session authentication for this external GraphQL integration; programmatic email/password sign-in is blocked by Cloudflare
New in v3.2.1: Scripted cookie login now keeps session secrets out of process arguments, validates workspace access before saving credentials, and restores document pagination for ordinary workspace members.
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_EMAIL=you@example.com \
-e AFFINE_PASSWORD=your-password \
-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 $XDG_CONFIG_HOME/affine-mcp/config when XDG_CONFIG_HOME is set, otherwise in ~/.config/affine-mcp/config, with mode 600.
For AFFiNE Cloud, paste the Cookie request header from a signed-in browser session
For self-hosted AFFiNE, use email/password (recommended) or a signed-in session cookie
AFFINE_API_TOKENremains available only for deployments that still accept a compatible GraphQL bearer token
For scripted session-cookie setup, keep the cookie out of process arguments:
affine-mcp login --url https://app.affine.pro --cookie-stdin --workspace-id your-workspace-id --forcePaste the cookie at the hidden prompt, or pipe it from a trusted secret source. The CLI verifies --workspace-id against the authenticated account before saving it. Piped input requires --force when existing credentials would be replaced.
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
Node.js 20 is the minimum supported runtime. CI validates the minimum runtime and the current Node.js release used by the npm publish workflow.
Target | Transport | Recommended auth | Recommended path |
Claude Code | stdio | Saved config | |
Claude Desktop | stdio | Saved config or session cookie | |
Codex CLI | stdio | Saved config or self-hosted email/password | |
Cursor | stdio | Saved config or session cookie | |
Containerized remote deployment | HTTP | Bearer token or OAuth | |
Remote MCP clients | HTTP | Bearer token or OAuth | |
AFFiNE Cloud | stdio or HTTP | Signed-in browser session cookie | |
Self-hosted AFFiNE | stdio or HTTP | Email/password or session cookie |
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; tool definitions returned by tools/list include MCP annotations that mark read-only, destructive, idempotent, and external-world behavior for client-side tool selection.
Every canonical tool also declares an MCP outputSchema for its structuredContent. Object results retain their existing top-level fields, while array and scalar results use stable { items }, { text }, or { value } envelopes. The existing text content remains unchanged for compatibility with clients that do not consume structured results.
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, custom properties, import/export, semantic composition, template inspection and native instantiation, capability and fidelity reporting, and block-level mutation
Visual Dashboards & AI Prompts: retrieve official AFFiNE LLM prompts (
make_it_real,code_artifact,mindmap_generate,slides_outline, etc.), create rich interactive HTML/CSS dashboards, generate nested mindmaps, and build presentation slide decksDatabases: create columns, add rows, update rows, inspect schema, and compose database structures from intent
Comments: list, create, update, delete, and resolve
History: version history listing
Users and authentication: current user, sign-in, and profile/settings
Notifications: list and mark notifications as read
Blob storage: upload, delete, and cleanup blobs
Use AFFINE_TOOL_PROFILE=read_only, core, or authoring when a deployment should expose a smaller surface than the complete full default. This is the recommended path for hosted, browser-connected, or least-privilege deployments because it reduces agent choice overload while keeping the full tool catalog available as an opt-in surface. You can also combine profiles with AFFINE_DISABLED_GROUPS such as docs.database, destructive, or admin for finer control.
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 | |
Edgeless canvas layout helpers and surface elements, worked end-to-end | |
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
status, doctor, and the server runtime use the same environment > saved config > defaults resolution. For a self-hosted deployment with a non-standard GraphQL route, use affine-mcp login --graphql-path /your/graphql/path or set AFFINE_GRAPHQL_PATH; show-config --json prints the exact resolved graphqlEndpoint without exposing secrets.
For common failures, see:
Security and Scope
Never commit passwords, session cookies, or compatible bearer tokens
Use a dedicated least-privilege AFFiNE account for unattended deployments
Email/password HTTP sessions share one login and never fall back to anonymous backend requests after authentication failure
Use HTTPS for non-local deployments
Keep remote HTTP MCP listeners authenticated; bearer mode refuses a non-loopback bind without
AFFINE_MCP_HTTP_TOKENSend MCP bearer tokens in the
Authorizationheader, never in the URLRe-run
affine-mcp loginwhen a saved browser session expiresRestrict exposed tools with
AFFINE_DISABLED_GROUPSandAFFINE_DISABLED_TOOLSfor least-privilege setupsTreat OAuth mode as a shared AFFiNE service-account deployment: it defaults to
read_only, and write-capable profiles requireAFFINE_OAUTH_ALLOW_SERVICE_WRITES=trueUse
/healthzand/readyzwhen running the HTTP server behind a container platform or load balancerSet HTTP body, session, idle, and shutdown limits explicitly for high-volume deployments
Development
Run the main quality gates before opening a PR:
npm run ciAdditional validation:
npm testverifies tool metadata, test-suite coverage, and the fast regression suite without requiring a live AFFiNE instancenpm 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,npm run test:mutation-ack,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
Live tests can mutate or delete AFFiNE data. They allow loopback targets by
default and refuse non-loopback targets unless the disposable target is
explicitly enabled and confirmed as documented in CONTRIBUTING.md. Never run
them against production.
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
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
AlicenseBqualityCmaintenanceAn MCP server that enables AI assistants to interact with the Notion API, allowing them to search, read, comment on, and create content in Notion workspaces through natural language commands.19187,9644,571MIT- Alicense-qualityAmaintenanceLocal-first knowledge base MCP server. Lets AI agents (Claude Code, Cursor, etc.) read and write your personal knowledge base through 20 MCP tools. Zero cloud dependency — all files stay on your machine.1,758657MIT
- AlicenseAqualityAmaintenanceAn unofficial MCP server that enables AI assistants to search, read, create, and update pages in your NotePM workspace.8391MIT
- AlicenseBqualityDmaintenanceA live MCP server that connects AI assistants to a running Obsidian instance, enabling full app automation including reading notes, clicking UI elements, managing plugins, and executing JavaScript.43122MIT
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/irfanhak123/affine-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server