DAWNCR0W/affine-mcp-server
소개
Model Context Protocol server for AFFiNE. Connect AI assistants to AFFiNE workspaces, documents, databases, and collaboration APIs over stdio or HTTP.
데이터 및 분석측정된 스타 증가
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +7
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalAFFiNE MCP Server
Connect your AI client to AFFiNE workspaces.
Search and edit documents, update databases, and build edgeless canvases with MCP.
Quick start · Docker and HTTP · Tool reference · Troubleshooting
Quick Start
Use Node.js 20.18.1 or newer for the local CLI. The server connects to AFFiNE Cloud or a self-hosted AFFiNE instance.
1. Install and sign in
npm install -g affine-mcp-server
affine-mcp --version
affine-mcp login
For AFFiNE Cloud, use the Cookie request header from a signed-in browser session. For self-hosted AFFiNE, use email and password or a signed-in session cookie. The CLI saves the selected workspace locally. First-run setup
Other login and workspace options
The CLI stores credentials in $XDG_CONFIG_HOME/affine-mcp/config when XDG_CONFIG_HOME
is set, or in ~/.config/affine-mcp/config otherwise, with mode 600.
Pressing Enter at the URL prompt reuses the configured or saved URL.
Enter q or send end-of-file to cancel without writing a new config.
To check the published CLI version without a global install, run
npm exec --yes --package=affine-mcp-server -- affine-mcp --version.
Use affine-mcp login --save-credentials with email and password for automatic
session renewal. Use a dedicated AFFiNE account with the access it needs.
For a trusted self-hosted plain HTTP endpoint, set AFFINE_ALLOW_INSECURE_HTTP=true
for login and the server.
Pass a session cookie on stdin to keep it out of command-line arguments.
affine-mcp login --url https://app.affine.pro --cookie-stdin --workspace-id your-workspace-id --force
List or switch workspaces using your saved login.
affine-mcp workspaces
affine-mcp workspace your-workspace-id
2. Register the server with your client
Codex CLI
codex mcp add affine -- affine-mcp
Claude Code
{
"mcpServers": {
"affine": {
"command": "affine-mcp"
}
}
}
Restart or reconnect your MCP client after registering the server. Client setup for Claude Code, Claude Desktop, Codex CLI, and Cursor
3. Verify the connection
affine-mcp status
affine-mcp doctor
Once connected, ask your client to list the AFFiNE workspaces it can access.
Try a canvas
Create an edgeless canvas called Release plan. Add Draft, Review, and Ship, then connect them in that order.
The illustration renders the shapes and connectors saved by add_surface_elements and read back with get_edgeless_canvas. Edgeless canvas cookbook
Overview
The MCP server uses the workspace permissions of the configured AFFiNE account and returns structured results that a client can use in its next tool call.
How requests reach AFFiNE
flowchart LR
client["MCP client"] -->|"stdio or HTTP"| server["AFFiNE MCP Server"]
server -->|"GraphQL, REST, WebSocket"| affine["AFFiNE Cloud or self-hosted"]
With one server process, writes are coordinated per workspace. Pass the revision
from a document read as expectedRevision to reject edits based on stale
content. Concurrent writes
Choose Your Path
| Setup | Where the server runs | Guide |
|---|---|---|
| Local stdio | The MCP client starts the CLI on your machine | Quick start |
| Docker | A container exposes an authenticated HTTP endpoint | Docker setup |
| Hosted HTTP | Your server serves remote MCP clients over HTTPS | HTTP mode and OAuth |
Run a local Docker example
This self-hosted AFFiNE example publishes the MCP port on loopback. Replace the AFFiNE credentials and use a strong, unique MCP bearer token.
docker run -d \
-p 127.0.0.1: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.17.0
Register the HTTP endpoint in a client that accepts an MCP server JSON config.
{
"mcpServers": {
"affine": {
"type": "http",
"url": "http://127.0.0.1:3000/mcp",
"headers": {
"Authorization": "Bearer your-strong-secret"
}
}
}
}
Use /healthz and /readyz for deployment probes. Short-lived Streamable HTTP
clients should send DELETE /mcp with their Mcp-Session-Id and authorization
headers when finished to release their session. Docker and health checks · HTTP session limits
If an HTTP server already runs on the same host as a stdio client, connect through the private stdio bridge to reuse it.
Compatibility Matrix
| Component | Supported setup |
|---|---|
| Node.js | 20.18.1 minimum, with CI on release lines 20, 22, 24, and 26 |
| AFFiNE Cloud | Signed-in browser session cookie for the external GraphQL connection |
| Self-hosted AFFiNE | Email/password or session cookie. Compatible GraphQL bearer tokens work on deployments that still accept them. |
| MCP clients | Claude Code, Claude Desktop, Codex CLI, Cursor, and other clients that support stdio or Streamable HTTP |
Realtime sync uses legacy joins on AFFiNE 0.27.4 and batch joins starting with 0.27.5-beta.3. This release was tested with 0.27.4 and 0.27.5-beta.4. Lifecycle-enabled workspaces require the protocol-2 override for reads. Selecting protocol 2 rejects MCP writes before they run. Realtime compatibility and overrides
Tool Surface
| Workflow | What you can do |
|---|---|
| Documents | Find, read, tag, move, publish, and export pages. Create native blocks from Markdown, compose pages from sections, or instantiate native templates. |
| Databases | Compose tables from intent, query and edit rows, and update columns, select options, and view settings. |
| Edgeless canvas | Arrange frames, notes, and images. Add shapes and connectors, then read back geometry and ownership. |
| Workspace organization | Browse linked documents, manage collections and custom properties, and create workspace blueprints. |
| Collaboration | Read and manage comments, check notifications, and work with blob attachments. |
The edgeless cookbook shows a canvas assembled from frames, connectors, and native notes. See the tool reference for supported operations and exact arguments.
Control what clients see
| Profile | Surface |
|---|---|
full |
Complete tool surface. Default outside OAuth mode. |
authoring |
Writing and editing tools for content authors. |
core |
Everyday workspace discovery, document editing, tags, and database tasks. |
read_only |
Discovery, reading, inspection, and exports. Default in OAuth mode. |
compact |
Full permissions with five single-item tools hidden in favor of batch calls. |
Set AFFINE_TOOL_PROFILE and limit individual operations further with
AFFINE_DISABLED_GROUPS or AFFINE_DISABLED_TOOLS. Profile reference and migration examples
Use tools/list to inspect the tools a client can call. get_capabilities
reports feature support and the currently enabled tool names. The
tool manifest lists the canonical names. Pass
{"view":"summary"} for the active profile and tool counts.
Keep responses focused
Use compact or outline reads, selective section reads, bounded exports, and minimal write receipts to keep large documents and edits manageable.
| Need | Example |
|---|---|
| Find a heading's block ID | find_blocks with {"docId":"project-notes","query":"Decisions","type":"heading","limit":10} |
| Read that section in outline form | read_doc with {"docId":"project-notes","view":"outline","section":"heading-block-id"} |
| Write several rows together | update_database_rows with one rows array for all intended edits |
Response size controls and revision checks
Documentation Map
| Guide | Use it to |
|---|---|
| Getting started | Sign in and verify your first connection |
| Client setup | Configure your MCP client |
| Configuration and deployment | Choose auth, limit tool access, or host the server |
| Workflow recipes | Find complete tool sequences for common tasks |
| Tool reference | Look up tool behavior, parameters, and output |
| Edgeless canvas cookbook | Build a canvas from working layout examples |
Verify Your Setup
| Command | Use it to |
|---|---|
affine-mcp status --json |
Read the effective connection status in JSON |
affine-mcp doctor |
Diagnose setup and connectivity problems |
affine-mcp workspaces [--json] |
See accessible workspaces and the saved default |
affine-mcp show-config |
Inspect effective settings with secrets redacted |
affine-mcp config-path |
Locate the saved config |
affine-mcp snippet codex |
Print a registration command that uses the saved login |
Use affine-mcp help <command> for subcommand options. Snippets for
claude, cursor, or all are also available. Add --env only when you want
an explicit environment snapshot that can include credentials.
Settings that support saved config resolve in the order environment, saved
config, then defaults. HTTP limits and WebSocket overrides use environment variables only.
Snippet options · Environment and advanced connection settings · First-run troubleshooting
Security and Scope
- Use a dedicated, least-privilege AFFiNE account for unattended deployments. This server accesses server-backed workspaces. Browser-local workspaces stay in the browser.
- Protect hosted MCP endpoints with HTTPS and authentication. Send bearer tokens in the authorization header. In OAuth mode, a write-capable profile requires
AFFINE_OAUTH_ALLOW_SERVICE_WRITES=true. - Keep passwords and session cookies out of source control. For GUI clients, put both
affine-mcpandnodeon the client'sPATH. GUI troubleshooting - Use
trash_docfor recoverable cleanup. Some AFFiNE versions acknowledgedelete_docwhile retaining the body. UsecontentAbsenceVerifiedto confirm permanent deletion. Deletion contract
Deployment checklist · Security reporting
Development
git clone --branch develop https://github.com/DAWNCR0W/affine-mcp-server.git
cd affine-mcp-server
npm ci
npm run ci
Run the built server with node dist/index.js. Use npm run test:docs for
documentation checks, npm run test:comprehensive for the Docker-backed tool
suite, or npm run test:e2e for the API and browser suites. Live tests require
a disposable AFFiNE instance. Contributor guide
Release Notes
Changelog · Release notes · GitHub Releases
License
Support
Report an issue · AFFiNE documentation · Glama listing
Acknowledgments
Built for AFFiNE with the Model Context Protocol and its TypeScript SDK.
관련 프로젝트 살펴보기
불러오는 중…