Laravel MCP Server
Cortex Agent Runtime — 基于 MCP 的原生 AI Agent 框架
之前:AI 不理解你的项目。之后:AI 可以分析、生成和调试应用程序。
一个 Model Context Protocol (MCP) 服务器,可将任何编码代理(Claude、Cursor、Codex、OpenCode 等)转变为你所处理项目的自主工程大脑。该运行时与项目类型无关:它会根据你的项目类型加载一组领域,因此同一运行时适用于 Laravel 应用、Node 项目以及任何其他项目。
运行时
项目类型检测 —
core/detector.ts检查项目并激活匹配的领域。通用工具始终加载;当存在composer.json+artisan时,Laravel 领域被激活。领域注册 —
core/registry.ts暴露registerDomain(manifest);listTools()/callTool()保持稳定,因此 MCP 表面在不同项目之间不会变化。默认安全 — 仅本地、离线、无遥测。命令白名单、危险命令阻止和敏感数据脱敏分层实现。
Related MCP server: Project Planner MCP
内置领域
领域 | 加载时机 | 工具 |
通用 | 始终 |
|
Laravel | 存在 | artisan、schema、model、routes、migrations、CRUD/feature/API 生成器、调试工作流、intentPlanner、workflowStatus、context 等 |
通用领域
工具 | 描述 |
| Git 状态摘要(分支、暂存/未暂存更改) |
| 按 glob 搜索文件,排除 |
| 项目的两级目录树 |
| 列出此项目中可用的角色以及每个角色拥有的工具 |
Laravel 领域
工具 | 描述 |
| 运行白名单内的 |
| 迁移状态 |
| 环境信息(安全变体对机密信息进行脱敏) |
| 清除/缓存配置、路由、视图 |
| 检查配置值 |
| 列出表 / 列 |
| 扫描 Eloquent 模型 |
| 最近的日志条目 |
| 带名称/URI/方法过滤器的路由 |
| 运行 PHPUnit 测试 |
| 扫描视图/js/css 结构 |
| 搭建类 |
| 将迁移解析为 schema |
| 项目依赖 |
| 完整项目上下文(按文件 mtime 缓存) |
| 完整 CRUD 生成器 |
| CRUD + Blade 视图 |
| REST API 生成器(可选 Sanctum 认证) |
| 错误定位、诊断、修复建议 |
| 自然语言请求 → 可执行计划 |
| 列出/检查/恢复/回滚运行 |
| 显示每部分项目上下文来自缓存还是实时重建 |
| 列出此项目中可用的角色以及每个角色拥有的工具 |
为什么代理信任它们的答案
两个借鉴自真实系统提示架构的设计原则:
角色,而非工具列表。
listRoles告诉代理它在此项目中可以是谁——探索者(只读调查)、工程师(构建和修复)或维护者(运维和验证)——以及每个角色拥有哪些工具。代理面对的不是一堵平坦的工具墙,而是选择一个角色并停留在其边界内。更少的失误,更清晰的意图。知道你的事实来自哪里。
contextSource显示项目上下文的每个模块是从缓存提供还是实时重建,并且上下文本身通过优先级链(cache → live → safe default)组装,而不是“由代理自行解决”。当代理回答时,它知道事实有多新鲜——你也一样。
之前: 代理盯着 29 个工具和无法检查日期的过期上下文。 之后: 它知道自己的角色、工具集以及所读一切的新鲜度。
快速开始
npm install
npm start设置要处理的项目路径:
# 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()通过单个 MCP 请求运行服务器,查看项目暴露了哪些工具:
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 tools使用 OpenCode
添加到 ~/.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" }
}
}
}使用 Claude Desktop
添加到 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"cortex": {
"command": "node",
"args": ["/path/to/cortex-agent-runtime/dist/index.js"]
}
}
}环境变量
变量 | 默认值 | 描述 |
| — | 项目路径(优先) |
|
| 向后兼容的 Laravel 项目路径 |
|
| PHP 可执行文件路径(Laravel 领域) |
| (空) | 为 |
|
| 兼容 OpenAI 的 API 基础 URL |
|
| 用于意图分析的 LLM 模型 |
架构
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 / manifest每个领域导出一个 DomainManifest(id、name、detect、getTools、getHandlers、getProjectPath?、roles?)。角色声明代理在此项目中可以是谁(explorer / engineer / maintainer)以及每个角色拥有哪些工具——代理可以调用 listRoles 而不是猜测。Laravel 领域保留自己的运行时(domains/laravel/mcp.ts)、工具、工作流、上下文、安全和规划器——现有的 24 工具表面不变。
要求
Node.js 18+
PHP 8.1+(用于 Laravel 领域)
Pi 扩展(MCP 工具的移植)
相同的工具集,作为 pi coding agent 扩展:35 个工具中的 34 个从 MCP 服务器迁移到原生 pi 自定义工具,减去 intentPlanner(pi 本身是 LLM;自然语言 → 计划在那里是多余的)。来源:pi-extension/cortex-laravel/。
安装
# 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-laravel然后重启 pi(或 /reload)。该扩展注册 34 个工具:
领域 | 工具 |
通用(5) |
|
Laravel 核心(5) |
|
Laravel 运维(12) |
|
Laravel 工作流(7) |
|
编排(5) |
|
项目路径解析:CORTEX_PROJECT_PATH / LARAVEL_PROJECT_PATH 环境变量,回退到 pi 的会话 cwd。Laravel 工具在非 Laravel 项目上通过清晰的错误进行自我保护;编排工具读写与 MCP 服务器(以及独立的 htask CLI)相同的 .htask/ 布局。
与 MCP 服务器的差异
安全性 — 相同的命令白名单 + 危险模式验证器(两层),外加
taskAdvance/taskAccept/workflowStatus(恢复·回滚)上的确认门:设置CORTEX_CONFIRM_OFF=1以允许在脚本中使用。Laravel 11+ 兼容性 — 上游移除的
config:get回退到 tinker;当routes/api.php不存在时,API 路由通过artisan install:api自动创建。nix flake 项目 —
resolvePhpPath探测已知的 nix 安装路径(不仅仅是PATH中的nix)。错误 — 抛出的错误作为工具错误呈现;工具结果是纯文本(无 MCP JSON-RPC 包装)。
开发
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)许可证
MIT
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
- AlicenseNot gradedqualityCmaintenanceIntegrates with the Laravel Forge API to provide comprehensive management of servers and sites. It enables users to perform health checks, monitor logs, create resources, and execute deployment tasks through MCP-compliant tools.202MIT
- AlicenseAqualityDmaintenanceMCP server for structured Laravel project planning. Scans projects, creates tickets, and exports as JSON.313MIT
- FlicenseNot gradedqualityDmaintenanceProvides various developer utilities such as UUID generation, timestamp conversion, Base64 encoding, color conversion, password generation, hash generation, and JSON formatting via MCP.771
- AlicenseNot gradedqualityBmaintenanceEnables 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.16MIT
Related MCP Connectors
A MCP server built for developers enabling Git based project management with project and personal…
Markdown-first MCP server for Notion API with 8 composite tools and 39 actions.
A basic MCP server to operate on the Postman API.
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/dok4everak47/cortex-agent-runtime'
If you have feedback or need assistance with the MCP directory API, please join our Discord server