# affine-mcp-server [Health: Active]

**Category:** 🏢 Workplace & Productivity  
**Repository:** https://github.com/DAWNCR0W/affine-mcp-server  
**GitHub Stars:** 338  
**npm Downloads (last month):** 5567  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/affine-mcp-server

## Description
Model Context Protocol server for AFFiNE. Connect AI assistants to AFFiNE workspaces, documents, databases, and collaboration APIs over stdio or HTTP.

## Tools
Capabilities this server exposes over MCP:

- **find_blocks** — {"docId":"inventory","query":"Villa 23","type":"list"}
- **edit_block_text** — {"docId":"inventory","blockId":"item-23","edits":[{"old_str":"Срочная","new_str":"Обычная"}]}
- **update_database_rows** — {"docId":"inventory","databaseBlockId":"tasks","rows":[{"rowBlockId":"r1","cells":{"Status":"Done"}},{"rowBlockId":"r2","cells":{"Status":"Done"}}]}

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "affine-mcp-server": {
    "command": "npx",
    "args": ["-y","-p","affine-mcp-server","affine-mcp"],
    "env": {
      "MCP_TRANSPORT": "",
      "AFFINE_BASE_URL": "",
      "AFFINE_EMAIL": "",
      "AFFINE_PASSWORD": "",
      "AFFINE_API_TOKEN": "",
      "AFFINE_MCP_AUTH_MODE": "",
      "AFFINE_MCP_HTTP_TOKEN": "",
      "AFFINE_ALLOW_INSECURE_HTTP": ""
    }
  }
}
```

**Requires environment variables:** `MCP_TRANSPORT`, `AFFINE_BASE_URL`, `AFFINE_EMAIL`, `AFFINE_PASSWORD`, `AFFINE_API_TOKEN`, `AFFINE_MCP_AUTH_MODE`, `AFFINE_MCP_HTTP_TOKEN`, `AFFINE_ALLOW_INSECURE_HTTP` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What affine-mcp-server does

affine-mcp-server gives MCP-compatible AI clients access to server-backed AFFiNE workspaces. It can locate document blocks, apply targeted text replacements, and update database row cells. The broader tool surface covers workspace and document operations, database and table changes, comments, organizations, canvas content, code blocks, journal dates, templates, page composition, and workspace blueprints.

The server supports both AFFiNE Cloud and self-hosted AFFiNE instances. It works with documents stored through AFFiNE server APIs; browser-local workspaces that exist only in local storage are outside its scope.

## How it works

A local deployment communicates with the client over stdio. Remote deployments expose the MCP endpoint at `/mcp` over HTTP, including Streamable HTTP and legacy SSE session handling. The server uses AFFiNE GraphQL, WebSocket, and REST APIs behind its MCP tools.

Concurrent writes to the same workspace are coordinated through one shared server. Read operations can return a document revision, which can then be supplied as `expectedRevision` to reject edits based on stale content. The server also offers compact or outline reads, section and tail selection, bounded Markdown exports, compact database queries, and minimal write receipts to limit response size.

## Setup and configuration

Install the CLI globally with `npm i -g affine-mcp-server`, or run it on demand with `npx`. The executable is `affine-mcp`. Docker images are also available for HTTP deployments, with health probes included.

For self-hosted AFFiNE, configure the instance URL and authenticate with email and password or a signed-in session cookie. AFFiNE Cloud requires the Cookie request header from an authenticated browser session because programmatic email/password sign-in is blocked by Cloudflare. Older deployments may accept `AFFINE_API_TOKEN` as a compatible GraphQL bearer token.

HTTP deployments can require a bearer token for clients connecting to `/mcp`. Configure session capacity and idle timeouts when serving multiple or long-lived clients, and close short-lived sessions with `DELETE /mcp` when finished.

## Tools and capabilities

The documented tool examples include:

- `find_blocks`, which searches a document by text and can filter by block type.
- `edit_block_text`, which replaces selected text within a specified block.
- `update_database_rows`, which changes cell values for identified database rows.

Additional capabilities include inserting and deleting native table rows and columns while preserving formatting and widths; modifying database columns, select options, and view column order or visibility; creating and updating code blocks; and placing, resizing, and connecting images on edgeless canvases. Native `created-by` and `created-time` row metadata can be read, and journal dates can be set or cleared.

## Limitations and notes

Only server-backed AFFiNE workspaces are accessible. `delete_doc` removes workspace page metadata and requests content deletion, but some AFFiNE servers may retain content after acknowledging the request; `trash_doc` is the recoverable cleanup option. After content writes, transient workspace timestamp failures are retried up to three times. If metadata still cannot be confirmed, inspect the saved document before attempting a repair rather than repeating the edit.

AFFiNE versions that removed the legacy personal-access-token GraphQL API cannot use token-management tools. Cloud authentication must use a browser session, and insecure HTTP for self-hosted instances requires explicit opt-in.

_Full upstream README: https://allmcps.com/mcp/affine-mcp-server/readme_

