Provides comprehensive tools for managing AFFiNE workspaces, documents, search, comments, and version history through GraphQL API integration, enabling full workspace collaboration and document management capabilities.
AFFiNE MCP Server
A Model Context Protocol (MCP) server that provides seamless integration with self-hosted or cloud AFFiNE instances. This server enables AI assistants to interact with AFFiNE workspaces and documents through a standardized interface.
Overview
- Purpose: MCP server for managing AFFiNE workspaces and documents
- Transport: stdio only (required for Claude Desktop and CLI integration)
- Auth: Flexible authentication with Token, Cookie, or Email/Password
- Tools: 30+ production-tested tools for comprehensive AFFiNE management
- Status: 🚀 Production Ready (v1.1.0)
Features
- Workspace Management: Create workspaces with initial documents (UI accessible)
- Document Operations: List, search, and manage documents
- User Management: Authentication and profile management
- Comments System: Full comment CRUD operations
- Version History: Document history and recovery
- Notifications: Read and manage notifications
Requirements
- Node.js 18+ (for running the server)
- AFFiNE instance (self-hosted or cloud)
- Valid AFFiNE credentials or access token
Installation
Configuration
Create a .env
file in the project root:
Authentication Priority
The server checks for authentication in this order:
- Bearer Token (
AFFINE_API_TOKEN
) - Highest priority - Cookie (
AFFINE_COOKIE
) - Email/Password (
AFFINE_EMAIL
+AFFINE_PASSWORD
) - Fallback
Quick Start
With Claude Desktop
Add to your Claude Desktop configuration:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
With Codebase CLI (codex)
Add to your Codebase CLI configuration:
Available Tools
Workspace Management (5 tools)
list_workspaces
- List all accessible workspacesget_workspace
- Get workspace detailscreate_workspace
- Create workspace with initial document ✅update_workspace
- Update workspace settingsdelete_workspace
- Delete workspace permanently
Document Operations (6 tools)
list_docs
- List documents with paginationget_doc
- Get document metadatasearch_docs
- Search documents by keywordrecent_docs
- List recently updated documentspublish_doc
- Make document publicrevoke_doc
- Revoke public access
Comments (5 tools)
list_comments
- List document commentscreate_comment
- Create new commentupdate_comment
- Update comment contentdelete_comment
- Delete a commentresolve_comment
- Resolve/unresolve comment
Version History (2 tools)
list_histories
- View document historyrecover_doc
- Restore to previous version
User Management (4 tools)
current_user
- Get current user informationsign_in
- Sign in with email/passwordupdate_profile
- Update user profileupdate_settings
- Update user settings
Access Tokens (3 tools)
list_access_tokens
- List personal access tokensgenerate_access_token
- Create new access tokenrevoke_access_token
- Revoke access token
Notifications (3 tools)
list_notifications
- Get notificationsread_notification
- Mark notification readread_all_notifications
- Mark all notifications read
Blob Storage (3 tools)
upload_blob
- Upload file/blobdelete_blob
- Delete blobcleanup_blobs
- Cleanup deleted blobs
Advanced (1 tool)
apply_doc_updates
- Apply CRDT updates to documents
Testing
Troubleshooting
Authentication Issues
- Email/Password fails:
- Ensure your AFFiNE instance allows password authentication
- Check network connectivity to the AFFiNE server
- Verify credentials are correct
- Cookie authentication:
- Extract cookies from browser DevTools Network tab
- Look for
affine_session
cookie after logging in - Include all relevant cookies in
AFFINE_COOKIE
- Token authentication:
- Generate token from AFFiNE user settings
- Ensure token hasn't expired
- Use the full token string in
AFFINE_API_TOKEN
Connection Issues
- Verify
AFFINE_BASE_URL
is accessible - Check if GraphQL endpoint is at
/graphql
(default) - Ensure no firewall/proxy blocking connections
- For self-hosted instances, verify CORS settings
Security Considerations
- Never commit
.env
files containing credentials - Use environment variables in production
- Rotate access tokens regularly
- Always use HTTPS for AFFiNE connections
- Store credentials in secure credential managers
Version History
1.1.0 (2025-08-12)
- ✅ Fixed workspace creation with initial documents
- Added 30+ tools for comprehensive AFFiNE management
- Workspace creation now accessible in UI
- Improved error handling and authentication
- Simplified tool names for better usability
1.0.0 (2025-08-12)
- Initial stable release
- Basic workspace and document operations
- Full authentication support
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Ensure all tests pass
- Submit a Pull Request
License
MIT License - see LICENSE file for details
Support
For issues and questions:
- Open an issue on GitHub
- Check AFFiNE documentation at https://docs.affine.pro
Author
dawncr0w - GitHub
Acknowledgments
- Built for the AFFiNE knowledge base platform
- Uses the Model Context Protocol specification
- Powered by @modelcontextprotocol/sdk
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Tools
Enables interaction with AFFiNE workspaces through GraphQL API to manage documents, search content, handle comments, and access version history. Supports comprehensive workspace operations including document publishing, comment management, and user authentication via session cookies or personal access tokens.
Related MCP Servers
- AsecurityAlicenseAqualityEnables interaction with Shopify store data via GraphQL API, providing tools for managing products, customers, orders, discounts, and more with robust error handling.Last updated -1535230MIT License
- -securityAlicense-qualityEnables interaction with Shopify stores through GraphQL API, providing tools for managing products, customers, orders, and more.Last updated -3528MIT License
- AsecurityAlicenseAqualityEnables interaction with Shopify store data through GraphQL API, providing tools for managing products, customers, orders, blogs, and articles.Last updated -152942MIT License
- -securityFlicense-qualityEnables interaction with Notion workspaces through the Notion API. Provides tools to search, read, create, and update Notion pages and databases with real-time synchronization.Last updated -312