Compare commits
21 Commits
cc50c64423
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 910873498a | |||
| 6dcf8aa0ff | |||
| a2926293df | |||
| 308290c122 | |||
| 865a48e1d4 | |||
| 66bb003b91 | |||
| 2f5f361013 | |||
| 3c763fc44f | |||
| 7084a7d5b2 | |||
| 3e9dce4ccb | |||
| 3c23e30b0c | |||
| 0a362b37b1 | |||
| 1ebc34764b | |||
| 5f7fc55d09 | |||
| 8a2f79dddb | |||
| dca14b1c9d | |||
| c0e76867a5 | |||
| d7c1111762 | |||
| 68b6067824 | |||
| 76f1180cde | |||
| 62f7f125d3 |
11
.claude/settings.local.json
Normal file
11
.claude/settings.local.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(npm run:*)",
|
||||
"Bash(npm help)",
|
||||
"Bash(git checkout:*)"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
}
|
||||
}
|
||||
94
CLAUDE.md
Normal file
94
CLAUDE.md
Normal file
@@ -0,0 +1,94 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Commands
|
||||
|
||||
### Build and Development
|
||||
```bash
|
||||
# Build TypeScript to JavaScript
|
||||
npm run build
|
||||
|
||||
# Watch mode for development
|
||||
npm run dev
|
||||
|
||||
# Run the built server
|
||||
npm start
|
||||
```
|
||||
|
||||
### Testing and Validation
|
||||
Before committing changes, ensure the TypeScript compiles without errors:
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
This is an Appwrite Model Context Protocol (MCP) server that provides a comprehensive interface between Claude and Appwrite services. The server is built in TypeScript and uses the official Appwrite Node.js SDK.
|
||||
|
||||
### Key Components
|
||||
|
||||
1. **MCP Server Core** (`src/index.ts`):
|
||||
- Main server class `AppwriteMCPServer` that initializes all Appwrite service clients
|
||||
- Implements 135 tools covering all major Appwrite services
|
||||
- Uses environment variables for configuration (loaded from `.env` in current working directory)
|
||||
|
||||
2. **Service Clients**:
|
||||
- Databases, Users, Storage, Functions, Teams, Account, Health, Messaging, Locale, Avatars
|
||||
- All clients are initialized with API key authentication
|
||||
|
||||
3. **Tool Categories**:
|
||||
- Database operations (create, list, delete databases)
|
||||
- Collection management with attribute and index operations
|
||||
- Document CRUD with query support
|
||||
- User management including MFA, preferences, identities, and messaging targets
|
||||
- Storage bucket and file operations
|
||||
- Function management with deployments and variables
|
||||
- Messaging service (providers, messages, topics, subscribers)
|
||||
- Locale service for internationalization
|
||||
- Avatar generation utilities
|
||||
- Bulk operations for efficient batch processing
|
||||
- Advanced features like schema auto-detection and data analysis
|
||||
|
||||
### Configuration
|
||||
|
||||
The server reads configuration from environment variables:
|
||||
- `APPWRITE_PROJECT_ID`: Target Appwrite project
|
||||
- `APPWRITE_API_ENDPOINT`: Appwrite API endpoint (cloud or self-hosted)
|
||||
- `APPWRITE_API_KEY`: API key with necessary scopes
|
||||
|
||||
The `.env` file is loaded from the current working directory where Claude Code is run, allowing project-specific configurations.
|
||||
|
||||
### Tool Implementation Pattern
|
||||
|
||||
Tools follow a consistent pattern:
|
||||
1. Parse and validate input parameters
|
||||
2. Initialize appropriate Appwrite service client
|
||||
3. Execute the operation with error handling
|
||||
4. Return formatted response with relevant data
|
||||
|
||||
### Error Handling
|
||||
|
||||
All tools implement comprehensive error handling:
|
||||
- Configuration validation before operations
|
||||
- Detailed error messages for debugging
|
||||
- Graceful fallbacks for missing optional parameters
|
||||
|
||||
## Development Guidelines
|
||||
|
||||
1. **Adding New Tools**: Follow the existing pattern in `src/index.ts`, ensuring proper parameter validation and error handling.
|
||||
|
||||
2. **Type Safety**: Leverage TypeScript's strict mode for all new code. The project uses ES2022 target with Node16 module resolution.
|
||||
|
||||
3. **Environment Variables**: Never commit `.env` files. Use `.env.example` as a template for configuration.
|
||||
|
||||
4. **Build Output**: Compiled JavaScript goes to `dist/` directory. Source maps are generated for debugging.
|
||||
|
||||
## Integration Notes
|
||||
|
||||
This server can be integrated with:
|
||||
- Claude Code (CLI) via `claude mcp add` command
|
||||
- Cursor IDE via settings.json configuration
|
||||
- Continue.dev via config.json
|
||||
|
||||
Each integration method supports different configuration approaches, with Claude Code using `.env` files and IDEs requiring inline environment variable configuration.
|
||||
525
README.md
525
README.md
@@ -1,251 +1,438 @@
|
||||
# Appwrite MCP Server
|
||||
# 🚀 Appwrite MCP Server
|
||||
|
||||
A comprehensive Model Context Protocol (MCP) server that transforms Claude Code into an intelligent Appwrite management assistant.
|
||||
<div align="center">
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
**Transform Claude into your intelligent Appwrite management assistant**
|
||||
*12 optimized tools • Core Appwrite operations • Context-efficient design • Production-ready*
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
A **context-optimized Model Context Protocol (MCP)** server that provides Claude with essential Appwrite integration. This version focuses on core functionality with action-based combined tools, offering database operations, user management, storage, and team management in an efficient package designed to stay under MCP context limits.
|
||||
|
||||
## 🚀 Features
|
||||
|
||||
**Core Appwrite Management:**
|
||||
- Complete database and collection operations
|
||||
- Document CRUD with full query support
|
||||
- User management and authentication
|
||||
- Storage buckets and file operations
|
||||
- Serverless function management
|
||||
- Team and permission management
|
||||
**🎯 Core Appwrite Operations:**
|
||||
- **Database Management** - Create, get, list, update, and delete databases with enabled status
|
||||
- **Collection Operations** - Full collection lifecycle with document security and search support
|
||||
- **Document CRUD** - Complete document operations with bulk support and advanced queries
|
||||
- **User Management** - User operations including bulk processing and preferences
|
||||
- **Storage Management** - Complete bucket operations with advanced configuration (file size limits, allowed extensions, compression, encryption, antivirus) and file upload/download
|
||||
- **Team Management** - Team CRUD operations
|
||||
- **Attribute & Index Management** - Schema management with array support and bulk operations
|
||||
- **Health Monitoring** - System health checks
|
||||
|
||||
**🧠 Intelligent Database Assistant:**
|
||||
- **Auto-detect schemas** from sample data
|
||||
- **Data quality analysis** and recommendations
|
||||
- **Duplicate detection** with similarity matching
|
||||
- **Index optimization** suggestions
|
||||
- **Schema migrations** with safety checks
|
||||
**⚡ Action-Based Design:**
|
||||
- **Single tools handle multiple operations** using action parameters
|
||||
- **Bulk operations integrated** into respective categories
|
||||
- **Context-optimized** - Efficient tool design for reduced token usage
|
||||
- **Advanced features** - Document security, file download, bucket encryption, array attributes
|
||||
|
||||
## Installation
|
||||
## 📦 Quick Start
|
||||
|
||||
### 1️⃣ Installation
|
||||
|
||||
1. Clone this repository:
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone <repository-url>
|
||||
cd appwrite-mcp-server
|
||||
```
|
||||
|
||||
2. Install dependencies:
|
||||
```bash
|
||||
# Install dependencies
|
||||
npm install
|
||||
```
|
||||
|
||||
3. Build the TypeScript code:
|
||||
```bash
|
||||
# Build the TypeScript code
|
||||
npm run build
|
||||
|
||||
# On Linux/macOS: Make the compiled file executable
|
||||
chmod +x dist/index.js
|
||||
```
|
||||
|
||||
4. Configure your Appwrite credentials by creating a `.env` file in your **current working directory** (where you run Claude Code from):
|
||||
### 2️⃣ Configuration
|
||||
|
||||
Create a `.env` file in your **current working directory** (where you run Claude Code from):
|
||||
|
||||
```bash
|
||||
# Copy the example file to your current working directory
|
||||
cp /path/to/app-write-mcp/.env.example ./.env
|
||||
```
|
||||
|
||||
5. Edit the `.env` file in your current directory with your Appwrite project details:
|
||||
```bash
|
||||
APPWRITE_PROJECT_ID=your-project-id
|
||||
Edit your `.env` file with your Appwrite credentials:
|
||||
|
||||
```env
|
||||
APPWRITE_PROJECT_ID=your-project-id-here
|
||||
APPWRITE_API_ENDPOINT=https://cloud.appwrite.io/v1
|
||||
APPWRITE_API_KEY=your-api-key
|
||||
APPWRITE_API_KEY=your-api-key-here
|
||||
```
|
||||
|
||||
**Important:** The MCP server looks for `.env` in the directory where Claude Code is currently running, not in the repository directory. This allows you to use different configurations for different projects without modifying the repository.
|
||||
> 💡 **Tip:** The MCP server looks for `.env` in the directory where Claude Code is running, allowing different configurations for different projects.
|
||||
|
||||
## Adding to Claude Code
|
||||
### 3️⃣ Integration Options
|
||||
|
||||
#### Option A: Claude Code (CLI) Integration
|
||||
|
||||
1. Add the MCP server to Claude Code:
|
||||
```bash
|
||||
# Add the MCP server to Claude Code
|
||||
claude mcp add appwrite-mcp-server "C:\path\to\your\app-write-mcp\dist\index.js"
|
||||
```
|
||||
|
||||
Replace the path with your actual project location. For example:
|
||||
```bash
|
||||
# Example with actual path
|
||||
claude mcp add appwrite-mcp-server "C:\Users\moh12\app-write-mcp\dist\index.js"
|
||||
```
|
||||
|
||||
3. Restart Claude Code if needed.
|
||||
#### Option B: Cursor IDE Integration
|
||||
|
||||
## Available Tools
|
||||
> 💡 **Note:** Cursor doesn't support `.env` files for MCP servers, so we pass environment variables directly in the configuration.
|
||||
|
||||
### 🗄️ Database Operations
|
||||
1. **Open Command Palette** (`Ctrl/Cmd + Shift + P`)
|
||||
|
||||
- **create_database**: Create a new database
|
||||
- **list_databases**: List all databases in your project
|
||||
- **delete_database**: Delete a database
|
||||
2. **Type "Preferences: Open Settings (JSON)"**
|
||||
|
||||
### 📁 Collection Operations
|
||||
3. **Add MCP Server Configuration to your settings.json:**
|
||||
```json
|
||||
{
|
||||
"mcp.servers": {
|
||||
"appwrite-mcp-server": {
|
||||
"command": "node",
|
||||
"args": ["C:\\path\\to\\your\\app-write-mcp\\dist\\index.js"],
|
||||
"env": {
|
||||
"APPWRITE_PROJECT_ID": "your-project-id-here",
|
||||
"APPWRITE_API_ENDPOINT": "https://cloud.appwrite.io/v1",
|
||||
"APPWRITE_API_KEY": "your-api-key-here"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- **create_collection**: Create a new collection in a database
|
||||
- **list_collections**: List all collections in a database
|
||||
- **delete_collection**: Delete a collection from a database
|
||||
4. **Replace the configuration values:**
|
||||
- **Path**: Update `C:\\path\\to\\your\\app-write-mcp\\dist\\index.js` with your actual path
|
||||
- **Project ID**: Your Appwrite project ID
|
||||
- **API Endpoint**: Your Appwrite endpoint (Cloud or self-hosted)
|
||||
- **API Key**: Your Appwrite API key with required permissions
|
||||
|
||||
### 🏷️ Attribute Management
|
||||
5. **Example configuration:**
|
||||
```json
|
||||
{
|
||||
"mcp.servers": {
|
||||
"appwrite-mcp-server": {
|
||||
"command": "node",
|
||||
"args": ["C:\\Users\\username\\app-write-mcp\\dist\\index.js"],
|
||||
"env": {
|
||||
"APPWRITE_PROJECT_ID": "6612345a000818bb9d2e",
|
||||
"APPWRITE_API_ENDPOINT": "https://cloud.appwrite.io/v1",
|
||||
"APPWRITE_API_KEY": "standard_1234567890abcdef..."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- **create_string_attribute**: Create a string attribute in a collection
|
||||
- **create_integer_attribute**: Create an integer attribute in a collection
|
||||
- **create_boolean_attribute**: Create a boolean attribute in a collection
|
||||
- **create_email_attribute**: Create an email attribute in a collection
|
||||
- **create_datetime_attribute**: Create a datetime attribute in a collection
|
||||
- **list_attributes**: List all attributes in a collection
|
||||
- **delete_attribute**: Delete an attribute from a collection
|
||||
6. **Save the file and restart Cursor** to load the MCP server
|
||||
|
||||
### 📊 Index Management
|
||||
#### Option C: Continue.dev Integration
|
||||
|
||||
- **create_index**: Create an index in a collection (key, fulltext, unique)
|
||||
- **list_indexes**: List all indexes in a collection
|
||||
- **delete_index**: Delete an index from a collection
|
||||
1. **Open your Continue configuration file** (`~/.continue/config.json`)
|
||||
|
||||
### 📄 Document Operations
|
||||
2. **Add the MCP server to your configuration:**
|
||||
```json
|
||||
{
|
||||
"mcpServers": [
|
||||
{
|
||||
"name": "appwrite-mcp-server",
|
||||
"command": "node",
|
||||
"args": ["C:\\path\\to\\your\\app-write-mcp\\dist\\index.js"],
|
||||
"env": {
|
||||
"APPWRITE_PROJECT_ID": "your-project-id-here",
|
||||
"APPWRITE_API_ENDPOINT": "https://cloud.appwrite.io/v1",
|
||||
"APPWRITE_API_KEY": "your-api-key-here"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- **create_document**: Create a new document in a collection
|
||||
- **get_document**: Get a document by ID
|
||||
- **list_documents**: List documents in a collection with optional queries
|
||||
- **update_document**: Update a document
|
||||
- **delete_document**: Delete a document
|
||||
3. **Replace with your actual credentials** (same as Cursor configuration above)
|
||||
|
||||
### 👥 User Management
|
||||
4. **Restart your IDE** to apply the changes
|
||||
|
||||
- **create_user**: Create a new user
|
||||
- **list_users**: List all users
|
||||
- **get_user**: Get a user by ID
|
||||
- **update_user_email**: Update user email
|
||||
- **update_user_name**: Update user name
|
||||
- **update_user_password**: Update user password
|
||||
- **delete_user**: Delete a user
|
||||
### 4️⃣ Verification
|
||||
|
||||
### 🗂️ Storage Operations
|
||||
Once integrated, you should be able to use commands like:
|
||||
- "List my Appwrite databases"
|
||||
- "Create a new user with email test@example.com"
|
||||
- "Show me all collections in my database"
|
||||
|
||||
- **create_bucket**: Create a storage bucket
|
||||
- **list_buckets**: List all storage buckets
|
||||
- **get_bucket**: Get a bucket by ID
|
||||
- **update_bucket**: Update a storage bucket
|
||||
- **delete_bucket**: Delete a storage bucket
|
||||
- **list_files**: List files in a storage bucket
|
||||
## 🛠️ Available Tools (12 Total)
|
||||
|
||||
### ⚡ Function Management
|
||||
<details>
|
||||
<summary><strong>🗄️ Database Operations (1 tool)</strong></summary>
|
||||
|
||||
- **create_function**: Create a new serverless function
|
||||
- **list_functions**: List all functions
|
||||
- **get_function**: Get a function by ID
|
||||
- **update_function**: Update a function
|
||||
- **delete_function**: Delete a function
|
||||
| Tool | Actions | Description |
|
||||
|------|---------|-------------|
|
||||
| `manage_database` | create, get, list, update, delete | Comprehensive database management with enabled status |
|
||||
|
||||
### 👨👩👧👦 Team Management
|
||||
</details>
|
||||
|
||||
- **create_team**: Create a new team
|
||||
- **list_teams**: List all teams
|
||||
- **get_team**: Get a team by ID
|
||||
- **update_team**: Update a team
|
||||
- **delete_team**: Delete a team
|
||||
<details>
|
||||
<summary><strong>📁 Collection Operations (1 tool)</strong></summary>
|
||||
|
||||
### 🧠 Smart Schema Operations
|
||||
| Tool | Actions | Description |
|
||||
|------|---------|-------------|
|
||||
| `collection_operations` | create, get, list, update, delete | Complete collection lifecycle with document security, enabled status, and search |
|
||||
|
||||
- **auto_detect_schema**: Analyze sample data and automatically create collection schema
|
||||
- **suggest_indexes**: Recommend optimal indexes based on collection usage patterns
|
||||
- **validate_document**: Check document data against collection schema before creation
|
||||
- **schema_migration**: Automatically migrate collection schema with data preservation
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>🏷️ Attribute Management (1 tool)</strong></summary>
|
||||
|
||||
| Tool | Actions | Description |
|
||||
|------|---------|-------------|
|
||||
| `attribute_operations` | create, get, list, update, delete, bulk_create, bulk_delete | Full attribute management with array support and bulk operations |
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>📊 Index Management (1 tool)</strong></summary>
|
||||
|
||||
| Tool | Actions | Description |
|
||||
|------|---------|-------------|
|
||||
| `index_operations` | create, get, list, delete | Complete index management |
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>📄 Document Operations (2 tools)</strong></summary>
|
||||
|
||||
| Tool | Actions/Description |
|
||||
|------|--------------------|
|
||||
| `document_operations` | create, get, update, delete, bulk_create, bulk_update, bulk_delete |
|
||||
| `list_documents` | List documents with advanced queries and pagination |
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>👥 User Management (2 tools)</strong></summary>
|
||||
|
||||
| Tool | Actions/Description |
|
||||
|------|--------------------|
|
||||
| `user_operations` | create, get, update, delete, update_preferences, update_labels, bulk_create, bulk_update, bulk_delete |
|
||||
| `list_users` | List users with advanced filtering and pagination |
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>🗂️ Storage Operations (3 tools)</strong></summary>
|
||||
|
||||
| Tool | Actions/Description |
|
||||
|------|--------------------|
|
||||
| `bucket_operations` | create, get, list, update, delete - with advanced configuration (file size limits, allowed extensions, compression, encryption, antivirus) |
|
||||
| `file_operations` | get, create, update, delete, list, download - with actual file download implementation |
|
||||
| `get_file_url` | Generate download, preview, or view URLs with transformations |
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
### 📊 Data Analysis & Insights
|
||||
<details>
|
||||
<summary><strong>👨👩👧👦 Team Management (1 tool)</strong></summary>
|
||||
|
||||
- **analyze_collection**: Get comprehensive data insights and patterns from collections
|
||||
- **detect_duplicates**: Find potential duplicate records with similarity scoring
|
||||
- **data_quality_check**: Analyze data quality (completeness, validity, consistency)
|
||||
- **usage_stats**: Get usage statistics and access patterns for collections
|
||||
| Tool | Actions | Description |
|
||||
|------|---------|-------------|
|
||||
| `team_operations` | create, get, list, update, delete | Complete team management |
|
||||
|
||||
## Configuration
|
||||
</details>
|
||||
|
||||
### Getting Appwrite Credentials
|
||||
<details>
|
||||
<summary><strong>🏥 Health Monitoring (1 tool)</strong></summary>
|
||||
|
||||
1. **Project ID**: Found in your Appwrite console under Settings > General
|
||||
2. **API Endpoint**:
|
||||
- For Appwrite Cloud: `https://cloud.appwrite.io/v1`
|
||||
- For self-hosted: `https://your-domain.com/v1`
|
||||
3. **API Key**: Create a new API key in your Appwrite console under Settings > API Keys
|
||||
- Make sure to give it appropriate permissions for databases and collections
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
| `get_health` | Get overall health status of Appwrite services |
|
||||
|
||||
### Configuration File
|
||||
</details>
|
||||
|
||||
The `appwrite-config.json` file should be in the root directory of this project:
|
||||
---
|
||||
|
||||
```json
|
||||
{
|
||||
"projectId": "your-project-id-here",
|
||||
"apiEndpoint": "https://cloud.appwrite.io/v1",
|
||||
"apiKey": "your-api-key-here"
|
||||
}
|
||||
|
||||
## ⚙️ Configuration Guide
|
||||
|
||||
### 🔑 Getting Appwrite Credentials
|
||||
|
||||
1. **🆔 Project ID**: Found in your Appwrite console under **Settings > General**
|
||||
2. **🌐 API Endpoint**:
|
||||
- **Appwrite Cloud**: `https://cloud.appwrite.io/v1`
|
||||
- **Self-hosted**: `https://your-domain.com/v1`
|
||||
3. **🔐 API Key**: Create a new API key in your Appwrite console under **Settings > API Keys**
|
||||
- ✅ Required scopes: `databases.read`, `databases.write`, `users.read`, `users.write`, `storage.read`, `storage.write`, `teams.read`, `teams.write`, `health.read`
|
||||
|
||||
### 🎯 VS Official Implementation
|
||||
|
||||
| Feature | Our Implementation | Official Appwrite MCP |
|
||||
|---------|-------------------|----------------------|
|
||||
| **Tools Available** | 🟢 12 optimized tools (context-efficient) | 🟡 195 tools (selective enabling) |
|
||||
| **Context Usage** | 🟢 Optimized token usage | 🔴 Over 60,000 tokens |
|
||||
| **Tool Design** | 🟢 Action-based combined tools | 🟡 Individual tools for each operation |
|
||||
| **Core Operations** | 🟢 All essential database, user, storage, and team features | 🟡 Database tools only (context limits) |
|
||||
| **Storage Operations** | 🟢 Complete file operations with download & advanced bucket config | 🟡 Basic bucket operations |
|
||||
| **User Management** | 🟢 CRUD + preferences + bulk operations | 🟡 Basic CRUD only |
|
||||
| **Advanced Features** | 🟢 Document security, file encryption, array attributes, compression | 🔴 Limited |
|
||||
| **Bulk Operations** | 🟢 Integrated into respective categories | 🔴 Not available |
|
||||
| **Error Handling** | 🟢 Comprehensive with validation | 🟡 Basic |
|
||||
| **Language** | 🟡 TypeScript/Node.js | 🟢 Python |
|
||||
| **Maintenance** | 🟢 Easier with fewer tools | 🟡 Complex with many tools |
|
||||
|
||||
## 🎯 Usage Examples
|
||||
|
||||
Once integrated, you can use natural language commands with Claude to interact with Appwrite:
|
||||
|
||||
<details>
|
||||
<summary><strong>🗄️ Database & Collection Management</strong></summary>
|
||||
|
||||
```
|
||||
✨ "Create a new database called 'ecommerce'"
|
||||
✨ "List all my databases"
|
||||
✨ "Create a collection called 'products' in the ecommerce database"
|
||||
✨ "Show me all collections in the ecommerce database"
|
||||
✨ "Delete the old 'test' database"
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
</details>
|
||||
|
||||
Once added to Claude Code, you can use natural language to interact with Appwrite:
|
||||
<details>
|
||||
<summary><strong>🏷️ Schema & Attributes</strong></summary>
|
||||
|
||||
**Database & Collection Management:**
|
||||
- "Create a new database called 'blog'"
|
||||
- "List all my databases"
|
||||
- "Create a collection called 'posts' in the blog database"
|
||||
- "Show me all collections in the blog database"
|
||||
```
|
||||
✨ "Create a string attribute called 'name' in the products collection"
|
||||
✨ "Add multiple attributes with bulk create operation"
|
||||
✨ "List all attributes in the products collection"
|
||||
✨ "Update attribute settings for existing fields"
|
||||
✨ "Create a unique index on the 'sku' attribute"
|
||||
✨ "Remove old attributes with bulk delete"
|
||||
```
|
||||
|
||||
**Attribute & Schema Management:**
|
||||
- "Add a string attribute called 'title' to the posts collection with max size 255"
|
||||
- "Create a boolean attribute 'published' in the posts collection"
|
||||
- "List all attributes in the posts collection"
|
||||
- "Create a unique index on the 'slug' attribute"
|
||||
</details>
|
||||
|
||||
**Document Operations:**
|
||||
- "Create a new document in the posts collection with title 'Hello World'"
|
||||
- "List all documents in the posts collection"
|
||||
- "Update document xyz123 in the posts collection"
|
||||
- "Get document abc456 from the posts collection"
|
||||
<details>
|
||||
<summary><strong>📄 Document Operations</strong></summary>
|
||||
|
||||
**User Management:**
|
||||
- "Create a new user with email john@example.com"
|
||||
- "List all users in the project"
|
||||
- "Update user xyz123's name to 'John Doe'"
|
||||
- "Delete user abc456"
|
||||
```
|
||||
✨ "Create a new product document with name 'iPhone 15' and price 999"
|
||||
✨ "List all documents in the products collection"
|
||||
✨ "Update document xyz123's price to 899"
|
||||
✨ "Get document abc456 from the products collection"
|
||||
✨ "Delete all out-of-stock products"
|
||||
```
|
||||
|
||||
**Storage Management:**
|
||||
- "Create a storage bucket called 'images'"
|
||||
- "List all storage buckets"
|
||||
- "Show me all files in the images bucket"
|
||||
</details>
|
||||
|
||||
**Function Management:**
|
||||
- "Create a new function called 'sendEmail' with Node.js runtime"
|
||||
- "List all functions"
|
||||
- "Update function abc123's timeout to 300 seconds"
|
||||
<details>
|
||||
<summary><strong>👥 User Management</strong></summary>
|
||||
|
||||
**Team Management:**
|
||||
- "Create a new team called 'Developers'"
|
||||
- "List all teams"
|
||||
- "Add user john@example.com to the Developers team"
|
||||
```
|
||||
✨ "Create a new user with email john@example.com"
|
||||
✨ "List all users in the project with filtering"
|
||||
✨ "Update user xyz123's name and email"
|
||||
✨ "Update user labels for admin permissions"
|
||||
✨ "Delete inactive user accounts"
|
||||
✨ "Update user preferences for notifications"
|
||||
✨ "Bulk create 10 test users for demo"
|
||||
✨ "Bulk update user information from CSV"
|
||||
```
|
||||
|
||||
**🧠 Smart Schema Operations:**
|
||||
- "Analyze this sample data and create a collection for me"
|
||||
- "Suggest optimal indexes for my users collection"
|
||||
- "Validate this document before I create it"
|
||||
- "Migrate my collection to add these new fields safely"
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>🗂️ Storage & File Management</strong></summary>
|
||||
|
||||
```
|
||||
✨ "Create a new storage bucket for user uploads"
|
||||
✨ "List all files in the images bucket"
|
||||
✨ "Get download URL for file abc123"
|
||||
✨ "Generate preview URL for image with 300x200 dimensions"
|
||||
✨ "Get file view URL for document xyz456"
|
||||
✨ "Delete old file from storage bucket"
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
**📊 Data Analysis & Insights:**
|
||||
- "Analyze the health and patterns in my users collection"
|
||||
- "Find duplicate records in my products collection"
|
||||
- "Check the data quality of my orders collection"
|
||||
- "Show me usage statistics for my database"
|
||||
|
||||
## Development
|
||||
|
||||
- `npm run build`: Build TypeScript to JavaScript
|
||||
- `npm run dev`: Watch mode for development
|
||||
- `npm start`: Run the built server
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
1. **Configuration not found**: Make sure `appwrite-config.json` exists in the project root
|
||||
2. **API Key issues**: Ensure your API key has the correct permissions for database operations
|
||||
3. **Connection issues**: Verify your API endpoint is correct (especially for self-hosted instances)
|
||||
### 🎬 **Real-World Scenarios**
|
||||
|
||||
## License
|
||||
**E-commerce Setup:**
|
||||
```
|
||||
1. "Create an ecommerce database"
|
||||
2. "Create a products collection with attributes"
|
||||
3. "Bulk create product documents from inventory"
|
||||
4. "Set up user authentication for customers"
|
||||
5. "Create indexes for search optimization"
|
||||
```
|
||||
|
||||
MIT
|
||||
**Content Management:**
|
||||
```
|
||||
1. "Create a blog database with posts and comments collections"
|
||||
2. "Create string and datetime attributes for blog posts"
|
||||
3. "List all blog posts with pagination"
|
||||
4. "Update blog post content and metadata"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Development
|
||||
|
||||
```bash
|
||||
# Build TypeScript to JavaScript
|
||||
npm run build
|
||||
|
||||
# Watch mode for development
|
||||
npm run dev
|
||||
|
||||
# Run the built server
|
||||
npm start
|
||||
```
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
<details>
|
||||
<summary><strong>Common Issues & Solutions</strong></summary>
|
||||
|
||||
| Issue | Solution |
|
||||
|-------|----------|
|
||||
| **❌ Configuration not found** | Make sure `.env` file exists in your working directory |
|
||||
| **❌ API Key issues** | Ensure your API key has all required scopes enabled |
|
||||
| **❌ Connection failed** | Verify your API endpoint is correct (check for typos) |
|
||||
| **❌ Tools not loading** | Restart your IDE after adding the MCP server |
|
||||
| **❌ Permission denied** | Check that your API key has `databases.write`, `users.write` permissions |
|
||||
| **❌ Schema validation errors** | Use `attribute_operations` with list action to check collection schema |
|
||||
|
||||
</details>
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
1. Fork the repository
|
||||
2. Create a feature branch: `git checkout -b feature/amazing-feature`
|
||||
3. Commit your changes: `git commit -m 'Add amazing feature'`
|
||||
4. Push to the branch: `git push origin feature/amazing-feature`
|
||||
5. Open a Pull Request
|
||||
|
||||
## 📄 License
|
||||
|
||||
MIT License - see [LICENSE](LICENSE) file for details
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
|
||||
**⭐ Star this repo if it helped you!**
|
||||
|
||||
Built with ❤️ for the Appwrite and Claude communities
|
||||
|
||||
[Report Bug](https://git.nebulm.com/smoido/app-write-mcp/issues) • [Request Feature](https://git.nebulm.com/smoido/app-write-mcp/issues) • [Documentation](https://git.nebulm.com/smoido/app-write-mcp/wiki)
|
||||
|
||||
</div>
|
||||
409
removed-tools-backup.ts
Normal file
409
removed-tools-backup.ts
Normal file
@@ -0,0 +1,409 @@
|
||||
/**
|
||||
* REMOVED TOOLS BACKUP
|
||||
*
|
||||
* This file contains all the tools that were removed from the main MCP server
|
||||
* to reduce context usage. These tools can be restored if needed in the future.
|
||||
*
|
||||
* Removed on: 2025-09-05
|
||||
* Reason: Reduce MCP context usage from ~61,830 tokens to under 25,000 tokens
|
||||
*
|
||||
* Categories of removed tools:
|
||||
* 1. Data Analysis & Intelligence Tools (8 tools)
|
||||
* 2. Avatars Service (7 tools)
|
||||
* 3. Locale Service (5 tools)
|
||||
* 4. Advanced User Management (12 tools)
|
||||
* 5. Messaging Targets (5 tools)
|
||||
* 6. Health Monitoring (2 tools) - kept get_health only
|
||||
* 7. Session Management (3 tools)
|
||||
* 8. Function Execution (1 tool)
|
||||
*
|
||||
* Total removed: ~43 tools
|
||||
*/
|
||||
|
||||
// ===== DATA ANALYSIS & INTELLIGENCE TOOLS (8 tools) =====
|
||||
|
||||
// auto_detect_schema - Smart analysis feature
|
||||
const autoDetectSchemaTool = {
|
||||
name: "auto_detect_schema",
|
||||
description: "Analyze sample data and automatically create collection schema with appropriate attributes",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
databaseId: { type: "string", description: "ID of the database" },
|
||||
collectionName: { type: "string", description: "Name for the new collection" },
|
||||
collectionId: { type: "string", description: "Custom collection ID (optional)" },
|
||||
sampleData: {
|
||||
type: "array",
|
||||
items: { type: "object" },
|
||||
description: "Array of sample documents to analyze"
|
||||
}
|
||||
},
|
||||
required: ["databaseId", "collectionName", "sampleData"]
|
||||
}
|
||||
};
|
||||
|
||||
// suggest_indexes - Analysis recommendation
|
||||
const suggestIndexesTool = {
|
||||
name: "suggest_indexes",
|
||||
description: "Analyze collection usage patterns and recommend optimal indexes",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
databaseId: { type: "string", description: "ID of the database" },
|
||||
collectionId: { type: "string", description: "ID of the collection" },
|
||||
queryPatterns: {
|
||||
type: "array",
|
||||
items: { type: "string" },
|
||||
description: "Common query patterns (optional)"
|
||||
}
|
||||
},
|
||||
required: ["databaseId", "collectionId"]
|
||||
}
|
||||
};
|
||||
|
||||
// validate_document - Pre-validation
|
||||
const validateDocumentTool = {
|
||||
name: "validate_document",
|
||||
description: "Validate document data against collection schema before creation",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
databaseId: { type: "string", description: "ID of the database" },
|
||||
collectionId: { type: "string", description: "ID of the collection" },
|
||||
documentData: { type: "object", description: "Document data to validate" }
|
||||
},
|
||||
required: ["databaseId", "collectionId", "documentData"]
|
||||
}
|
||||
};
|
||||
|
||||
// schema_migration - Advanced schema operation
|
||||
const schemaMigrationTool = {
|
||||
name: "schema_migration",
|
||||
description: "Automatically migrate collection schema with data preservation",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
databaseId: { type: "string", description: "ID of the database" },
|
||||
collectionId: { type: "string", description: "ID of the collection" },
|
||||
newSchema: {
|
||||
type: "array",
|
||||
items: { type: "object" },
|
||||
description: "New schema definition"
|
||||
},
|
||||
migrationStrategy: {
|
||||
type: "string",
|
||||
enum: ["safe", "aggressive"],
|
||||
description: "Migration strategy (safe, aggressive)",
|
||||
default: "safe"
|
||||
}
|
||||
},
|
||||
required: ["databaseId", "collectionId", "newSchema"]
|
||||
}
|
||||
};
|
||||
|
||||
// analyze_collection - Data insights analysis
|
||||
const analyzeCollectionTool = {
|
||||
name: "analyze_collection",
|
||||
description: "Get comprehensive data insights and patterns from a collection",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
databaseId: { type: "string", description: "ID of the database" },
|
||||
collectionId: { type: "string", description: "ID of the collection" },
|
||||
analysisType: {
|
||||
type: "string",
|
||||
enum: ["basic", "detailed", "statistical"],
|
||||
description: "Type of analysis",
|
||||
default: "basic"
|
||||
}
|
||||
},
|
||||
required: ["databaseId", "collectionId"]
|
||||
}
|
||||
};
|
||||
|
||||
// detect_duplicates - Data analysis feature
|
||||
const detectDuplicatesTool = {
|
||||
name: "detect_duplicates",
|
||||
description: "Find potential duplicate records across collections",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
databaseId: { type: "string", description: "ID of the database" },
|
||||
collectionId: { type: "string", description: "ID of the collection" },
|
||||
fields: {
|
||||
type: "array",
|
||||
items: { type: "string" },
|
||||
description: "Fields to check for duplicates"
|
||||
},
|
||||
threshold: {
|
||||
type: "number",
|
||||
description: "Similarity threshold (0-1)",
|
||||
default: 0.9
|
||||
}
|
||||
},
|
||||
required: ["databaseId", "collectionId", "fields"]
|
||||
}
|
||||
};
|
||||
|
||||
// data_quality_check - Quality analysis
|
||||
const dataQualityCheckTool = {
|
||||
name: "data_quality_check",
|
||||
description: "Analyze data quality and identify issues (missing fields, invalid formats, etc.)",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
databaseId: { type: "string", description: "ID of the database" },
|
||||
collectionId: { type: "string", description: "ID of the collection" },
|
||||
checkType: {
|
||||
type: "string",
|
||||
enum: ["completeness", "validity", "consistency", "all"],
|
||||
description: "Type of quality check",
|
||||
default: "all"
|
||||
}
|
||||
},
|
||||
required: ["databaseId", "collectionId"]
|
||||
}
|
||||
};
|
||||
|
||||
// usage_stats - Analytics feature
|
||||
const usageStatsTool = {
|
||||
name: "usage_stats",
|
||||
description: "Get usage statistics and access patterns for collections and documents",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
databaseId: { type: "string", description: "ID of the database" },
|
||||
collectionId: { type: "string", description: "ID of the collection (optional, for all collections if not specified)" },
|
||||
timeRange: {
|
||||
type: "string",
|
||||
enum: ["1d", "7d", "30d", "90d"],
|
||||
description: "Time range for stats",
|
||||
default: "7d"
|
||||
}
|
||||
},
|
||||
required: ["databaseId"]
|
||||
}
|
||||
};
|
||||
|
||||
// ===== AVATARS SERVICE (7 tools) =====
|
||||
|
||||
const avatarTools = [
|
||||
{
|
||||
name: "get_browser_icon",
|
||||
description: "Get browser icon image URL",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
code: { type: "string", description: "Browser code" },
|
||||
width: { type: "number", description: "Icon width (optional)" },
|
||||
height: { type: "number", description: "Icon height (optional)" },
|
||||
quality: { type: "number", description: "Image quality (optional)" }
|
||||
},
|
||||
required: ["code"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "get_credit_card_icon",
|
||||
description: "Get credit card icon image URL",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
code: { type: "string", description: "Credit card code" },
|
||||
width: { type: "number", description: "Icon width (optional)" },
|
||||
height: { type: "number", description: "Icon height (optional)" },
|
||||
quality: { type: "number", description: "Image quality (optional)" }
|
||||
},
|
||||
required: ["code"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "get_favicon",
|
||||
description: "Get website favicon URL",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
url: { type: "string", description: "Website URL" }
|
||||
},
|
||||
required: ["url"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "get_flag_icon",
|
||||
description: "Get country flag icon URL",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
code: { type: "string", description: "Country code" },
|
||||
width: { type: "number", description: "Icon width (optional)" },
|
||||
height: { type: "number", description: "Icon height (optional)" },
|
||||
quality: { type: "number", description: "Image quality (optional)" }
|
||||
},
|
||||
required: ["code"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "get_image_from_url",
|
||||
description: "Get image from URL with transformations",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
url: { type: "string", description: "Image URL" },
|
||||
width: { type: "number", description: "Image width (optional)" },
|
||||
height: { type: "number", description: "Image height (optional)" }
|
||||
},
|
||||
required: ["url"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "get_initials_avatar",
|
||||
description: "Generate initials avatar URL",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: { type: "string", description: "Name for initials" },
|
||||
width: { type: "number", description: "Avatar width (optional)" },
|
||||
height: { type: "number", description: "Avatar height (optional)" },
|
||||
background: { type: "string", description: "Background color (optional)" }
|
||||
},
|
||||
required: ["name"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "get_qr_code",
|
||||
description: "Generate QR code URL",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
text: { type: "string", description: "Text to encode" },
|
||||
size: { type: "number", description: "QR code size (optional)" },
|
||||
margin: { type: "number", description: "QR code margin (optional)" },
|
||||
download: { type: "boolean", description: "Force download (optional)" }
|
||||
},
|
||||
required: ["text"]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// ===== LOCALE SERVICE (5 tools) =====
|
||||
|
||||
const localeTools = [
|
||||
{
|
||||
name: "list_countries",
|
||||
description: "List all countries with phone codes"
|
||||
},
|
||||
{
|
||||
name: "list_continents",
|
||||
description: "List all continents"
|
||||
},
|
||||
{
|
||||
name: "list_currencies",
|
||||
description: "List all currencies"
|
||||
},
|
||||
{
|
||||
name: "list_languages",
|
||||
description: "List all languages"
|
||||
},
|
||||
{
|
||||
name: "list_phone_codes",
|
||||
description: "List phone codes for all countries"
|
||||
}
|
||||
];
|
||||
|
||||
// ===== ADVANCED USER MANAGEMENT (12 tools) =====
|
||||
|
||||
const advancedUserTools = [
|
||||
"verify_user_email",
|
||||
"unverify_user_email",
|
||||
"verify_user_phone",
|
||||
"unverify_user_phone",
|
||||
"update_user_mfa",
|
||||
"create_user_mfa_recovery_codes",
|
||||
"update_user_phone_verification",
|
||||
"update_user_password_hash",
|
||||
"list_user_identities",
|
||||
"delete_user_identity",
|
||||
"update_user_labels",
|
||||
"get_user_preferences"
|
||||
];
|
||||
|
||||
// ===== MESSAGING TARGETS (5 tools) =====
|
||||
|
||||
const messagingTargetTools = [
|
||||
"create_user_target",
|
||||
"list_user_targets",
|
||||
"get_user_target",
|
||||
"update_user_target",
|
||||
"delete_user_target"
|
||||
];
|
||||
|
||||
// ===== HEALTH MONITORING (2 tools - kept get_health only) =====
|
||||
|
||||
const healthTools = [
|
||||
"get_health_db",
|
||||
"get_health_storage"
|
||||
];
|
||||
|
||||
// ===== SESSION MANAGEMENT (3 tools) =====
|
||||
|
||||
const sessionTools = [
|
||||
"create_session",
|
||||
"delete_session",
|
||||
"list_sessions"
|
||||
];
|
||||
|
||||
// ===== FUNCTION EXECUTION (1 tool) =====
|
||||
|
||||
const functionExecutionTools = [
|
||||
"execute_function"
|
||||
];
|
||||
|
||||
/**
|
||||
* TOOL IMPLEMENTATIONS
|
||||
*
|
||||
* The actual implementation code for these tools was removed from the main file.
|
||||
* If you need to restore any of these tools:
|
||||
*
|
||||
* 1. Add the tool definition back to the tools list in setupToolHandlers()
|
||||
* 2. Add the case handler back to the handleTool() switch statement
|
||||
* 3. Restore the implementation method to the class
|
||||
*
|
||||
* The implementations used the standard pattern:
|
||||
* - Validate configuration
|
||||
* - Parse input parameters
|
||||
* - Call appropriate Appwrite service method
|
||||
* - Return formatted response
|
||||
* - Handle errors gracefully
|
||||
*/
|
||||
|
||||
export {
|
||||
// Data Analysis Tools
|
||||
autoDetectSchemaTool,
|
||||
suggestIndexesTool,
|
||||
validateDocumentTool,
|
||||
schemaMigrationTool,
|
||||
analyzeCollectionTool,
|
||||
detectDuplicatesTool,
|
||||
dataQualityCheckTool,
|
||||
usageStatsTool,
|
||||
|
||||
// Avatar Tools
|
||||
avatarTools,
|
||||
|
||||
// Locale Tools
|
||||
localeTools,
|
||||
|
||||
// Advanced User Tools
|
||||
advancedUserTools,
|
||||
|
||||
// Messaging Target Tools
|
||||
messagingTargetTools,
|
||||
|
||||
// Health Tools
|
||||
healthTools,
|
||||
|
||||
// Session Tools
|
||||
sessionTools,
|
||||
|
||||
// Function Execution Tools
|
||||
functionExecutionTools
|
||||
};
|
||||
3870
src/index.ts
3870
src/index.ts
File diff suppressed because it is too large
Load Diff
4425
src/index.ts.backup
Normal file
4425
src/index.ts.backup
Normal file
File diff suppressed because it is too large
Load Diff
4425
src/index.ts.old
Normal file
4425
src/index.ts.old
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"module": "Node16",
|
||||
"moduleResolution": "node16",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
|
||||
Reference in New Issue
Block a user