removed redundant tools
This commit is contained in:
10
.claude/settings.local.json
Normal file
10
.claude/settings.local.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"allow": [
|
||||||
|
"Bash(npm run:*)",
|
||||||
|
"Bash(npm help)"
|
||||||
|
],
|
||||||
|
"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.
|
||||||
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
|
||||||
|
};
|
||||||
1513
src/index.ts
1513
src/index.ts
File diff suppressed because it is too large
Load Diff
6585
src/index.ts.backup
Normal file
6585
src/index.ts.backup
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user