A comprehensive Model Context Protocol (MCP) server for seamless integration with the Anytype knowledge management platform. This server provides a complete set of tools for managing spaces, objects, properties, types, tags, and templates through the Anytype API.
- Complete API Coverage: Full support for all Anytype API endpoints
- Space Management: Create, update, and manage Anytype spaces
- Object Operations: CRUD operations for objects with advanced search capabilities
- Property Management: Dynamic property creation and management
- Type System: Custom object types with full lifecycle management
- Tag Management: Organize content with tags and multi-select properties
- Template Support: Access and utilize Anytype templates
- Collection & List Operations: Manage collections and lists with proper view handling
- Modern Development: Built with Vite for fast development and optimized builds
- Package Management: Uses pnpm for efficient dependency management
- TypeScript Support: Fully typed for enhanced developer experience
- Modular Architecture: Clean, maintainable code structure
- Node.js 18.0.0 or higher
- pnpm 8.0.0 or higher (recommended) or npm
- Anytype application running locally
- Valid Anytype API key
-
Install pnpm globally (if not already installed)
npm install -g pnpm
-
Clone the repository
git clone <repository-url> cd my-mcp-anytype
-
Install dependencies
pnpm install
-
Configure environment variables
# Copy the example file cp .env.example .env # Edit .env with your actual values # ANYTYPE_API_KEY=your-actual-api-key # ANYTYPE_BASE_URL=http://localhost:31009
-
Build the project
pnpm build
-
Start the server
pnpm start
-
Clone the repository
git clone <repository-url> cd my-mcp-anytype
-
Install dependencies
npm install
-
Configure environment variables
# Copy the example file cp .env.example .env # Edit .env with your actual values # ANYTYPE_API_KEY=your-actual-api-key # ANYTYPE_BASE_URL=http://localhost:31009
-
Build the project
npm run build
-
Start the server
npm start
-
Clone the repository
git clone <repository-url> cd my-mcp-anytype
-
Configure environment variables
# Copy and edit the environment file cp .env.example .env # Edit .env with your actual Anytype API key
-
Run with Docker Compose
# Build and start the container docker-compose up -d # View logs docker-compose logs -f # Stop the container docker-compose down
-
Or run with Docker directly
# Build the image docker build -t anytype-mcp . # Run the container docker run -d \ --name anytype-mcp-server \ --network host \ --env-file .env \ anytype-mcp
| Variable | Description | Default | Required |
|---|---|---|---|
ANYTYPE_API_KEY |
Your Anytype API key | - | β |
ANYTYPE_BASE_URL |
Anytype API base URL | http://localhost:31009 |
β |
MCP_PORT |
Port for MCP server | 3000 |
β |
LOG_LEVEL |
Logging level | info |
β |
REQUEST_TIMEOUT |
API request timeout (ms) | 30000 |
β |
- Open Anytype application
- Navigate to Settings β Developer
- Generate or copy your API key
- Add it to your
.envfile
This project uses modern development tools for optimal developer experience:
- β‘ Lightning Fast: Instant server start and HMR
- π¦ Optimized Builds: Efficient bundling with Rollup
- π§ Zero Config: Works out of the box with sensible defaults
- π― TypeScript Native: First-class TypeScript support
# Development
pnpm dev # Start development server with hot reload
pnpm build # Build for production using Vite
pnpm preview # Preview production build locally
pnpm start # Start the built MCP server
# Utilities
pnpm clean # Clean build artifacts
pnpm type-check # Run TypeScript type checking
pnpm prepare # Pre-publish preparation
# Docker
docker-compose up --build # Build and run with Docker- πΎ Disk Efficient: Saves up to 50% disk space
- β‘ Faster Installs: Up to 2x faster than npm
- π Strict: Better dependency resolution
- π Monorepo Ready: Built-in workspace support
The MCP now includes enhanced tag management with automatic validation and processing:
- β Automatic Tag Validation: Tags are validated when creating/updating objects
- β Improved Error Handling: Clear error messages for invalid tag assignments
- β Better Documentation: Comprehensive examples and usage patterns
- β Consistent API: Standardized property_id usage across all tag operations
-
Create tags for a multi_select property:
anytype_create_tag --space_id="space123" --name="Urgent" --color="red" --property_id="prop456"
-
Create object with tags:
anytype_create_object \ --space_id="space123" \ --name="My Task" \ --properties='[{"key":"labels","multi_select":["tag_id_1","tag_id_2"]}]'
-
Update object with new tags:
anytype_update_object \ --space_id="space123" \ --object_id="obj789" \ --properties='[{"key":"status","select":"completed_tag_id"}]'
For complete tag usage examples, see TAGS_USAGE.md.
Due to Anytype API behavior, updating object content requires a special approach:
When updating objects in Anytype, simply patching properties may not reflect changes immediately in the UI due to caching and synchronization mechanisms.
// Instead of simple update:
// PATCH /v1/spaces/{spaceId}/objects/{objectId}
// Use this pattern:
1. Get current object data
2. Delete the existing object
3. Create new object with updated content
4. Return new object IDasync function updateObjectContent(spaceId: string, objectId: string, updates: any) {
// 1. Get current object
const currentObject = await getObject(spaceId, objectId);
// 2. Merge updates with current data
const updatedData = {
...currentObject,
...updates,
// Preserve important metadata
type: currentObject.type,
createdDate: currentObject.createdDate
};
// 3. Delete current object
await deleteObject(spaceId, objectId);
// 4. Create new object with updated content
const newObject = await createObject(spaceId, updatedData);
return newObject;
}- β Content Updates: When changing object text, descriptions, or main content
- β Property Changes: When modifying custom properties
- β Type Changes: When changing object type
- β Simple Metadata: For basic metadata updates, regular PATCH may suffice
- ID Changes: The object will get a new ID after recreation
- References: Update any references to the old object ID
- Permissions: Ensure proper permissions for delete/create operations
- Backup: Consider backing up important objects before updates
| Tool | Description |
|---|---|
anytype_list_spaces |
List all available spaces |
anytype_get_space |
Get specific space details |
anytype_create_space |
Create a new space |
anytype_update_space |
Update existing space |
anytype_list_members |
List space members |
anytype_get_member |
Get specific member details |
| Tool | Description |
|---|---|
anytype_search_objects |
Search objects with advanced filters |
anytype_list_objects |
List objects in a space |
anytype_get_object |
Get specific object details |
anytype_create_object |
Create new object |
anytype_update_object |
Update existing object |
anytype_delete_object |
Delete (archive) object |
| Tool | Description |
|---|---|
anytype_list_properties |
List all properties in a space |
anytype_get_property |
Get specific property details |
anytype_create_property |
Create new property |
anytype_update_property |
Update existing property |
anytype_delete_property |
Delete property |
| Tool | Description |
|---|---|
anytype_list_types |
List all object types |
anytype_get_type |
Get specific type details |
anytype_create_type |
Create new object type |
anytype_update_type |
Update existing type |
anytype_delete_type |
Delete object type |
| Tool | Description |
|---|---|
anytype_list_tags |
List tags for a property |
anytype_get_tag |
Get specific tag details |
anytype_create_tag |
Create new tag |
anytype_update_tag |
Update existing tag |
anytype_delete_tag |
Delete tag |
| Tool | Description |
|---|---|
anytype_list_templates |
List templates for a type |
anytype_get_template |
Get specific template details |
| Tool | Description |
|---|---|
anytype_add_to_collection |
Add object to collection |
anytype_remove_from_collection |
Remove object from collection |
anytype_get_list_views |
Get available views for a list |
anytype_get_list_objects |
Get objects from a list view |
src/
βββ index.ts # Main server entry point
βββ startup-info.ts # Server startup information
βββ utils.ts # Utility functions and API helpers
βββ handlers/ # Request handlers
β βββ spaces.ts # Space and member operations
β βββ objects.ts # Object CRUD operations
β βββ properties.ts # Property management
β βββ types-tags.ts # Types, tags, and templates
βββ tools/ # MCP tool definitions
βββ spaces.ts # Space tool schemas
βββ objects.ts # Object tool schemas
βββ properties.ts # Property tool schemas
βββ types.ts # Type tool schemas
βββ tags.ts # Tag tool schemas
βββ templates.ts # Template tool schemas
βββ lists.ts # List tool schemas
βββ schemas.ts # Common schemas
This MCP server interfaces with the following Anytype API endpoints:
GET /v1/spaces- List spacesGET /v1/spaces/{id}- Get spacePOST /v1/spaces- Create spacePATCH /v1/spaces/{id}- Update spaceGET /v1/spaces/{id}/members- List members
POST /v1/search- Global searchPOST /v1/spaces/{id}/search- Space searchGET /v1/spaces/{id}/objects- List objectsGET /v1/spaces/{id}/objects/{objectId}- Get objectPOST /v1/spaces/{id}/objects- Create objectPATCH /v1/spaces/{id}/objects/{objectId}- Update objectDELETE /v1/spaces/{id}/objects/{objectId}- Delete object
GET /v1/spaces/{id}/properties- List propertiesPOST /v1/spaces/{id}/properties- Create propertyPATCH /v1/spaces/{id}/properties/{propertyId}- Update propertyDELETE /v1/spaces/{id}/properties/{propertyId}- Delete property
GET /v1/spaces/{id}/types- List typesPOST /v1/spaces/{id}/types- Create typePATCH /v1/spaces/{id}/types/{typeId}- Update typeDELETE /v1/spaces/{id}/types/{typeId}- Delete type
GET /v1/spaces/{id}/types/{typeId}/templates- List templatesGET /v1/spaces/{id}/types/{typeId}/templates/{templateId}- Get template
- Consistent Environment: Ensures the same runtime across different systems
- Easy Deployment: Simple containerized deployment
- Isolation: Runs in an isolated environment
- Scalability: Easy to scale and manage
The project includes:
Dockerfile: Multi-stage build with security best practicesdocker-compose.yml: Complete orchestration setup.dockerignore: Optimized build context- Health checks and resource limits
Host Network Mode (Recommended):
network_mode: hostThis allows the container to access Anytype running on the host machine.
Bridge Network Mode (Alternative): If Anytype is also containerized, use a custom network:
networks:
- anytype-networkThe container uses the same environment variables as the local installation:
ANYTYPE_API_KEY: Your API keyANYTYPE_BASE_URL: Defaults tohttp://host.docker.internal:31009in Docker
npm run build # Compile TypeScript to JavaScript
npm start # Start the MCP server
npm run dev # Development mode with tsx
npm run prepare # Pre-publish build step# Development with Docker
docker-compose -f docker-compose.yml up --build
# View logs in real-time
docker-compose logs -f anytype-mcp
# Execute commands in container
docker-compose exec anytype-mcp sh- Define tool schema in the appropriate
tools/*.tsfile - Implement handler in the corresponding
handlers/*.tsfile - Register tool in
src/index.ts - Update documentation as needed
- TypeScript with strict type checking
- Modular architecture with separation of concerns
- Consistent error handling with MCP error types
- Comprehensive input validation
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Issues page for existing solutions
- Create a new issue with detailed information
- Include your environment details and error messages
- Anytype for the amazing knowledge management platform
- Model Context Protocol for the integration framework
- The open-source community for continuous inspiration
Made with β€οΈ for the Anytype community