Stratos 透過 MCP 讓 Cursor 和 Claude Code 即時存取本機 Laravel 資料庫結構與日誌
Giving Cursor & Claude Code Live Access to Local Laravel DB Schemas & Logs via MCP
Stratos v1.7.2 的本機 MCP 橋接讓 Cursor、Claude Code 等編輯器即時讀取 Laravel 專案的資料庫結構、執行環境資料及日誌。橋接僅綁定 127.0.0.1,並以 bearer token 和 Host/Origin 驗證限制存取;免費版提供唯讀結構及站點資料,Pro 版的 PHP、SQL 和 Artisan 指令須經 macOS 人手批准,年費 $39。
If you use Cursor, Claude Code, Claude Desktop, or Windsurf on a Laravel project, you know the most annoying loop in AI-assisted coding:
- You ask the agent to write an Eloquent migration or fix a 500 error.
- It hallucinates a column name or asks you to paste
storage/logs/laravel.log, your table schema, or the last failed webhook payload. - You manually run
php artisan ..., copy-paste 80 lines of terminal output into the chat, and repeat 20 times a day.
The Model Context Protocol (MCP) solves this cleanly — instead of copy-pasting state, your local dev environment exposes structured, read-only (or human-approved) context directly to your AI editor over localhost loopback.
Here's how we architected the local MCP bridge in Stratos v1.7.2 for macOS Laravel & PHP developers — and the security boundaries that make it safe to use on real client projects.
1. What Your AI Editor Actually Needs (Without Exposing Secrets)
When debugging a local Laravel app, 90% of AI mistakes happen because the model is missing 4 live facts:
- Exact Database Schema: Real table names, column types, indexes, and foreign keys from your local SQLite, MySQL, or PostgreSQL database.
-
Active Runtime Context: Which PHP version (
8.1–8.5) and.testURL the project is actually running on. -
Recent Exceptions & HTTP Traces: The tail of
laravel.log, recent HTTP status codes / slow requests, anddump()payloads. -
Safe Verification Execution: Running
php artisan test,php artisan migrate:status, or a read-only SQL query to verify a fix.
Notice what the AI editor does not need: raw .env production secrets, unrestricted shell access, or an open LAN port.
2. Architecture & Security Boundaries
In Stratos, the MCP bridge is designed around strict local-first safety:
-
Off by Default & Loopback-Only: Binds strictly to
127.0.0.1with per-session bearer tokens andHost/Originvalidation so external websites or LAN devices can never reach it. - 1-Click Editor Config (Non-Destructive): Installs into Cursor, Claude Code, Claude Desktop (via a bundled stdio relay), and Windsurf while backing up and preserving all your existing MCP servers.
- Read-Only Context Free Forever: Site metadata, active PHP versions, Nginx paths, and SQLite/MySQL/PostgreSQL table schemas with foreign keys are available on the Free tier with zero setup.
- Human-in-the-Loop Execution (Pro): Any PHP, SQL, or Artisan command requested by an agent pauses behind a native macOS approval dialog inside Stratos so you inspect the exact command before it executes.
3. Real Workflow Example (Debugging an N+1 Query in 15 Seconds)
With the MCP bridge running in Stratos:
- Hit your slow local endpoint (
https://myapp.test/dashboard). - In Cursor or Claude Code, ask:
> "Check the latest slow request and repeated SQL queries for
myapp, inspect theordersandusersschema, and suggest the exact Eloquent eager-loading fix." - The agent reads the real schema + slow query trace directly from Stratos's local MCP server and writes the exact
->with(['user:id,name'])fix on the first try — zero copy-pasting.
Try It on macOS (Free Core + BFCM20 Deal)
- Download Stratos v1.7.2 (Apple Silicon & Intel, Notarized): https://stratosapp.dev/download/
- Full MCP Setup Guide: https://stratosapp.dev/docs/local-ai-mcp/
- Manual Editor Config Examples (GitHub): https://github.com/khorshedobs/stratos-mcp-guide
Stratos Core (including read-only MCP schema + site context) is free forever. Pro unlocks runtime log tails, DumpServer/Request Inspector MCP telemetry, and approved PHP/SQL/Artisan execution ($39/yr or $89 Founder Lifetime — currently 20% off with BFCM20 through Nov 30, 2026).
What MCP tools do you wish your local Laravel stack exposed to Cursor or Claude Code? Drop ideas in the comments!
來源:DEV Community · dev.to