by DAWNCR0W
Manages AFFiNE workspaces, documents, comments, version history, users, tokens, notifications, and blob storage via a Model Context Protocol server that communicates over stdio.
Affine MCP Server provides a command‑line MCP server that bridges AFFiNE knowledge‑base instances (self‑hosted or cloud) with AI assistants. It exposes workspace and document operations, comment handling, version history, user management, notifications, and blob storage through standardized MCP tools, enabling AI models to read, create, edit, and organize AFFiNE content directly.
npx -y -p affine-mcp-server affine-mcp -- --version
The command installs the package temporarily, then runs the affine-mcp binary which starts the MCP server on stdio.AFFINE_BASE_URL – base URL of your AFFiNE instance.AFFINE_API_TOKEN – personal access token (preferred for speed).AFFINE_COOKIE – session cookies.AFFINE_EMAIL and AFFINE_PASSWORD – fallback email/password login.
Optional variables: AFFINE_GRAPHQL_PATH, AFFINE_WORKSPACE_ID, AFFINE_LOGIN_AT_START (async by default).heading, list, todo, code, divider, quote), delete.npx -y -p affine-mcp-server affine-mcp runs the server without a permanent install.AFFINE_API_TOKEN (or AFFINE_COOKIE) avoids the async login step and gives instant access.!? Quote the value in the shell or place it in a JSON config (as shown for Claude Desktop) to prevent shell expansion.npm run test:tool-manifest locally; CI enforces the same check.AFFINE_GRAPHQL_PATH (default /graphql).A Model Context Protocol (MCP) server that integrates with AFFiNE (self‑hosted or cloud). It exposes AFFiNE workspaces and documents to AI assistants over stdio.
New in v1.3.0: Added
append_blockfor slash-command style blocks (heading/list/todo/code/divider/quote), removed duplicated aliases/non-core tools, and added CI + manifest quality gates.
# Global install (recommended)
npm i -g affine-mcp-server
# Or run ad‑hoc via npx (no install)
npx -y -p affine-mcp-server affine-mcp -- --version
The package installs a CLI named affine-mcp that runs the MCP server over stdio.
Note: From v1.2.2+ the CLI wrapper (bin/affine-mcp) ensures Node runs the ESM entrypoint, preventing shell from misinterpreting JS.
Configure via environment variables (shell or app config). .env files are no longer recommended.
AFFINE_BASE_URLAFFINE_API_TOKEN | AFFINE_COOKIE | AFFINE_EMAIL + AFFINE_PASSWORDAFFINE_GRAPHQL_PATH (default /graphql), AFFINE_WORKSPACE_ID, AFFINE_LOGIN_AT_START (async default, sync to block)Authentication priority:
AFFINE_API_TOKEN → 2) AFFINE_COOKIE → 3) AFFINE_EMAIL + AFFINE_PASSWORDAdd to your Claude Desktop configuration:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json{
"mcpServers": {
"affine": {
"command": "affine-mcp",
"env": {
"AFFINE_BASE_URL": "https://your-affine-instance.com",
"AFFINE_EMAIL": "you@example.com",
"AFFINE_PASSWORD": "secret!",
"AFFINE_LOGIN_AT_START": "async"
}
}
}
}
Tips
AFFINE_COOKIE or AFFINE_API_TOKEN for zero‑latency startup.! (zsh history expansion), wrap it in single quotes in shells or use the JSON config above.Register the MCP server with Codex:
Global install path (fastest)
npm i -g affine-mcp-servercodex mcp add affine --env AFFINE_BASE_URL=https://your-affine-instance.com --env 'AFFINE_EMAIL=you@example.com' --env 'AFFINE_PASSWORD=secret!' --env AFFINE_LOGIN_AT_START=async -- affine-mcpUse npx (no global install)
codex mcp add affine --env AFFINE_BASE_URL=https://your-affine-instance.com --env 'AFFINE_EMAIL=you@example.com' --env 'AFFINE_PASSWORD=secret!' --env AFFINE_LOGIN_AT_START=async -- npx -y -p affine-mcp-server affine-mcpToken or cookie (no startup login)
codex mcp add affine --env AFFINE_BASE_URL=https://... --env AFFINE_API_TOKEN=... -- affine-mcpcodex mcp add affine --env AFFINE_BASE_URL=https://... --env "AFFINE_COOKIE=affine_session=...; affine_csrf=..." -- affine-mcpNotes
affineaffine-mcpAFFINE_BASE_URL + one auth method (AFFINE_API_TOKEN | AFFINE_COOKIE | AFFINE_EMAIL/AFFINE_PASSWORD)list_workspaces – list all workspacesget_workspace – get workspace detailscreate_workspace – create workspace with initial documentupdate_workspace – update workspace settingsdelete_workspace – delete workspace permanentlylist_docs – list documents with paginationget_doc – get document metadatapublish_doc – make document publicrevoke_doc – revoke public accesscreate_doc – create a new document (WebSocket)append_paragraph – append a paragraph block (WebSocket)append_block – append slash-command style blocks (heading/list/todo/code/divider/quote)delete_doc – delete a document (WebSocket)list_comments, create_comment, update_comment, delete_comment, resolve_commentlist_historiescurrent_user, sign_in, update_profile, update_settingslist_access_tokens, generate_access_token, revoke_access_tokenlist_notifications, read_all_notificationsupload_blob, delete_blob, cleanup_blobsgit clone https://github.com/dawncr0w/affine-mcp-server.git
cd affine-mcp-server
npm install
npm run build
# Run directly
node dist/index.js
# Or expose as a global CLI for Codex/Claude without publishing
npm link
# Now use `affine-mcp` like a global binary
npm run build
npm run test:tool-manifest
npm run pack:check
tool-manifest.json is the source of truth for publicly exposed tool names.registerTool(...) declarations match the manifest exactly.Authentication
affine_session, affine_csrf) from the browser DevTools after loginAFFINE_LOGIN_AT_START=sync only if needed.Connection
AFFINE_BASE_URL is reachable/graphql.env with secretsappend_block for slash-command style editing (heading/list/todo/code/divider/quote)npm run test:tool-manifest, npm run ci)bin/affine-mcp), preventing shell mis-execution.env file no longer recommendedAFFINE_LOGIN_AT_START env (async default, sync to block at startup)create_doc, append_paragraph, delete_doc (create/edit/delete now supported)affine_* + non-prefixed names). They were removed later to reduce duplication.affine-mcp for easy npm i -g usageContributions are welcome!
CONTRIBUTING.mdnpm run ci locally before opening PRtool-manifest.json.github/CODE_OF_CONDUCT.mdSECURITY.mdCONTRIBUTING.mdMIT License - see LICENSE file for details
For issues and questions:
dawncr0w - GitHub
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
by zed-industries
A high‑performance, multiplayer code editor designed for speed and collaboration.
by modelcontextprotocol
Model Context Protocol Servers
by modelcontextprotocol
A Model Context Protocol server that provides time and timezone conversion capabilities.
by cline
An autonomous coding assistant that can create and edit files, execute terminal commands, and interact with a browser directly from your IDE, operating step‑by‑step with explicit user permission.
by upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
by daytonaio
Provides a secure, elastic infrastructure that creates isolated sandboxes for running AI‑generated code with sub‑90 ms startup, unlimited persistence, and OCI/Docker compatibility.
by continuedev
Enables faster shipping of code by integrating continuous AI agents across IDEs, terminals, and CI pipelines, offering chat, edit, autocomplete, and customizable agent workflows.
by github
Connects AI tools directly to GitHub, enabling natural‑language interactions for repository browsing, issue and pull‑request management, CI/CD monitoring, code‑security analysis, and team collaboration.
{
"mcpServers": {
"affine": {
"command": "npx",
"args": [
"-y",
"-p",
"affine-mcp-server",
"affine-mcp"
],
"env": {
"AFFINE_BASE_URL": "<YOUR_AFFINE_BASE_URL>",
"AFFINE_API_TOKEN": "<YOUR_API_TOKEN>"
}
}
}
}claude mcp add affine npx -y -p affine-mcp-server affine-mcp