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.
Potencia tu agente
El comando propio del publicador. No es un endpoint de PlugMCP.
Host a copy with our keys and logs.
npx -y [email protected]Claude Code no tiene enlace de instalación para un comando local. Copia el comando de abajo y ejecútalo en una terminal.
claude mcp add affine-mcp-server -- npx -y affine-mcp-server@3.13.0Ejecútalo en una terminal.
{ "mcpServers": { "affine-mcp-server": { "command": "npx", "args": [ "-y", "[email protected]" ] } }}claude_desktop_config.json
¿URL remota o un comando en tu máquina? En qué se diferencian las dos instalaciones
Ejecutar en PlugMCP
A new server you create. It is not this listing's official endpoint. Use the publisher install when you want their URL and their credentials.
AbrirDel publicador
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.
Model Context Protocol server for AFFiNE - enables AI assistants to interact with AFFiNE workspaces, documents, and collaboration features.
AFFiNE MCP Server is designed for three common scenarios:
Highlights:
created-by (user ID) and created-time (timestamp) columns from row metadata; missing or invalid metadata returns null without backfilling itset_doc_journalScope boundaries:
delete_doc removes workspace page metadata and requests content deletion. Some AFFiNE servers retain content despite acknowledging the request; the tool returns a partial result with a warning unless content absence is verified. Use trash_doc for recoverable cleanup.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.
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
docker run -d \
-p 3000:3000 \
-e MCP_TRANSPORT=http \
-e AFFINE_BASE_URL=https://your-affine-instance.com \
-e [email protected] \
-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:3.10.1
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.
HTTP deployments have two environment-only session limits:
Short-lived Streamable HTTP clients, including cron jobs, should send DELETE /mcp
with their Mcp-Session-Id and authentication headers when finished. Exiting the
client process alone does not terminate its server-side session. A long idle
timeout can let abandoned sessions fill the limit and cause 503 / -32002
errors. Close unused sessions and choose an appropriate idle timeout before
raising the cap. See session capacity troubleshooting.
affine-mcp login
This stores credentials in $XDG_CONFIG_HOME/affine-mcp/config when XDG_CONFIG_HOME is set, otherwise in ~/.config/affine-mcp/config, with mode 600.
The login flow reuses the configured or saved AFFiNE URL when you press Enter at
the URL prompt. After authentication, workspace discovery displays the workspace
name first and falls back to Workspace name unavailable when profile metadata
has no name; the full ID remains visible. An invalid numeric selection is rejected
and prompted again. Enter q or send end-of-file to cancel without writing a new
config. A failed discovery request is reported as a failure; it is not treated as
a completed login.
AFFINE_API_TOKEN remains available only for deployments that still accept a compatible GraphQL bearer tokenThe prompt defaults to AFFINE_BASE_URL from the environment or the saved config file, so pressing Enter keeps an already-configured self-hosted URL instead of switching back to AFFiNE Cloud.
For a self-hosted instance reached over plain HTTP on a trusted private network, AFFINE_ALLOW_INSECURE_HTTP=true must be set for the login run as well as for the server. The opt-in is read from the environment first and then from the saved config file.
To avoid re-running login when a session expires, persist the account credentials instead of the session cookie:
affine-mcp login --save-credentials
With the email/password method, this stores AFFINE_EMAIL and AFFINE_PASSWORD so the server signs in on its own and renews the session before it expires. The password is written to the mode-600 config file, so use a dedicated least-privilege AFFiNE account. Without this flag the CLI keeps storing only the session credential, which never renews by itself.
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 --force
Paste 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.
After login, inspect and switch the saved default workspace without signing in again:
affine-mcp workspaces
affine-mcp workspaces --json
affine-mcp workspace <workspace-id>
workspaces lists names first and marks the current default. workspace validates
the requested ID with the active credentials and changes only the local default
(AFFINE_WORKSPACE_ID); it does not grant access to a workspace or change the
authenticated account. With no ID, it uses the same validated selection flow.
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.
affine-mcp status
affine-mcp doctor
affine-mcp snippet codex
The recommended Codex form is a command-only registration line that keeps using
the current saved login. snippet claude and snippet cursor print JSON
configuration instead. Apply the generated snippet, then restart or reconnect
the MCP client so it starts a fresh server process.
For an explicit environment snapshot, add --env to any snippet command. It
copies the currently resolved URL, authentication, headers, workspace, and
relevant OAuth settings; client environment variables win over saved config at
runtime. Remove or regenerate copied credentials when they expire instead of
expecting a saved login to override them.
If you want to expose the server remotely over HTTP instead of stdio, start with docs/configuration-and-deployment.md. If an HTTP server already runs on the same host as your stdio client, use the private stdio HTTP bridge instead of starting another full server process.
Node.js 20.18.1 is the minimum supported runtime. CI validates the Node.js 20, 22, 24, and 26 release lines.
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.
get_capabilities exposes the full implemented list in
server.supportedTools and the currently enabled surface in
server.effective.profile and server.effective.enabledTools, after profiles,
disabled groups or tools, and auth-mode policy. Inspect tools/list when you
need the final set of callable tools.
Advertised input and output schemas omit the SDK-generated draft-07 $schema marker. Schema interpretation follows the client context, allowing clients that reject an explicit draft-07 declaration to consume the tool surface.
Domains:
For new document content, use create_doc for an optional single plain-text
paragraph and create_doc_from_markdown for native headings, lists, links,
code blocks, and $$...$$/$...$ math equations. Both tools accept folderId for immediate organize-folder placement.
New pages record the authenticated AFFiNE account in the app's Created by
property, including semantic pages, template instances, and workspace welcome pages.
Existing creator records are preserved; older pages are not backfilled.
New database rows also record the authenticated AFFiNE account and creation time,
including rows composed from intent or inserted as paragraph blocks. Editing or
moving existing rows preserves their creation metadata; older rows are not backfilled.
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.
Full-note replacement with replace_doc_with_markdown is destructive and requires full without disabling the destructive group. core and authoring retain incremental editing through append_markdown and update_block.
For the grouped catalog, notes, and operational caveats, see docs/tool-reference.md.
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 workspaces [--json] - list accessible workspaces by name and mark the defaultaffine-mcp workspace [id] - validate and set the local default workspaceaffine-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 credentialsCore configuration uses environment > saved config > defaults. HTTP body/session
limits, proxy settings, WebSocket timeouts, and the HTTP compatibility escape
hatches are environment-only runtime flags; they are not read from the saved
KEY=value file. See configuration precedence and environment scope.
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. Generated workspace and document URLs
use the configured AFFiNE base URL, so a custom GraphQL path does not become part
of a browser link.
For common failures, see:
AFFINE_MCP_HTTP_TOKENAuthorization header, never in the URLaffine-mcp login when a saved browser session expirescommand -v affine-mcp and command -v node; an absolute
script path does not fix a #!/usr/bin/env node shebang when the GUI process has
no Node.js directory in PATH. See GUI client PATH troubleshooting.AFFINE_DISABLED_GROUPS and AFFINE_DISABLED_TOOLS for least-privilege setupsread_only, and write-capable profiles require AFFINE_OAUTH_ALLOW_SERVICE_WRITES=true/healthz and /readyz when running the HTTP server behind a container platform or load balancerRun the main quality gates before opening a PR:
npm run ci
Additional validation:
npm test verifies tool metadata, test-suite coverage, and the fast regression suite without requiring a live AFFiNE instancenpm run test:comprehensive boots a local Docker AFFiNE stack and validates the tool surfacenpm run test:e2e runs Docker, MCP, and Playwright togethernpm run test:playwright runs the Playwright suite onlynpm 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, and node tests/test-supporting-tools.mjsLive 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.js
MIT License - see LICENSE.
Model Context Protocol server for AFFiNE - enables AI assistants to interact with AFFiNE workspaces, documents, and collaboration features.
{ "mcpServers": { "affine-mcp-server": { "command": "npx", "args": [ "-y", "[email protected]" ] } }}Herramientas
Aún no hay lista de herramientas. Los servidores remotos la reciben tras la primera comprobación de estado.
Preguntas frecuentes
Copia en esta página la configuración stdio para Cursor, Claude Desktop, Claude Code o VS Code. Usa la instalación del publicador, no un proxy de PlugMCP.
Este registro no indica ninguna variable de entorno obligatoria.
Affine se ejecuta localmente por stdio.
Última comprobación: 2026-11-15. Model Context Protocol server for AFFiNE - enables AI assistants to interact with AFFiNE workspaces, documents, and collaboration features.