Skip to main content
Glama
Falzz1010
by Falzz1010
README.md
# ๐Ÿš€ Laravel MCP Server

> **AI-Powered Laravel Development Assistant** โ€” Secure bridge between AI Clients (Claude Desktop, Cursor, VS Code) and your local Laravel projects.

<div align="center">

[![npm version](https://img.shields.io/npm/v/@falzz1010/laravel-mcp-server.svg?style=flat-square)](https://www.npmjs.com/package/@falzz1010/laravel-mcp-server)
[![npm downloads](https://img.shields.io/npm/dm/@falzz1010/laravel-mcp-server.svg?style=flat-square)](https://www.npmjs.com/package/@falzz1010/laravel-mcp-server)
[![GitHub](https://img.shields.io/github/stars/Falzz1010/laravel-mcp-server?style=flat-square)](https://github.com/Falzz1010/laravel-mcp-server)
[![OpenSSF Scorecard](https://img.shields.io/ossf-scorecard/github.com/Falzz1010/laravel-mcp-server?label=openssf%20scorecard&style=flat-square)](https://securityscorecards.dev/viewer/?uri=github.com/Falzz1010/laravel-mcp-server)
[![Security Rating](https://img.shields.io/badge/Security-A+-brightgreen?style=flat-square)](SECURITY.md)
[![TypeScript](https://img.shields.io/badge/TypeScript-5.5-blue?logo=typescript&style=flat-square)](https://www.typescriptlang.org/)
[![Node.js](https://img.shields.io/badge/Node.js-18+-green?logo=node.js&style=flat-square)](https://nodejs.org/)
[![Laravel](https://img.shields.io/badge/Laravel-8+-red?logo=laravel&style=flat-square)](https://laravel.com/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
[![Security: 10 Layers](https://img.shields.io/badge/Security-10%20Layers-green?style=flat-square)](SECURITY.md)

</div>

---

## โš ๏ธ Security Notice

This package **intentionally** requires system access for its core functionality (executing artisan commands, reading logs, etc.). All operations are protected by a [10-layer security system](SECURITY.md) including:
- Input sanitization & command validation
- Path traversal prevention
- Production environment blocking  
- Rate limiting & audit logging
- No shell injection (uses `execFile` only)

**For local development only. Never use in production.**

### ๐Ÿ“ข Expected npm/Socket Security Alerts

When installing this package, you may see alerts from npm or Socket.dev about:
- **Shell Access** โœ“ Required - safely executes `php artisan` commands
- **Filesystem Access** โœ“ Required - reads Laravel logs and source files  
- **Environment Variables** โœ“ Required - validates `APP_ENV` to block production
- **Network Access** โœ“ Required - MCP protocol communication
- **AI-detected risks** โœ“ Expected - automated scanners flag dev tools

**These are NOT vulnerabilities** - they are legitimate features of a Laravel development tool, all protected by our security layers. See [SECURITY.md](SECURITY.md) for complete details on how each capability is secured.

### ๐Ÿ” Security Monitoring

We maintain enterprise-grade security through:
- โœ… [CodeQL Analysis](https://github.com/Falzz1010/laravel-mcp-server/security/code-scanning) - Automated code security scanning
- โœ… [Dependabot](https://github.com/Falzz1010/laravel-mcp-server/security/dependabot) - Dependency vulnerability alerts
- โœ… [Security Tests](https://github.com/Falzz1010/laravel-mcp-server/actions/workflows/security.yml) - 19 security-focused tests
- ๐Ÿ“Š [OpenSSF Scorecard](https://securityscorecards.dev/viewer/?uri=github.com/Falzz1010/laravel-mcp-server) - Best practice monitoring (weekly)

See [SECURITY.md](SECURITY.md) for complete security details.

---

## ๐Ÿ“– Table of Contents

- [What is Laravel MCP Server?](#-what-is-laravel-mcp-server)
- [Features](#-features)
- [Security Architecture](#-security-architecture)
- [Installation](#-installation)
- [Quick Start](#-quick-start)
- [Configuration](#-configuration)
- [Usage Examples](#-usage-examples)
- [Tools Reference](#-tools-reference)
- [Security Details](#-security-details)
- [Troubleshooting](#-troubleshooting)
- [Contributing](#-contributing)
- [License](#-license)

---

## ๐ŸŽฏ What is Laravel MCP Server?

Laravel MCP Server adalah **MCP (Model Context Protocol) Server** berbasis TypeScript/Node.js yang memungkinkan AI Assistant seperti Claude untuk:

- โœ… Menjalankan perintah `php artisan` dengan aman
- โœ… Membaca dan menganalisis Laravel logs
- โœ… Melihat routes, config, dan structure proyek
- โœ… Membaca dan menulis source code (dengan proteksi ketat)
- โœ… Menjalankan kode PHP via Tinker (dalam sandbox mode)

**Mengapa dibuat?** AI modern sangat powerful untuk development, tapi memberikan akses terminal langsung ke AI sangat **berbahaya**. Server ini memberikan **controlled access** dengan **10 lapis security layer** yang dirancang khusus untuk mencegah kerusakan pada proyek Laravel kamu.

---

## โœจ Features

### ๐Ÿ”ง 7 Powerful Tools

| Tool | Fungsi | Access Level |
|------|--------|--------------|
| **`run_artisan`** | Jalankan perintah artisan yang aman | ๐ŸŸข Always Active |
| **`read_logs`** | Baca Laravel logs dengan filter | ๐ŸŸข Always Active |
| **`list_routes`** | Lihat semua routes dengan filter | ๐ŸŸข Always Active |
| **`read_file`** | Baca source code proyek | ๐ŸŸข Always Active |
| **`write_file`** | Tulis/edit file proyek | ๐Ÿ”ด Requires `--allow-write` |
| **`run_tinker`** | Jalankan PHP code via Tinker | ๐Ÿ”ด Requires `--allow-tinker` |

### ๐Ÿ“‚ 3 Laravel Resources

- **`laravel://env`** โ€” Static view of `.env` dengan credential masking
- **`laravel://routes`** โ€” JSON view lengkap semua routes
- **`laravel://config/{key}`** โ€” Dynamic config reader (contoh: `laravel://config/app.name`)

### ๐Ÿ’ฌ 3 Smart Prompts

- **`debug-error`** โ€” Otomatis baca logs dan minta AI menganalisis error
- **`create-crud`** โ€” Template untuk generate CRUD lengkap (Model, Migration, Controller, Routes)
- **`review-code`** โ€” Code review dengan fokus Laravel best practices

### ๐Ÿ›ก๏ธ 10-Layer Security System

1. **Environment Gate** โ€” Menolak start jika `APP_ENV=production`
2. **Rate Limiter** โ€” Max 30 perintah/menit, 500 perintah/jam
3. **Command Classifier** โ€” 3-tier risk classification (READ_ONLY, CAUTIOUS, DANGEROUS)
4. **Input Sanitizer** โ€” Blokir shell injection (`;`, `&&`, `$()`, backticks, dll)
5. **Flag Validator** โ€” Blokir `--force`, `--seed`, `--drop-*`, `--wipe`
6. **Path Protector** โ€” Blokir path traversal (`../`, symlinks keluar project)
7. **Write Guard** โ€” Whitelist directory + extension untuk `write_file`
8. **Tinker Sandbox** โ€” Blokir 15+ fungsi PHP berbahaya
9. **Execution Sandbox** โ€” Timeout ketat, no shell access (`execFile` only)
10. **Audit Trail** โ€” Log semua operasi ke `.laravel-mcp-audit.jsonl`

---

## ๐Ÿ—๏ธ Security Architecture

### 3-Tier Command Classification

Setiap perintah artisan dikategorikan berdasarkan tingkat risiko:

| Tier | Warna | Level | Contoh Perintah | Perlakuan |
|------|-------|-------|-----------------|-----------|
| ๐ŸŸข **READ_ONLY** | Hijau | Aman | `about`, `route:list`, `config:show` | Langsung dieksekusi |
| ๐ŸŸก **CAUTIOUS** | Kuning | Hati-hati | `make:*`, `migrate`, `cache:clear` | Audit log + Rate limited |
| ๐Ÿ”ด **DANGEROUS** | Merah | Berbahaya | `migrate:fresh`, `db:wipe`, `down` | **DIBLOKIR TOTAL** |

### Permanently Blocked Commands (20+)

Perintah berikut **TIDAK PERNAH** bisa dijalankan, bahkan dengan flag khusus:

```
migrate:fresh    โ†’ Hapus SEMUA tabel + migrate ulang
migrate:reset    โ†’ Rollback SEMUA migrations
migrate:refresh  โ†’ Reset + re-migrate database
db:wipe          โ†’ Hapus SEMUA tabel, views, types
down             โ†’ Matikan aplikasi (maintenance mode)
tinker           โ†’ Ada tool terpisah yang lebih aman
serve            โ†’ Blocking command yang bisa hang server
queue:restart    โ†’ Restart semua queue workers
vendor:publish   โ†’ Bisa overwrite file penting
package:discover โ†’ Security risk
```

**Lihat full list di:** [`src/utils/security.ts`](src/utils/security.ts) (`DANGEROUS_COMMANDS`)

### File Write Protection

Tool `write_file` hanya bisa menulis ke directory yang di-whitelist:

โœ… **Allowed Directories:**
```
app/                    โ†’ Models, Controllers, Services
routes/                 โ†’ Route definitions
database/migrations/    โ†’ Migration files
database/seeders/       โ†’ Seeder files
database/factories/     โ†’ Factory definitions
resources/views/        โ†’ Blade templates
config/                 โ†’ Config files
tests/                  โ†’ Test files
```

โŒ **Blocked Directories:**
```
.env, vendor/, node_modules/, storage/, public/, 
bootstrap/, artisan, composer.json, .git/
```

โœ… **Allowed Extensions:**
```
.php, .blade.php, .json, .yaml, .yml, .xml, .stub, .md, .txt
```

โŒ **Blocked Extensions:**
```
.sh, .bat, .exe, .phar, .js, .env*
```

### Auto Backup System

Setiap kali `write_file` mengubah file yang sudah ada, server otomatis membuat backup ke:

```
.laravel-mcp-backup/
โ”œโ”€โ”€ User.php.2026-08-01T143022.bak
โ”œโ”€โ”€ ProductController.php.2026-08-01T143045.bak
โ””โ”€โ”€ ...
```

---

## ๐Ÿ“ฆ Installation

### Prerequisites

- **Node.js** 18.0 atau lebih baru
- **PHP** 8.0 atau lebih baru
- **Laravel Project** (lokal di mesin kamu)

### Install via npm (Recommended)

```bash
# Install globally
npm install -g @falzz1010/laravel-mcp-server

# Verify installation
laravel-mcp --version
```

### Install from Source

```bash
# Clone repository
git clone https://github.com/Falzz1010/laravel-mcp-server.git
cd laravel-mcp-server

# Install dependencies
npm install

# Build TypeScript โ†’ JavaScript
npm run build
```

### Verify Installation

```bash
# Test security layer
npm test

# Expected output:
# โœ“ All security tests passed (19 tests)
```

---

## ๐Ÿš€ Quick Start

### 1. Basic Usage (Read-Only Mode)

Mode paling aman โ€” hanya bisa baca data, tidak bisa menulis:

```bash
node build/index.js /path/to/your/laravel-project
```

**Yang bisa dilakukan:**
- โœ… Jalankan perintah artisan READ_ONLY (`route:list`, `about`, dll)
- โœ… Baca logs (`read_logs`)
- โœ… Baca source code (`read_file`)
- โœ… Lihat `.env` dengan masking (resource `laravel://env`)
- โŒ Tidak bisa menulis file
- โŒ Tidak bisa jalankan Tinker

### 2. With Write Access

Izinkan AI menulis/edit file proyek (dengan whitelist ketat):

```bash
node build/index.js /path/to/your/laravel-project --allow-write
```

**Tambahan yang bisa dilakukan:**
- โœ… Generate controller, model, migration via `make:*`
- โœ… Edit file di `app/`, `routes/`, `database/`, `config/`, `tests/`
- โœ… Auto backup sebelum overwrite

### 3. With Tinker Access

Izinkan AI menjalankan kode PHP (dalam sandbox mode):

```bash
node build/index.js /path/to/your/laravel-project --allow-tinker
```

**Tambahan yang bisa dilakukan:**
- โœ… Query database via Eloquent: `User::count()`
- โœ… Test helpers: `cache()->get('key')`
- โœ… Manipulasi data: `User::find(1)->update(['name' => 'Test'])`
- โŒ **Diblokir:** `exec()`, `system()`, `unlink()`, `file_put_contents()`, dll

### 4. Full Access Mode (USE WITH CAUTION!)

```bash
node build/index.js /path/to/your/laravel-project --allow-write --allow-tinker
```

### 5. Dry-Run Mode (Preview Only)

Lihat preview command tanpa benar-benar menjalankannya:

```bash
node build/index.js /path/to/your/laravel-project --dry-run
```

---

## โš™๏ธ Configuration

### Claude Desktop Configuration

Edit `claude_desktop_config.json` (biasanya di `%APPDATA%\Claude\` atau `~/.config/claude/`):

#### Using Global npm Package (Recommended)

```json
{
  "mcpServers": {
    "laravel-dev": {
      "command": "npx",
      "args": [
        "@falzz1010/laravel-mcp-server",
        "E:/xampp/htdocs/my-laravel-app"
      ]
    }
  }
}
```

#### Using Local Installation

```json
{
  "mcpServers": {
    "laravel-dev": {
      "command": "node",
      "args": [
        "E:/desain-ui/laravel-mcp-server/build/index.js",
        "E:/xampp/htdocs/my-laravel-app",
        "--allow-write"
      ],
      "env": {
        "NODE_ENV": "production"
      }
    }
  }
}
```

### VS Code / Cursor Configuration

#### Using npm Package

Edit `.vscode/settings.json` atau Cursor settings:

```json
{
  "mcp.servers": {
    "laravel": {
      "command": "npx",
      "args": [
        "@falzz1010/laravel-mcp-server",
        "${workspaceFolder}",
        "--allow-write"
      ]
    }
  }
}
```

#### Using Local Installation

```json
{
  "mcp.servers": {
    "laravel": {
      "command": "node",
      "args": [
        "E:/desain-ui/laravel-mcp-server/build/index.js",
        "${workspaceFolder}",
        "--allow-write"
      ]
    }
  }
}
```

### CLI Arguments Reference

| Argument | Default | Deskripsi |
|----------|---------|-----------|
| `[path]` | *required* | Path ke root proyek Laravel |
| `--allow-write` | `false` | Aktifkan tool `write_file` |
| `--allow-tinker` | `false` | Aktifkan tool `run_tinker` |
| `--dry-run` | `false` | Preview mode (tidak eksekusi command) |
| `--php [path]` | `php` | Custom PHP binary path |
| `--timeout [ms]` | `30000` | Timeout untuk artisan commands (ms) |
| `--rate-limit [n]` | `30` | Max requests per menit |

**Contoh lengkap:**

```bash
node build/index.js \
  /var/www/laravel-app \
  --allow-write \
  --php /usr/bin/php8.2 \
  --timeout 60000 \
  --rate-limit 50
```

---

## ๐Ÿ’ก Usage Examples

### Example 1: Debugging Error Logs

**User berkata ke Claude:**
> "Ada error di aplikasi, coba lihat log dan jelasin masalahnya"

**AI menggunakan tool `read_logs`:**
```json
{
  "tool": "read_logs",
  "arguments": {
    "lines": 50,
    "filter": "ERROR"
  }
}
```

**Output:**
```
[2026-08-01 14:30:22] local.ERROR: Call to undefined method App\Models\User::getFullNameAttribute() 
{"exception":"Error","file":"app/Http/Controllers/UserController.php","line":42}
```

**AI menganalisis:**
> "Error terjadi karena method accessor `getFullNameAttribute()` tidak ditemukan. Seharusnya accessor didefinisikan dengan prefix `get` dan suffix `Attribute`. Coba tambahkan method ini di Model User..."

### Example 2: Generate CRUD Resource

**User:**
> "Bikin CRUD untuk Product dong, fieldnya: name, description, price, stock"

**AI menggunakan prompt `create-crud`:**
```json
{
  "prompt": "create-crud",
  "arguments": {
    "model_name": "Product",
    "fields": "name:string,description:text,price:decimal,stock:integer"
  }
}
```

**AI kemudian menjalankan:**
1. `run_artisan make:model Product -m` โ†’ Buat Model + Migration
2. `write_file database/migrations/..._create_products_table.php` โ†’ Edit migration
3. `run_artisan make:controller ProductController --resource` โ†’ Buat Controller
4. `write_file routes/web.php` โ†’ Tambahkan route resource

### Example 3: Code Review

**User:**
> "Review code di `app/Http/Controllers/OrderController.php`"

**AI menggunakan prompt `review-code`:**
```json
{
  "prompt": "review-code",
  "arguments": {
    "file_path": "app/Http/Controllers/OrderController.php"
  }
}
```

**AI membaca file lalu memberikan feedback:**
> โœ… **Positif:**
> - Controller menggunakan Form Request untuk validasi
> - Query menggunakan Eloquent relationships dengan benar
> 
> โš ๏ธ **Perlu Diperbaiki:**
> - Method `store()` tidak menggunakan DB transaction, risiko partial save
> - Query di `index()` bisa N+1 problem, tambahkan `with(['user', 'items'])`
> - Tidak ada authorization check, sebaiknya gunakan Policy

---

## ๐Ÿ”ง Tools Reference

### 1. `run_artisan`

Jalankan perintah `php artisan` yang aman.

**Parameters:**
```typescript
{
  command: string;          // e.g. "make:controller"
  args?: string[];          // e.g. ["UserController", "--resource"]
}
```

**Example:**
```json
{
  "tool": "run_artisan",
  "arguments": {
    "command": "make:model",
    "args": ["Product", "-m", "-c", "-r"]
  }
}
```

**Response:**
```json
{
  "success": true,
  "output": "Model created successfully.\nCreated Migration: 2026_08_01_143022_create_products_table",
  "exitCode": 0
}
```

### 2. `read_logs`

Baca baris terakhir dari Laravel logs.

**Parameters:**
```typescript
{
  lines?: number;           // Default: 100, Max: 500
  filter?: string;          // Keyword untuk filter (case-insensitive)
}
```

**Example:**
```json
{
  "tool": "read_logs",
  "arguments": {
    "lines": 50,
    "filter": "ERROR"
  }
}
```

### 3. `list_routes`

Lihat semua routes dengan optional filter.

**Parameters:**
```typescript
{
  method?: string;          // Filter by HTTP method: GET, POST, PUT, DELETE
  path?: string;            // Filter by path pattern (regex)
}
```

**Example:**
```json
{
  "tool": "list_routes",
  "arguments": {
    "method": "POST",
    "path": "/api/"
  }
}
```

### 4. `read_file`

Baca source code dari proyek Laravel.

**Parameters:**
```typescript
{
  path: string;             // Relative path dari root project
}
```

**Example:**
```json
{
  "tool": "read_file",
  "arguments": {
    "path": "app/Models/User.php"
  }
}
```

**Security:**
- โœ… Path traversal protection
- โœ… Max file size: 1MB
- โŒ Cannot read `.env` (use resource `laravel://env`, masked)

### 5. `write_file` (Requires `--allow-write`)

Tulis/edit file di proyek Laravel.

**Parameters:**
```typescript
{
  path: string;             // Relative path
  content: string;          // File content
}
```

**Example:**
```json
{
  "tool": "write_file",
  "arguments": {
    "path": "app/Models/Product.php",
    "content": "<?php\n\nnamespace App\\Models;\n..."
  }
}
```

**Security:**
- โœ… Directory whitelist (only `app/`, `routes/`, `database/`, `config/`, `tests/`)
- โœ… Extension whitelist (`.php`, `.blade.php`, `.json`, `.yaml`, dll)
- โœ… Auto backup ke `.laravel-mcp-backup/`
- โœ… Max file size: 500KB
- โŒ Cannot write to `.env`, `vendor/`, `node_modules/`, dll

### 6. `run_tinker` (Requires `--allow-tinker`)

Jalankan kode PHP via Tinker.

**Parameters:**
```typescript
{
  code: string;             // PHP code (tanpa <?php tag)
}
```

**Example:**
```json
{
  "tool": "run_tinker",
  "arguments": {
    "code": "User::count()"
  }
}
```

**Security:**
- โœ… Timeout ultra-ketat: 10 detik
- โœ… Max code length: 2000 karakter
- โŒ **Blocked functions:** `exec()`, `system()`, `shell_exec()`, `passthru()`, `popen()`, `proc_open()`, `unlink()`, `rmdir()`, `file_put_contents()`, `fwrite()`, `curl_exec()`, `eval()`, dll (15+ functions)
- โŒ **Blocked keywords:** `::truncate()`, `::delete()`, `->forceDelete()`, `DB::statement()`, `DB::unprepared()`, `Schema::drop()`, dll

---

## ๐Ÿ”’ Security Details

### Audit Logging

Semua operasi dicatat dalam **JSON Lines** format di:

```
{laravelPath}/.laravel-mcp-audit.jsonl
```

**Example log entry:**
```json
{"timestamp":"2026-08-01T14:30:22.000Z","sessionId":"abc123","tool":"run_artisan","tier":"CAUTIOUS","command":"make:controller","args":["ProductController","--resource"],"exitCode":0,"outputSize":45,"status":"ALLOWED","duration":1523}
```

**Fields:**
- `timestamp` โ€” ISO 8601 timestamp
- `sessionId` โ€” Unique per server session
- `tool` โ€” Tool yang dipanggil
- `tier` โ€” Risk tier (READ_ONLY, CAUTIOUS, DANGEROUS)
- `command` โ€” Artisan command (if applicable)
- `args` โ€” Command arguments
- `filePath` โ€” File yang dibaca/ditulis (if applicable)
- `exitCode` โ€” Command exit code
- `outputSize` โ€” Output size in bytes
- `fileHash` โ€” SHA-256 hash dari file yang ditulis
- `status` โ€” ALLOWED / BLOCKED / ERROR
- `reason` โ€” Alasan jika blocked
- `duration` โ€” Execution duration in ms

### Rate Limiting

**Default limits:**
- 30 requests per menit
- 500 requests per jam
- 2 detik cooldown minimum antar perintah CAUTIOUS

**READ_ONLY commands tidak dihitung dalam limit.**

**Jika limit tercapai:**
```json
{
  "error": "RATE_LIMIT_EXCEEDED",
  "message": "Too many requests. Try again in 15 seconds.",
  "retryAfterMs": 15000
}
```

### Environment Protection

Server **menolak untuk start** jika:

```bash
# .env file contains:
APP_ENV=production
```

**Error message:**
```
[FATAL ERROR] Refusing to run in PRODUCTION environment. 
This server is designed for LOCAL development only.
```

**Warning untuk staging:**
```bash
# .env file contains:
APP_ENV=staging
```

**Warning message:**
```
[WARNING] Running in STAGING environment. Proceed with caution.
```

---

## ๐Ÿ” Development & Debugging

### MCP Inspector

Gunakan MCP Inspector untuk debug tools secara interaktif:

```bash
# Install inspector (jika belum)
npm install -g @modelcontextprotocol/inspector

# Run inspector
npm run inspect /path/to/laravel-project
```

**Inspector akan:**
1. Start MCP server
2. Buka web interface di browser
3. Tampilkan semua tools, resources, prompts
4. Izinkan testing tool secara interaktif

### Development Mode

Watch mode untuk auto-rebuild saat edit code:

```bash
npm run dev /path/to/laravel-project
```

### Enable Debug Logging

Set environment variable untuk verbose logging:

```bash
# Unix/Mac
DEBUG=mcp:* node build/index.js /path/to/laravel-project

# Windows CMD
set DEBUG=mcp:* && node build/index.js /path/to/laravel-project

# Windows PowerShell
$env:DEBUG="mcp:*"; node build/index.js /path/to/laravel-project
```

---

## ๐Ÿ› Troubleshooting

### Error: "Invalid Laravel path"

**Problem:** Server tidak menemukan file `artisan` di path yang diberikan.

**Solution:**
```bash
# Pastikan path mengarah ke ROOT project Laravel
ls /path/to/laravel-project/artisan

# Bukan ke subfolder
# โŒ SALAH: /path/to/laravel-project/app
# โœ… BENAR: /path/to/laravel-project
```

### Error: "Refusing to run in PRODUCTION environment"

**Problem:** File `.env` memiliki `APP_ENV=production`.

**Solution:**
```bash
# Edit .env
APP_ENV=local    # atau 'development'

# Server ini HANYA untuk development, TIDAK untuk production!
```

### Error: "PHP binary not found"

**Problem:** Command `php` tidak ditemukan di PATH.

**Solution:**
```bash
# Option 1: Tambahkan PHP ke PATH (recommended)
export PATH="/usr/local/bin:$PATH"

# Option 2: Specify PHP path explicitly
node build/index.js /path/to/laravel --php /usr/bin/php8.2
```

### Error: "Command not allowed"

**Problem:** AI mencoba menjalankan command yang di-blocklist.

**Solution:**
Ini adalah **fitur keamanan**. Command berbahaya seperti `migrate:fresh`, `db:wipe`, dll memang diblokir secara permanen.

**Workaround:**
```bash
# Jalankan manual di terminal kamu (jika benar-benar diperlukan)
cd /path/to/laravel-project
php artisan migrate:fresh --seed
```

### Tools tidak muncul di Claude Desktop

**Problem:** Setelah konfigurasi, tools tidak muncul.

**Solution:**
1. Restart Claude Desktop
2. Cek file config path:
   - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
   - Mac: `~/Library/Application Support/Claude/claude_desktop_config.json`
3. Cek build folder exist: `ls build/index.js`
4. Test manual:
   ```bash
   node build/index.js /path/to/laravel-project
   # Should output: [INFO] Laravel MCP Server running on stdio transport.
   ```

---

## ๐Ÿงช Running Tests

### Full Test Suite

```bash
npm test
```

**Expected output:**
```
โœ“ classifyCommand() - READ_ONLY commands (7 tests)
โœ“ classifyCommand() - CAUTIOUS commands (12 tests)
โœ“ classifyCommand() - DANGEROUS commands (20 tests)
โœ“ sanitizeArgs() - Shell injection protection (8 tests)
โœ“ isPathSafe() - Path traversal protection (6 tests)
โœ“ isWriteAllowed() - Write protection (5 tests)
โœ“ sanitizeTinkerCode() - Tinker sandbox (8 tests)
โœ“ Rate Limiter (4 tests)
โœ“ Environment check (3 tests)

Total: 40 tests passed
```

### Run Specific Test File

```bash
# Unix/Mac
node --test build/tests/security.test.js

# Windows
node --test build\tests\security.test.js
```

---

## ๐Ÿค Contributing

Kontribusi sangat welcome! Terutama untuk:

1. **Security improvements** โ€” Additional validation, better sandboxing
2. **Tool additions** โ€” New Laravel-specific tools
3. **Bug fixes** โ€” Especially edge cases di Windows/Mac/Linux
4. **Documentation** โ€” Tutorial, use cases, best practices

**Contribution guidelines:**
1. Fork repository
2. Create feature branch: `git checkout -b feature/amazing-feature`
3. Commit changes: `git commit -m 'Add amazing feature'`
4. Push to branch: `git push origin feature/amazing-feature`
5. Open Pull Request

**Testing requirements:**
- โœ… Semua test harus pass: `npm test`
- โœ… TypeScript harus compile tanpa error: `npm run build`
- โœ… Tambahkan test untuk fitur baru

---

## ๐Ÿ“„ License

MIT License โ€” feel free to use in your projects!

---

## ๐Ÿ™ Acknowledgments

- [Model Context Protocol](https://modelcontextprotocol.io/) โ€” MCP SDK
- [Anthropic](https://www.anthropic.com/) โ€” Claude Desktop
- [Laravel](https://laravel.com/) โ€” The PHP Framework

---

## ๐Ÿ“ž Support

- ๐Ÿ“– **Documentation:** [QUICK_START.md](QUICK_START.md) ยท [SECURITY.md](SECURITY.md)
- ๐Ÿ› **Bug Reports:** [GitHub Issues](https://github.com/Falzz1010/laravel-mcp-server/issues)
- ๐Ÿ’ฌ **Discussions:** [GitHub Discussions](https://github.com/Falzz1010/laravel-mcp-server/discussions)

---

<div align="center">

**Made with โค๏ธ for Laravel Developers**

โญ Star this repo if you find it useful!

</div>