Laravel MCP Server
Provides secure tools for managing Laravel projects, including running artisan commands, reading logs and routes, viewing environment configuration, reading and writing source files, and executing PHP code via Tinker in a sandboxed environment.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Laravel MCP Serverlist all routes"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
š Laravel MCP Server
AI-Powered Laravel Development Assistant ā Secure bridge between AI Clients (Claude Desktop, Cursor, VS Code) and your local Laravel projects.
ā ļø 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 including:
Input sanitization & command validation
Path traversal prevention
Production environment blocking
Rate limiting & audit logging
No shell injection (uses
execFileonly)
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 artisancommandsFilesystem Access ā Required - reads Laravel logs and source files
Environment Variables ā Required - validates
APP_ENVto block productionNetwork 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 for complete details on how each capability is secured.
š Security Monitoring
We maintain enterprise-grade security through:
ā CodeQL Analysis - Automated code security scanning
ā Dependabot - Dependency vulnerability alerts
ā Security Tests - 19 security-focused tests
š OpenSSF Scorecard - Best practice monitoring (weekly)
See SECURITY.md for complete security details.
Related MCP server: laravel-artisan-mcp
š Table of Contents
šÆ 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 artisandengan 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 |
| Jalankan perintah artisan yang aman | š¢ Always Active |
| Baca Laravel logs dengan filter | š¢ Always Active |
| Lihat semua routes dengan filter | š¢ Always Active |
| Baca source code proyek | š¢ Always Active |
| Tulis/edit file proyek | š“ Requires |
| Jalankan PHP code via Tinker | š“ Requires |
š 3 Laravel Resources
laravel://envā Static view of.envdengan credential maskinglaravel://routesā JSON view lengkap semua routeslaravel://config/{key}ā Dynamic config reader (contoh:laravel://config/app.name)
š¬ 3 Smart Prompts
debug-errorā Otomatis baca logs dan minta AI menganalisis errorcreate-crudā Template untuk generate CRUD lengkap (Model, Migration, Controller, Routes)review-codeā Code review dengan fokus Laravel best practices
š”ļø 10-Layer Security System
Environment Gate ā Menolak start jika
APP_ENV=productionRate Limiter ā Max 30 perintah/menit, 500 perintah/jam
Command Classifier ā 3-tier risk classification (READ_ONLY, CAUTIOUS, DANGEROUS)
Input Sanitizer ā Blokir shell injection (
;,&&,$(), backticks, dll)Flag Validator ā Blokir
--force,--seed,--drop-*,--wipePath Protector ā Blokir path traversal (
../, symlinks keluar project)Write Guard ā Whitelist directory + extension untuk
write_fileTinker Sandbox ā Blokir 15+ fungsi PHP berbahaya
Execution Sandbox ā Timeout ketat, no shell access (
execFileonly)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 |
| Langsung dieksekusi |
š” CAUTIOUS | Kuning | Hati-hati |
| Audit log + Rate limited |
š“ DANGEROUS | Merah | Berbahaya |
| 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 riskLihat full list di: 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)
# Install globally
npm install -g @falzz1010/laravel-mcp-server
# Verify installation
laravel-mcp --versionInstall from Source
# 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 buildVerify Installation
# 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:
node build/index.js /path/to/your/laravel-projectYang bisa dilakukan:
ā Jalankan perintah artisan READ_ONLY (
route:list,about, dll)ā Baca logs (
read_logs)ā Baca source code (
read_file)ā Lihat
.envdengan masking (resourcelaravel://env)ā Tidak bisa menulis file
ā Tidak bisa jalankan Tinker
2. With Write Access
Izinkan AI menulis/edit file proyek (dengan whitelist ketat):
node build/index.js /path/to/your/laravel-project --allow-writeTambahan 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):
node build/index.js /path/to/your/laravel-project --allow-tinkerTambahan 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!)
node build/index.js /path/to/your/laravel-project --allow-write --allow-tinker5. Dry-Run Mode (Preview Only)
Lihat preview command tanpa benar-benar menjalankannya:
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)
{
"mcpServers": {
"laravel-dev": {
"command": "npx",
"args": [
"@falzz1010/laravel-mcp-server",
"E:/xampp/htdocs/my-laravel-app"
]
}
}
}Using Local Installation
{
"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:
{
"mcp.servers": {
"laravel": {
"command": "npx",
"args": [
"@falzz1010/laravel-mcp-server",
"${workspaceFolder}",
"--allow-write"
]
}
}
}Using Local Installation
{
"mcp.servers": {
"laravel": {
"command": "node",
"args": [
"E:/desain-ui/laravel-mcp-server/build/index.js",
"${workspaceFolder}",
"--allow-write"
]
}
}
}CLI Arguments Reference
Argument | Default | Deskripsi |
| required | Path ke root proyek Laravel |
|
| Aktifkan tool |
|
| Aktifkan tool |
|
| Preview mode (tidak eksekusi command) |
|
| Custom PHP binary path |
|
| Timeout untuk artisan commands (ms) |
|
| Max requests per menit |
Contoh lengkap:
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:
{
"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 prefixgetdan suffixAttribute. 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:
{
"prompt": "create-crud",
"arguments": {
"model_name": "Product",
"fields": "name:string,description:text,price:decimal,stock:integer"
}
}AI kemudian menjalankan:
run_artisan make:model Product -mā Buat Model + Migrationwrite_file database/migrations/..._create_products_table.phpā Edit migrationrun_artisan make:controller ProductController --resourceā Buat Controllerwrite_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:
{
"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 saveQuery di
index()bisa N+1 problem, tambahkanwith(['user', 'items'])Tidak ada authorization check, sebaiknya gunakan Policy
š§ Tools Reference
1. run_artisan
Jalankan perintah php artisan yang aman.
Parameters:
{
command: string; // e.g. "make:controller"
args?: string[]; // e.g. ["UserController", "--resource"]
}Example:
{
"tool": "run_artisan",
"arguments": {
"command": "make:model",
"args": ["Product", "-m", "-c", "-r"]
}
}Response:
{
"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:
{
lines?: number; // Default: 100, Max: 500
filter?: string; // Keyword untuk filter (case-insensitive)
}Example:
{
"tool": "read_logs",
"arguments": {
"lines": 50,
"filter": "ERROR"
}
}3. list_routes
Lihat semua routes dengan optional filter.
Parameters:
{
method?: string; // Filter by HTTP method: GET, POST, PUT, DELETE
path?: string; // Filter by path pattern (regex)
}Example:
{
"tool": "list_routes",
"arguments": {
"method": "POST",
"path": "/api/"
}
}4. read_file
Baca source code dari proyek Laravel.
Parameters:
{
path: string; // Relative path dari root project
}Example:
{
"tool": "read_file",
"arguments": {
"path": "app/Models/User.php"
}
}Security:
ā Path traversal protection
ā Max file size: 1MB
ā Cannot read
.env(use resourcelaravel://env, masked)
5. write_file (Requires --allow-write)
Tulis/edit file di proyek Laravel.
Parameters:
{
path: string; // Relative path
content: string; // File content
}Example:
{
"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:
{
code: string; // PHP code (tanpa <?php tag)
}Example:
{
"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.jsonlExample log entry:
{"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 timestampsessionIdā Unique per server sessiontoolā Tool yang dipanggiltierā Risk tier (READ_ONLY, CAUTIOUS, DANGEROUS)commandā Artisan command (if applicable)argsā Command argumentsfilePathā File yang dibaca/ditulis (if applicable)exitCodeā Command exit codeoutputSizeā Output size in bytesfileHashā SHA-256 hash dari file yang ditulisstatusā ALLOWED / BLOCKED / ERRORreasonā Alasan jika blockeddurationā 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:
{
"error": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests. Try again in 15 seconds.",
"retryAfterMs": 15000
}Environment Protection
Server menolak untuk start jika:
# .env file contains:
APP_ENV=productionError message:
[FATAL ERROR] Refusing to run in PRODUCTION environment.
This server is designed for LOCAL development only.Warning untuk staging:
# .env file contains:
APP_ENV=stagingWarning message:
[WARNING] Running in STAGING environment. Proceed with caution.š Development & Debugging
MCP Inspector
Gunakan MCP Inspector untuk debug tools secara interaktif:
# Install inspector (jika belum)
npm install -g @modelcontextprotocol/inspector
# Run inspector
npm run inspect /path/to/laravel-projectInspector akan:
Start MCP server
Buka web interface di browser
Tampilkan semua tools, resources, prompts
Izinkan testing tool secara interaktif
Development Mode
Watch mode untuk auto-rebuild saat edit code:
npm run dev /path/to/laravel-projectEnable Debug Logging
Set environment variable untuk verbose logging:
# 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:
# 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-projectError: "Refusing to run in PRODUCTION environment"
Problem: File .env memiliki APP_ENV=production.
Solution:
# 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:
# 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.2Error: "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:
# Jalankan manual di terminal kamu (jika benar-benar diperlukan)
cd /path/to/laravel-project
php artisan migrate:fresh --seedTools tidak muncul di Claude Desktop
Problem: Setelah konfigurasi, tools tidak muncul.
Solution:
Restart Claude Desktop
Cek file config path:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonMac:
~/Library/Application Support/Claude/claude_desktop_config.json
Cek build folder exist:
ls build/index.jsTest manual:
node build/index.js /path/to/laravel-project # Should output: [INFO] Laravel MCP Server running on stdio transport.
š§Ŗ Running Tests
Full Test Suite
npm testExpected 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 passedRun Specific Test File
# Unix/Mac
node --test build/tests/security.test.js
# Windows
node --test build\tests\security.test.jsš¤ Contributing
Kontribusi sangat welcome! Terutama untuk:
Security improvements ā Additional validation, better sandboxing
Tool additions ā New Laravel-specific tools
Bug fixes ā Especially edge cases di Windows/Mac/Linux
Documentation ā Tutorial, use cases, best practices
Contribution guidelines:
Fork repository
Create feature branch:
git checkout -b feature/amazing-featureCommit changes:
git commit -m 'Add amazing feature'Push to branch:
git push origin feature/amazing-featureOpen 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 ā MCP SDK
Anthropic ā Claude Desktop
Laravel ā The PHP Framework
š Support
š Documentation: QUICK_START.md Ā· SECURITY.md
š Bug Reports: GitHub Issues
š¬ Discussions: GitHub Discussions
Made with ā¤ļø for Laravel Developers
ā Star this repo if you find it useful!
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityCmaintenanceProvides secure, sandboxed file system access for AI assistants to read, write, and manage project files with controlled command execution capabilities, all confined to a designated workspace directory.Last updatedMIT
- Alicense-qualityCmaintenanceEnables secure execution of Laravel Artisan commands through AI assistants, allowing controlled management of Laravel projects via natural language.Last updated6MIT
- Alicense-qualityCmaintenanceLocal daemon that bridges AI assistants to the local filesystem with read-only commands and optional write mode, enforcing strict security filters to prevent credential leakage.Last updated41MIT
- Alicense-qualityBmaintenanceEnables AI assistants to introspect a Laravel application's routes, models, controllers, migrations, and more through the Model Context Protocol, running locally via php artisan commands and filesystem scanning.Last updated18MIT
Related MCP Connectors
Operate your Linux servers from your LLM. Every action runs through an auditable allowlist.
Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.
Security firewall for AI agents ā scans MCP calls for injection, secrets, and risks.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Falzz1010/laravel-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server