affine-markdown-mcp 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +8 -13
- package/dist/api/mcp-server.js +6 -2
- package/package.json +4 -7
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -9,6 +9,10 @@ MCP server for **self-hosted [AFFiNE](https://affine.pro)**. Lets an AI agent (C
|
|
|
9
9
|
|
|
10
10
|
It talks to AFFiNE the same way the web app does (Yjs over the sync socket), so changes show up live for everyone who has the doc open.
|
|
11
11
|
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
*Left: Claude Code gets one sentence of task and uses the MCP. Right: the AFFiNE board and the new doc update live. [MP4 version](https://raw.githubusercontent.com/Tankonyako/affine-markdown-mcp/main/docs/demo/affine-mcp-demo.mp4).*
|
|
15
|
+
|
|
12
16
|

|
|
13
17
|
|
|
14
18
|
*Everything on this page was written by the MCP: the Markdown (heading, bold, italic, todos, table, code) and the card moved to Complete with a new Author value.*
|
|
@@ -67,15 +71,7 @@ It reads its settings from environment variables:
|
|
|
67
71
|
| `AFFINE_WORKSPACE_ID` | no | default workspace, the id from `/workspace/<id>/...`. Without it tools take a workspace name |
|
|
68
72
|
| `AFFINE_READ_ONLY` | no | `true` = only the reading tools |
|
|
69
73
|
|
|
70
|
-
**Bot user (recommended).** Edits then show up as the bot, and your own password stays out of config.
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
git clone https://github.com/Tankonyako/affine-markdown-mcp && cd affine-markdown-mcp && npm ci
|
|
74
|
-
AFFINE_BASE_URL=https://affine.example.com AFFINE_ADMIN_EMAIL=you@example.com AFFINE_ADMIN_PASSWORD=... \
|
|
75
|
-
node scripts/setup-bot.ts --workspace-name "My workspace" --bot claude@example.com
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
It creates the user with a random password, invites it into the workspace as a collaborator, makes a separate **"MCP test"** workspace for the integration tests and writes everything into `.env`. The password is only in `.env`.
|
|
74
|
+
**Bot user (recommended).** Edits then show up as the bot, and your own password stays out of config. In the AFFiNE admin panel (`/admin`, Accounts) create a user such as `claude@example.com` with a long random password, then invite it to your workspace from Settings > Members and accept the invite once as that user. A collaborator is enough for everything the tools do.
|
|
79
75
|
|
|
80
76
|
<br>
|
|
81
77
|
|
|
@@ -138,16 +134,15 @@ Node 22.18+ runs the TypeScript sources directly (the npm package is plain JS an
|
|
|
138
134
|
```bash
|
|
139
135
|
npm ci
|
|
140
136
|
cp .env.example .env # bot login, see above
|
|
141
|
-
|
|
137
|
+
npm start # the server on stdio, for an MCP client or the MCP Inspector
|
|
142
138
|
npm test # unit tests, no network (node:test)
|
|
143
|
-
npm run test:integration # real server against AFFINE_TEST_WORKSPACE_ID, writes and trashes docs there
|
|
139
|
+
npm run test:integration # real server against AFFINE_TEST_WORKSPACE_ID (a throwaway workspace), writes and trashes docs there
|
|
144
140
|
npm run typecheck
|
|
145
141
|
npm run lint
|
|
146
|
-
node e2e/run-claude-check.ts # a real Claude Code run in e2e/dummy-project, then checks AFFiNE (uses your Claude login)
|
|
147
142
|
npm pack # builds dist/ and the .tgz that npm would publish
|
|
148
143
|
```
|
|
149
144
|
|
|
150
|
-
Release:
|
|
145
|
+
Release: automatic. Every push to `main` that changes the package (`src/`, `package.json`, `README.md`, ...) runs the `Publish` workflow: checks, raises the patch version, adds a `CHANGELOG.md` entry from the commit subjects, commits and tags `v<version>`, publishes to npm through trusted publishing (no token) and makes a GitHub release. Put `#minor` or `#major` in the commit message for a bigger step, `[skip release]` to skip it, or run the workflow by hand and pick the part. The server reads its version from `package.json`, nothing else to bump.
|
|
151
146
|
|
|
152
147
|
Code layout: `src/types` (plain types), `src/domain` (Markdown and board rendering, no I/O), `src/infrastructure/affine` (HTTP session, sync socket, Yjs page/board/folder adapters), `src/application` (use cases, id or title resolution), `src/api/mcp-server.ts` (tools), `src/main.ts` (wiring). Style: `.editorconfig` and `eslint.config.js` (4 spaces, single quotes, Allman braces). Only erasable TypeScript, so Node runs the sources directly.
|
|
153
148
|
|
package/dist/api/mcp-server.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
1
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
import { listWorkspaces } from "../application/affine-context.js";
|
|
@@ -6,8 +7,11 @@ import { createDoc, createFolder, moveDoc, readDoc, trashDoc, writeDoc } from ".
|
|
|
6
7
|
import { searchDocs, treeToText, workspaceTree } from "../application/workspace.use-cases.js";
|
|
7
8
|
import { formatValue } from "../domain/board/board-render.js";
|
|
8
9
|
import { AffineToolError } from "../types/result.types.js";
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
/* package.json is two folders up from both src/api and dist/api, so the sources and the npm package read the same file.
|
|
11
|
+
The release workflow bumps only package.json */
|
|
12
|
+
const PACKAGE = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
|
|
13
|
+
export const SERVER_NAME = PACKAGE.name;
|
|
14
|
+
export const SERVER_VERSION = PACKAGE.version;
|
|
11
15
|
const INSTRUCTIONS = `AFFiNE workspace: docs as Markdown, a folder tree and Kanban boards.
|
|
12
16
|
- Start with tree to see folders and docs. Docs and folders can be named by id or by title.
|
|
13
17
|
- read_doc gives Markdown. Boards and blocks Markdown cannot show (images, embeds) appear as <!-- board:... --> / <!-- affine:block ... --> markers. Keep those markers when you write the doc back with mode "replace", they keep the board or block in place. Removing a marker removes that block.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "affine-markdown-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "MCP server for self-hosted AFFiNE: read and write docs as Markdown, see the folder tree, manage Kanban boards.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bandy (https://bandy.sh)",
|
|
@@ -40,14 +40,12 @@
|
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"start": "node src/main.ts",
|
|
43
|
-
"
|
|
43
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
44
|
+
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
44
45
|
"typecheck": "tsc -p tsconfig.json",
|
|
45
|
-
"lint": "eslint src test
|
|
46
|
+
"lint": "eslint src test",
|
|
46
47
|
"test": "node --test \"test/unit/**/*.test.ts\"",
|
|
47
48
|
"test:integration": "node --test --test-concurrency=1 \"test/integration/**/*.test.ts\"",
|
|
48
|
-
"test:e2e": "node e2e/run-claude-check.ts",
|
|
49
|
-
"setup:bot": "node scripts/setup-bot.ts",
|
|
50
|
-
"dump": "node scripts/dump-doc.ts",
|
|
51
49
|
"prepack": "npm run build",
|
|
52
50
|
"prepublishOnly": "npm run typecheck && npm run lint && npm test"
|
|
53
51
|
},
|
|
@@ -66,7 +64,6 @@
|
|
|
66
64
|
"@types/mdast": "4.0.4",
|
|
67
65
|
"@types/node": "26.6.11",
|
|
68
66
|
"eslint": "10.16.0",
|
|
69
|
-
"puppeteer-core": "25.19.0",
|
|
70
67
|
"typescript": "6.0.3",
|
|
71
68
|
"typescript-eslint": "8.74.0"
|
|
72
69
|
}
|