AFFiNE MCP 服务器是一个基于模型上下文协议(MCP)的服务器,它能够与自托管或云端的 AFFiNE 实例实现无缝集成。借助该服务器,AI 助手可以通过标准化接口与 AFFiNE 工作区和文档进行交互。
将以下内容添加到你的 Claude Desktop 配置文件中:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json{
"mcpServers": {
"affine": {
"command": "node",
"args": ["/path/to/affine-mcp-server/dist/index.js"],
"env": {
"AFFINE_BASE_URL": "https://your-affine-instance.com",
"AFFINE_EMAIL": "your@email.com",
"AFFINE_PASSWORD": "your_password"
}
}
}
}
将以下内容添加到你的 Codebase CLI 配置文件中:
{
"affine": {
"command": "node",
"args": ["/path/to/affine-mcp-server/dist/index.js"],
"env": {
"AFFINE_BASE_URL": "https://your-affine-instance.com",
"AFFINE_EMAIL": "your@email.com",
"AFFINE_PASSWORD": "your_password"
}
}
}
# 克隆仓库
git clone https://github.com/dawncr0w/affine-mcp-server.git
cd affine-mcp-server
# 安装依赖
npm install
# 构建 TypeScript 代码
npm run build
在项目根目录下创建一个 .env 文件:
# AFFiNE 服务器 URL(必需)
AFFINE_BASE_URL=https://your-affine-instance.com
# 认证方式(选择一种):
# 选项 1:Bearer Token(优先级最高)
AFFINE_API_TOKEN=your_personal_access_token
# 选项 2:会话 Cookie
AFFINE_COOKIE=affine_session=xxx; affine_csrf=yyy
# 选项 3:邮箱/密码(备用)
AFFINE_EMAIL=your@email.com
AFFINE_PASSWORD=your_password
# 可选设置
AFFINE_GRAPHQL_PATH=/graphql # 默认值:/graphql
AFFINE_WORKSPACE_ID=workspace-uuid # 操作的默认工作区
服务器按以下顺序检查认证方式:
AFFINE_API_TOKEN) - 优先级最高AFFINE_COOKIE)AFFINE_EMAIL + AFFINE_PASSWORD) - 备用list_workspaces - 列出所有可访问的工作区get_workspace - 获取工作区详细信息create_workspace - 创建带有初始文档的工作区 ✅update_workspace - 更新工作区设置delete_workspace - 永久删除工作区list_docs - 分页列出文档get_doc - 获取文档元数据search_docs - 按关键字搜索文档recent_docs - 列出最近更新的文档publish_doc - 使文档公开revoke_doc - 撤销文档的公开访问权限list_comments - 列出文档评论create_comment - 创建新评论update_comment - 更新评论内容delete_comment - 删除评论resolve_comment - 解决/未解决评论list_histories - 查看文档历史记录recover_doc - 恢复到之前的版本current_user - 获取当前用户信息sign_in - 使用邮箱/密码登录update_profile - 更新用户资料update_settings - 更新用户设置list_access_tokens - 列出个人访问令牌generate_access_token - 创建新的访问令牌revoke_access_token - 撤销访问令牌list_notifications - 获取通知read_notification - 将通知标记为已读read_all_notifications - 将所有通知标记为已读upload_blob - 上传文件/blobdelete_blob - 删除 blobcleanup_blobs - 清理已删除的 blobapply_doc_updates - 将 CRDT 更新应用到文档# 运行全面测试
node test-comprehensive.mjs
# 测试工作区创建
node test-fixed-workspace.mjs
affine_session Cookie。AFFINE_COOKIE 中。AFFINE_API_TOKEN 中使用完整的 Token 字符串。AFFINE_BASE_URL 是否可访问。/graphql(默认值)。.env 文件。欢迎贡献代码!请按照以下步骤进行:
本项目采用 MIT 许可证,详情请参阅 LICENSE 文件。
如有问题或疑问:
dawncr0w - GitHub