Compare commits

..

21 Commits

Author SHA1 Message Date
910873498a feat: add database/collection/storage enhancements, file download, array attributes, remove messaging tools 2025-11-01 22:04:36 +03:00
6dcf8aa0ff fixed issue: when listing: (collections, attributes, indexes, users, buckets, files, teams) is only listed the first 25 items, now it lists up to 5000, listing documents was not affected because it already used pagination 2025-11-01 21:24:16 +03:00
a2926293df Merge branch 'master' of https://git.nebulm.com/smoido/app-write-mcp 2025-10-29 01:15:25 +03:00
308290c122 fix: query parsing, attribute size updates, and detailed attribute display 2025-10-29 01:14:07 +03:00
865a48e1d4 Add chmod step for Linux/macOS in installation 2025-10-16 04:15:18 +03:00
66bb003b91 readme links 2025-10-05 23:43:42 +03:00
2f5f361013 readme update 2025-09-05 05:35:29 +03:00
3c763fc44f fixed newlines 2025-09-05 05:26:39 +03:00
7084a7d5b2 down to 16 general tools only 2025-09-05 05:09:13 +03:00
3e9dce4ccb removed redundant tools 2025-09-05 03:44:25 +03:00
3c23e30b0c fixed issues 2025-09-04 22:27:48 +03:00
0a362b37b1 fixed 3 tools 2025-07-27 23:31:51 +03:00
1ebc34764b added 68 tools 2025-07-27 18:12:02 +03:00
5f7fc55d09 added general attribute creation tool, bulk attribute creatin, bulk attribute removal, user authentication 2025-07-27 15:36:30 +03:00
8a2f79dddb wring error message when .env not configed 2025-07-27 14:26:56 +03:00
dca14b1c9d 67 2025-07-26 05:24:26 +03:00
c0e76867a5 cursor readme 2025-07-25 19:49:28 +03:00
d7c1111762 stable 2 2025-07-25 18:30:37 +03:00
68b6067824 stable 2025-07-25 18:05:59 +03:00
76f1180cde fixes 2025-07-25 17:45:41 +03:00
62f7f125d3 bulk and auth functions 2025-07-25 16:43:30 +03:00
8 changed files with 10873 additions and 3016 deletions

View File

@@ -0,0 +1,11 @@
{
"permissions": {
"allow": [
"Bash(npm run:*)",
"Bash(npm help)",
"Bash(git checkout:*)"
],
"deny": [],
"ask": []
}
}

94
CLAUDE.md Normal file
View 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
View File

