This commit is contained in:
2025-07-25 16:29:56 +03:00
parent e3d1738ae6
commit cc50c64423
7 changed files with 57 additions and 34 deletions

11
.env.example Normal file
View File

@@ -0,0 +1,11 @@
# Appwrite Configuration
# Copy this file to .env in your current working directory and fill in your values
# Your Appwrite Project ID
APPWRITE_PROJECT_ID=your-project-id-here
# Your Appwrite API Endpoint (e.g., https://cloud.appwrite.io/v1 or your self-hosted URL)
APPWRITE_API_ENDPOINT=https://cloud.appwrite.io/v1
# Your Appwrite API Key (Server API Key with required permissions)
APPWRITE_API_KEY=your-api-key-here

3
.gitignore vendored
View File

@@ -8,8 +8,7 @@ yarn-error.log*
dist/ dist/
build/ build/
# Environment and config files # Environment and config files
appwrite-config.json
.env .env
.env.local .env.local
.env.development.local .env.development.local

View File

@@ -37,23 +37,21 @@ npm install
npm run build npm run build
``` ```
4. Configure your Appwrite credentials by creating `appwrite-config.json` in your **current working directory** (where you run Claude Code from), not in the cloned repository: 4. Configure your Appwrite credentials by creating a `.env` file in your **current working directory** (where you run Claude Code from):
```bash ```bash
# Copy the template to your current working directory # Copy the example file to your current working directory
cp /path/to/app-write-mcp/appwrite-config.json.template ./appwrite-config.json cp /path/to/app-write-mcp/.env.example ./.env
``` ```
5. Edit the `appwrite-config.json` file in your current directory with your Appwrite project details: 5. Edit the `.env` file in your current directory with your Appwrite project details:
```json ```bash
{ APPWRITE_PROJECT_ID=your-project-id
"projectId": "your-project-id", APPWRITE_API_ENDPOINT=https://cloud.appwrite.io/v1
"apiEndpoint": "https://cloud.appwrite.io/v1", APPWRITE_API_KEY=your-api-key
"apiKey": "your-api-key"
}
``` ```
**Important:** The MCP server looks for `appwrite-config.json` 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. **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.
## Adding to Claude Code ## Adding to Claude Code

View File

@@ -1,5 +0,0 @@
{
"projectId": "YOUR_PROJECT_ID_HERE",
"apiEndpoint": "YOUR_API_ENDPOINT_HERE",
"apiKey": "YOUR_API_KEY_HERE"
}

13
package-lock.json generated
View File

@@ -10,6 +10,7 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@modelcontextprotocol/sdk": "^1.0.0", "@modelcontextprotocol/sdk": "^1.0.0",
"dotenv": "^17.2.1",
"node-appwrite": "^14.0.0" "node-appwrite": "^14.0.0"
}, },
"devDependencies": { "devDependencies": {
@@ -229,6 +230,18 @@
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/dotenv": {
"version": "17.2.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.1.tgz",
"integrity": "sha512-kQhDYKZecqnM0fCnzI5eIv5L4cAe/iRI+HqMbO/hbRdTAeXDG+M9FjipUxNfbARuEg4iHIbhnhs78BCHNbSxEQ==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/dunder-proto": { "node_modules/dunder-proto": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",

View File

@@ -9,15 +9,21 @@
"start": "node dist/index.js", "start": "node dist/index.js",
"dev": "tsc --watch" "dev": "tsc --watch"
}, },
"keywords": ["mcp", "appwrite", "claude", "model-context-protocol"], "keywords": [
"mcp",
"appwrite",
"claude",
"model-context-protocol"
],
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@modelcontextprotocol/sdk": "^1.0.0", "@modelcontextprotocol/sdk": "^1.0.0",
"dotenv": "^17.2.1",
"node-appwrite": "^14.0.0" "node-appwrite": "^14.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^22.0.0", "@types/node": "^22.0.0",
"typescript": "^5.6.0" "typescript": "^5.6.0"
} }
} }

View File

@@ -23,6 +23,7 @@ import {
} from "node-appwrite"; } from "node-appwrite";
import { readFileSync, existsSync } from "fs"; import { readFileSync, existsSync } from "fs";
import { join } from "path"; import { join } from "path";
import * as dotenv from "dotenv";
interface AppwriteConfig { interface AppwriteConfig {
projectId: string; projectId: string;
@@ -58,25 +59,25 @@ class AppwriteMCPServer {
} }
private loadConfig(): void { private loadConfig(): void {
const configPath = join(process.cwd(), "appwrite-config.json"); // Load environment variables from .env file in current working directory
dotenv.config({ path: join(process.cwd(), '.env') });
if (!existsSync(configPath)) { const projectId = process.env.APPWRITE_PROJECT_ID;
console.error("Appwrite configuration file not found. Please create appwrite-config.json"); const apiEndpoint = process.env.APPWRITE_API_ENDPOINT;
const apiKey = process.env.APPWRITE_API_KEY;
if (!projectId || !apiEndpoint || !apiKey) {
console.error("Appwrite configuration missing. Please create a .env file with APPWRITE_PROJECT_ID, APPWRITE_API_ENDPOINT, and APPWRITE_API_KEY");
return; return;
} }
try { this.config = {
const configData = readFileSync(configPath, "utf-8"); projectId,
this.config = JSON.parse(configData); apiEndpoint,
apiKey
if (!this.config?.projectId || !this.config?.apiEndpoint || !this.config?.apiKey) { };
throw new Error("Missing required configuration fields");
}
this.initializeAppwrite(); this.initializeAppwrite();
} catch (error) {
console.error("Error loading Appwrite configuration:", error);
}
} }
private initializeAppwrite(): void { private initializeAppwrite(): void {