Laravel MCP Server
This server provides an MCP-powered autonomous development toolkit for Laravel projects, enabling AI agents to understand, generate, and debug Laravel applications. Key capabilities include:
Project Understanding: Analyze Laravel project structure, including models, routes, migrations, packages, frontend, environment, and configuration.
Code Generation: Generate complete features, CRUD operations, and REST APIs, including migrations, models, controllers, requests, routes, Blade views, and tests.
Database Interaction: Inspect database schema, list tables, view column definitions, and parse migration files to extract schema details.
Debugging & Error Analysis: Locate files, diagnose common Laravel errors, suggest fixes from error messages or stack traces, and tail log files.
Artisan Command Execution: Safely run a whitelisted set of php artisan commands.
Testing: Run PHPUnit tests with optional filters.
Dependency Management: List project dependencies from composer.json.
Caching: Manage Laravel application caches (clear or cache config, routes, views).
Intent Planning: Parse natural language development requests into executable plans.
Workflow Management: List, inspect, resume, or rollback generated workflow runs.
Provides tools for running Artisan commands, checking migration status, inspecting environment and config, clearing cache, viewing database schema, scanning Eloquent models, and tailing logs in a Laravel project.
Click on "Deploy 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 Server Check migration status"
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.
Cortex Agent Runtime — MCP-native AI Agent Framework
Before: AI doesn't understand your project. After: AI can analyze, generate and debug applications.
A Model Context Protocol (MCP) server that turns any coding agent (Claude, Cursor, Codex, OpenCode, and more) into an autonomous engineering brain for the projects you work on. The runtime is project-type agnostic: it loads a set of domains based on what your project is, so the same runtime works across Laravel apps, Node projects, and anything else.
Runtime
Project-type detection —
core/detector.tsinspects the project and activates the matching domains. Generic tools are always loaded; the Laravel domain activates whencomposer.json+artisanare present.Domain registration —
core/registry.tsexposesregisterDomain(manifest);listTools()/callTool()stay stable so the MCP surface doesn't change between projects.Safe by default — local-only, offline, no telemetry. Command whitelists, dangerous-command blocking, and sensitive-data redaction are layered in.
Related MCP server: laravel-forge-mcp
Built-in Domains
Domain | When it loads | Tools |
Generic | Always |
|
Laravel |
| artisan, schema, model, routes, migrations, CRUD/feature/API generators, debug workflow, intentPlanner, workflowStatus, context, and more |
Generic domain
Tool | Description |
| Git status summary (branch, staged/unstaged changes) |
| Search files by glob, excluding |
| Two-level directory tree of the project |
| List the roles available in this project and the tools each role owns |
Laravel domain
Tool | Description |
| Run whitelisted |
| Migration status |
| Environment info (safe variant redacts secrets) |
| Clear/cache config, routes, views |
| Inspect config values |
| List tables / columns |
| Scan Eloquent models |
| Recent log entries |
| Routes with name/URI/method filters |
| Run PHPUnit tests |
| Scan views/js/css structure |
| Scaffold classes |
| Parse migrations into schema |
| Project dependencies |
| Full project context (cached by file mtime) |
| Full CRUD generator |
| CRUD + Blade views |
| REST API generator (optional Sanctum auth) |
| Error location, diagnosis, fix suggestions |
| Natural-language request → executable plan |
| List/inspect/resume/rollback runs |
| Show whether each piece of project context came from cache or was rebuilt live |
| List the roles available in this project and the tools each role owns |
Why agents trust their answers
Two design principles borrowed from real-world system-prompt architecture:
Roles, not tool lists.
listRolestells the agent who it can be in this project — an explorer (read-only investigation), an engineer (build and fix), or a maintainer (ops and verification) — and which tools each role owns. Instead of facing a flat wall of tools, the agent picks a role and stays inside its boundary. Fewer missteps, clearer intent.Know where your facts come from.
contextSourceshows whether each module of project context was served from cache or rebuilt in real time, and context itself is assembled through a priority chain (cache → live → safe default) instead of "the agent figures it out". When the agent answers, it knows how fresh the facts are — and so do you.
Before: an agent stares at 29 tools and stale context it can't date-check. After: it knows its role, its toolset, and the freshness of everything it reads.
Quick Start
npm install
npm startSet the project path to work against:
# Any project (Node, Laravel, ...)
CORTEX_PROJECT_PATH=/path/to/project npm start
# Laravel-specific path resolution (backward compatible)
LARAVEL_PROJECT_PATH=/path/to/laravel-app npm start
# Nothing set → process.cwd()Run the server with a single MCP request to see which tools a project exposes:
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | \
CORTEX_PROJECT_PATH=/path/to/node-project npx tsx src/index.ts
# → only generic tools
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | \
CORTEX_PROJECT_PATH=/path/to/laravel-app npx tsx src/index.ts
# → generic + laravel toolsWith OpenCode
Add to ~/.config/opencode/opencode.jsonc:
{
"mcp": {
"cortex": {
"type": "local",
"command": ["node", "/path/to/cortex-agent-runtime/dist/index.js"],
"environment": { "CORTEX_PROJECT_PATH": "/path/to/project" }
}
}
}With Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"cortex": {
"command": "node",
"args": ["/path/to/cortex-agent-runtime/dist/index.js"]
}
}
}Environment Variables
Variable | Default | Description |
| — | Project path (takes priority) |
|
| Backward-compatible Laravel project path |
|
| PHP executable path (Laravel domain) |
| (empty) | Enables the LLM semantic layer for |
|
| OpenAI-compatible API base URL |
|
| LLM model used for intent analysis |
Architecture
src/
├── index.ts # entry: detect → load domains → register → start MCP
├── core/ # framework layer — project-type agnostic
│ ├── registry.ts # ToolRegistry: registerDomain / listTools / callTool / roles
│ ├── source-chain.ts # resolveChain: priority fallback chain (cache → live → default)
│ ├── mcp.ts # getConfig / getLogger / runCommand
│ ├── logger.ts # leveled logger
│ ├── detector.ts # detectDomains(projectPath) → DomainManifest[]
│ ├── glob.ts # minimal `*` / `**` glob
│ ├── context/ # generic context interface
│ └── tools/ # shared tools (listRoles)
└── domains/
├── generic/ # always loaded: gitStatus / fileSearch / projectTree / listRoles
└── laravel/ # tools / workflows / context / security / planner / manifestEach domain exports a DomainManifest (id, name, detect, getTools, getHandlers, getProjectPath?, roles?). Roles declare who the agent can be in this project (explorer / engineer / maintainer) and which tools each role owns — the agent can call listRoles instead of guessing. The Laravel domain keeps its own runtime (domains/laravel/mcp.ts), tools, workflows, context, security, and planner — the pre-existing 24-tool surface is unchanged.
Requirements
Node.js 18+
PHP 8.1+ (for the Laravel domain)
Pi Extension (port of the MCP tools)
Same toolset, as a pi coding agent extension: 34 of the 35 tools migrated from the MCP server to native pi custom tools, minus intentPlanner (pi is itself an LLM; natural-language → plan is redundant there). Source: pi-extension/cortex-laravel/.
Install
# either copy …
cp -R pi-extension/cortex-laravel ~/.pi/agent/extensions/
# … or symlink (always in sync with this repo)
ln -s "$(pwd)/pi-extension/cortex-laravel" ~/.pi/agent/extensions/cortex-laravelThen restart pi (or /reload). The extension registers 34 tools:
Domain | Tools |
Generic (5) |
|
Laravel core (5) |
|
Laravel ops (12) |
|
Laravel workflows (7) |
|
Orchestration (5) |
|
Project path resolution: CORTEX_PROJECT_PATH / LARAVEL_PROJECT_PATH env, falling back to pi's session cwd. Laravel tools self-guard with a clear error on non-Laravel projects; orchestration tools read/write the same .htask/ layout as the MCP server (and the standalone htask CLI).
Differences vs the MCP server
Safety — same command whitelist + dangerous-pattern validator (two layers), plus a confirm gate on
taskAdvance/taskAccept/workflowStatus(resume·rollback): setCORTEX_CONFIRM_OFF=1to allow in scripts.Laravel 11+ compatibility —
config:getremoved upstream falls back to tinker; API routes auto-create viaartisan install:apiwhenroutes/api.phpis absent.nix flake projects —
resolvePhpPathprobes known nix install paths (not onlynixinPATH).Errors — thrown errors surface as tool errors; tool results are plain text (no MCP JSON-RPC wrapper).
Development
npm install
npm run typecheck # tsc --noEmit (type-check only)
npm test # run all tests
npm run build # compile to dist/
npm start # node dist/index.js
npm run dev # npx tsx src/index.ts (hot reload)License
MIT
Available Tools
23 toolsapiGeneratorB
Generate REST API for a Laravel entity: migration, model, API controller, routes, tests
Inputs: entity (required), auth, fields.
artisanA
Run a Laravel artisan command. Returns stdout and stderr.
Inputs: command (required).
cacheB
Manage Laravel caches: clear all caches, or cache config/routes for performance.
Inputs: action (required).
composerAnalyzerA
List Laravel project dependencies from composer.json and composer.lock
Inputs: dev, filter.
configGetA
Get a Laravel config value by key (e.g. 'app.name', 'database.default', 'mail.default').
Inputs: key (required).
createFeatureB
Generate complete Laravel feature: migration, model, controller, requests, routes, blade views, tests
Inputs: entity (required), api, views, fields.
crudGeneratorA
Generate full CRUD for a Laravel entity: migration, model, controller, request, route, test, and run tests
Inputs: entity (required), table, fields.
debugWorkflowA
Analyze a Laravel error: locate file, read context, diagnose common issues, suggest fixes
Inputs: error (required), file.
envInfoA
Show Laravel environment info: APP_ENV, APP_DEBUG, and database connection status.
Inputs: no named parameters.
envInfoSafeA
Read Laravel environment info, filtering out sensitive values (keys, passwords, tokens)
Inputs: no named parameters.
frontendScannerA
Scan Laravel frontend structure: views, JS, CSS files
Inputs: no named parameters.
intentPlannerA
Parse a natural language development request, generate an execution plan, and optionally execute it
Inputs: request (required), dryRun.
logA
View recent entries from the Laravel log file (storage/logs/laravel.log).
Inputs: lines.
makeControllerB
Create a new controller class
Inputs: name (required), api, model, resource.
makeMigrationB
Create a new migration file
Inputs: name (required), table, create.
makeModelB
Create a new Eloquent model class
Inputs: name (required), seed, factory, migration.
migrateStatusA
Show the status of Laravel migrations. Lists which migrations have been run and which are pending.
Inputs: no named parameters.
migrationAnalyzerA
Parse Laravel migration files and extract database schema (columns, types, foreign keys)
Inputs: no named parameters.
modelA
List Eloquent models in the Laravel application by scanning app/Models and verifying they extend Model.
Inputs: no named parameters.
projectContextA
Get comprehensive Laravel project context (version, models, routes, packages, structure)
Inputs: force.
routeListB
List Laravel routes with optional filtering by name or URI
Inputs: uri, name, method.
runTestA
Run PHPUnit tests with optional filter
Inputs: filter.
schemaA
Inspect the Laravel database schema: list all tables, or show column details for a specific table.
Inputs: action (required), table.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 23 tools
Most tools have clearly distinct purposes, but there is overlap between envInfo/envInfoSafe and between migrationAnalyzer/schema for inspecting database structure. The three generators (crudGenerator, createFeature, apiGenerator) also have similar scopes, though descriptions clarify differences.
Tool names use inconsistent patterns: some are camelCase verbs (runTest, makeModel), some are noun-first (envInfo, configGet), some are single nouns (artisan, model, log), and some are compound names (migrationAnalyzer, crudGenerator). No consistent verb_noun convention.
23 tools is on the heavy side; while each has a purpose, the server covers many development workflows, making it borderline but manageable. Not excessive enough for a 2, but more than the typical well-scoped server.
The toolset covers a wide range of Laravel tasks: environment info, migrations, schema inspection, code generation, testing, debugging, and project context. Minor gaps like missing seeding/rollback commands can be worked around via artisan, so not severely incomplete.
Maintenance
Related MCP Connectors
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Build your own tools from chat: design, test and host them on a shareable MCP server URL.
A MCP server built for developers enabling Git based project management with project and personal…
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables 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.9 npmMIT
- AlicenseAqualityDmaintenanceMCP server exposing the Laravel Forge API v2 with curated tools for deploys, logs, env, and services plus universal access to all 273 operations.28Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables developers to expose any dev tool as a safe, audited MCP server with permission tiers, audit logging, and automatic argument validation.MIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to drive a Pterodactyl game panel over both its client and application API trees, covering servers, files, backups, schedules, databases, subusers, nodes, nests, and an eight-tool wings websocket console suite. Exposes 105 typed tools with a default-deny gate that blocks deletes, reinstalls, suspensions, and kill actions until explicitly allowlisted.MIT