by DAWNCR0W
Model Context Protocol server for AFFiNE. Connect AI assistants to AFFiNE workspaces, documents, databases, and collaboration APIs over stdio or HTTP.
# Add to your Claude Code skills
git clone https://github.com/DAWNCR0W/affine-mcp-serverGuides for using ai agents skills like affine-mcp-server.
affine-mcp-server is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by DAWNCR0W. Model Context Protocol server for AFFiNE. Connect AI assistants to AFFiNE workspaces, documents, databases, and collaboration APIs over stdio or HTTP. It has 339 GitHub stars.
affine-mcp-server's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/DAWNCR0W/affine-mcp-server" and add it to your Claude Code skills directory (see the Installation section above).
affine-mcp-server is primarily written in JavaScript. It is open-source under DAWNCR0W on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh affine-mcp-server against similar tools.
No comments yet. Be the first to share your thoughts!
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
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.
AFFiNE MCP Server is designed for three common scenarios:
Highlights:
expectedRevision to reject stale edits. Resaving a title that already matches keeps its revision.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.v3.16.0 adds native callout icon and background controls and restores realtime sync with the AFFiNE 0.27.5-beta.3 batch gateway.
| 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 |
| Let multiple agents write through one coordinated server | Concurrent writes |
| 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 |
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.16.0
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:
| Variable | Default | Purpose |
|---|---|---|
AFFINE_MCP_HTTP_MAX_SESSIONS |
32 |
Combined Streamable HTTP and legacy SSE session capacity, including sessions being initialized |
AFFINE_MCP_HTTP_SESSION_IDLE_TIMEOUT_MS |
1800000 (30 minutes) |
Idle time before an inactive session is closed |
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