@@ -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">
![Appwrite MCP](https://img.shields.io/badge/Appwrite-MCP-red?style=for-the-badge&logo=appwrite)
![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
![Claude](https://img.shields.io/badge/Claude-AI-orange?style=for-the-badge)
**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 ## 🚀 Features
**Core Appwrite Management:** **🎯 Core Appwrite Operations:**
- Complete database and collection operations - **Database Management** - Create, get, list, update, and delete databases with enabled status
- Document CRUD with full query support - **Collection Operations** - Full collection lifecycle with document security and search support
- User management and authentication - **Document CRUD** - Complete document operations with bulk support and advanced queries
- Storage buckets and file operations - **User Management** - User operations including bulk processing and preferences
- Serverless function management - **Storage Management** - Complete bucket operations with advanced configuration (file size limits, allowed extensions, compression, encryption, antivirus) and file upload/download
- Team and permission management - **Team Management** - Team CRUD operations
- **Attribute & Index Management** - Schema management with array support and bulk operations
- **Health Monitoring** - System health checks
**🧠 Intelligent Database Assistant:** **⚡ Action-Based Design:**
- **Auto-detect schemas** from sample data - **Single tools handle multiple operations** using action parameters
- **Data quality analysis** and recommendations - **Bulk operations integrated** into respective categories
- **Duplicate detection** with similarity matching - **Context-optimized** - Efficient tool design for reduced token usage
- **Index optimization** suggestions - **Advanced features** - Document security, file download, bucket encryption, array attributes
- **Schema migrations** with safety checks
## Installation ## 📦 Quick Start
### 1⃣ Installation
1. Clone this repository:
```bash ```bash
# Clone the repository
git clone <repository-url> git clone <repository-url>
cd appwrite-mcp-server cd appwrite-mcp-server
```
2. Install dependencies: # Install dependencies
```bash
npm install npm install
```
3. Build the TypeScript code: # Build the TypeScript code
```bash
npm run build 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 ```bash
# Copy the example file to your current working directory # Copy the example file to your current working directory
cp /path/to/app-write-mcp/.env.example ./.env cp /path/to/app-write-mcp/.env.example ./.env
``` ```
5. Edit the `.env` file in your current directory with your Appwrite project details: Edit your `.env` file with your Appwrite credentials:
```bash
APPWRITE_PROJECT_ID=your-project-id ```env
APPWRITE_PROJECT_ID=your-project-id-here
APPWRITE_API_ENDPOINT=https://cloud.appwrite.io/v1 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 ```bash
# Add the MCP server to Claude Code
claude mcp add appwrite-mcp-server "C:\path\to\your\app-write-mcp\dist\index.js" 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: # Example with actual path
```bash
claude mcp add appwrite-mcp-server "C:\Users\moh12\app-write-mcp\dist\index.js" 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 2. **Type "Preferences: Open Settings (JSON)"**
- **list_databases**: List all databases in your project
- **delete_database**: Delete a database
### 📁 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 4. **Replace the configuration values:**
- **list_collections**: List all collections in a database - **Path**: Update `C:\\path\\to\\your\\app-write-mcp\\dist\\index.js` with your actual path
- **delete_collection**: Delete a collection from a database - **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 6. **Save the file and restart Cursor** to load the MCP server
- **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
### 📊 Index Management #### Option C: Continue.dev Integration
- **create_index**: Create an index in a collection (key, fulltext, unique) 1. **Open your Continue configuration file** (`~/.continue/config.json`)
- **list_indexes**: List all indexes in a collection
- **delete_index**: Delete an index from a collection
### 📄 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 3. **Replace with your actual credentials** (same as Cursor configuration above)
- **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
### 👥 User Management 4. **Restart your IDE** to apply the changes
- **create_user**: Create a new user ### 4⃣ Verification
- **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
### 🗂️ 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 ## 🛠️ Available Tools (12 Total)
- **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
### ⚡ Function Management <details>
<summary><strong>🗄️ Database Operations (1 tool)</strong></summary>
- **create_function**: Create a new serverless function | Tool | Actions | Description |
- **list_functions**: List all functions |------|---------|-------------|
- **get_function**: Get a function by ID | `manage_database` | create, get, list, update, delete | Comprehensive database management with enabled status |
- **update_function**: Update a function
- **delete_function**: Delete a function
### 👨‍👩‍👧‍👦 Team Management </details>
- **create_team**: Create a new team <details>
- **list_teams**: List all teams <summary><strong>📁 Collection Operations (1 tool)</strong></summary>
- **get_team**: Get a team by ID
- **update_team**: Update a team
- **delete_team**: Delete a team
### 🧠 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 </details>
- **suggest_indexes**: Recommend optimal indexes based on collection usage patterns
- **validate_document**: Check document data against collection schema before creation <details>
- **schema_migration**: Automatically migrate collection schema with data preservation <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 | Tool | Actions | Description |
- **detect_duplicates**: Find potential duplicate records with similarity scoring |------|---------|-------------|
- **data_quality_check**: Analyze data quality (completeness, validity, consistency) | `team_operations` | create, get, list, update, delete | Complete team management |
- **usage_stats**: Get usage statistics and access patterns for collections
## 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 | Tool | Description |
2. **API Endpoint**: |------|-------------|
- For Appwrite Cloud: `https://cloud.appwrite.io/v1` | `get_health` | Get overall health status of Appwrite services |
- 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
### Configuration File </details>
The `appwrite-config.json` file should be in the root directory of this project: ---
```json
{ ## ⚙️ Configuration Guide
"projectId": "your-project-id-here",
"apiEndpoint": "https://cloud.appwrite.io/v1", ### 🔑 Getting Appwrite Credentials
"apiKey": "your-api-key-here"
} 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'" "Create a string attribute called 'name' in the products collection"
- "List all my databases" ✨ "Add multiple attributes with bulk create operation"
- "Create a collection called 'posts' in the blog database" ✨ "List all attributes in the products collection"
- "Show me all collections in the blog database" ✨ "Update attribute settings for existing fields"
✨ "Create a unique index on the 'sku' attribute"
✨ "Remove old attributes with bulk delete"
```
**Attribute & Schema Management:** </details>
- "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"
**Document Operations:** <details>
- "Create a new document in the posts collection with title 'Hello World'" <summary><strong>📄 Document Operations</strong></summary>
- "List all documents in the posts collection"
- "Update document xyz123 in the posts collection"
- "Get document abc456 from the posts collection"
**User Management:** ```
- "Create a new user with email john@example.com" "Create a new product document with name 'iPhone 15' and price 999"
- "List all users in the project" "List all documents in the products collection"
- "Update user xyz123's name to 'John Doe'" "Update document xyz123's price to 899"
- "Delete user abc456" ✨ "Get document abc456 from the products collection"
✨ "Delete all out-of-stock products"
```
**Storage Management:** </details>
- "Create a storage bucket called 'images'"
- "List all storage buckets"
- "Show me all files in the images bucket"
**Function Management:** <details>
- "Create a new function called 'sendEmail' with Node.js runtime" <summary><strong>👥 User Management</strong></summary>
- "List all functions"
- "Update function abc123's timeout to 300 seconds"
**Team Management:** ```
- "Create a new team called 'Developers'" "Create a new user with email john@example.com"
- "List all teams" "List all users in the project with filtering"
- "Add user john@example.com to the Developers team" ✨ "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:** </details>
- "Analyze this sample data and create a collection for me"
- "Suggest optimal indexes for my users collection" <details>
- "Validate this document before I create it" <summary><strong>🗂️ Storage & File Management</strong></summary>
- "Migrate my collection to add these new fields safely"
```
✨ "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 ### 🎬 **Real-World Scenarios**
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)
## 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
View 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
};

File diff suppressed because it is too large Load Diff

4425
src/index.ts.backup Normal file

File diff suppressed because it is too large Load Diff

4425
src/index.ts.old Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ES2022", "target": "ES2022",
"module": "ESNext", "module": "Node16",
"moduleResolution": "node", "moduleResolution": "node16",
"outDir": "./dist", "outDir": "./dist",
"rootDir": "./src", "rootDir": "./src",
"strict": true, "strict": true,