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

1
.gitignore vendored
View File

@@ -9,7 +9,6 @@ dist/
build/
# Environment and config files
appwrite-config.json
.env
.env.local
.env.development.local

View File

@@ -37,23 +37,21 @@ npm install
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
# Copy the template to your current working directory
cp /path/to/app-write-mcp/appwrite-config.json.template ./appwrite-config.json
# Copy the example file to your current working directory
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:
```json
{
"projectId": "your-project-id",
"apiEndpoint": "https://cloud.appwrite.io/v1",
"apiKey": "your-api-key"
}
5. Edit the `.env` file in your current directory with your Appwrite project details:
```bash
APPWRITE_PROJECT_ID=your-project-id
APPWRITE_API_ENDPOINT=https://cloud.appwrite.io/v1
APPWRITE_API_KEY=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

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",
"dependencies": {
"@modelcontextprotocol/sdk": "^1.0.0",
"dotenv": "^17.2.1",
"node-appwrite": "^14.0.0"
},
"devDependencies": {
@@ -229,6 +230,18 @@
"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": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",

View File

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

View File

@@ -23,6 +23,7 @@ import {
} from "node-appwrite";
import { readFileSync, existsSync } from "fs";
import { join } from "path";
import * as dotenv from "dotenv";
interface AppwriteConfig {
projectId: string;
@@ -58,25 +59,25 @@ class AppwriteMCPServer {
}
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)) {
console.error("Appwrite configuration file not found. Please create appwrite-config.json");
const projectId = process.env.APPWRITE_PROJECT_ID;
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;
}
try {
const configData = readFileSync(configPath, "utf-8");
this.config = JSON.parse(configData);
this.config = {
projectId,
apiEndpoint,
apiKey
};
if (!this.config?.projectId || !this.config?.apiEndpoint || !this.config?.apiKey) {
throw new Error("Missing required configuration fields");
}
this.initializeAppwrite();
} catch (error) {
console.error("Error loading Appwrite configuration:", error);
}
this.initializeAppwrite();
}
private initializeAppwrite(): void {