定制 skylence/laravel-optimize-mcp 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

skylence/laravel-optimize-mcp

Composer 安装命令:

composer require skylence/laravel-optimize-mcp

包简介

Laravel Optimize MCP provides optimization tools and utilities for AI-assisted development

README 文档

README

Optimize your Laravel project with AI assistance through the Model Context Protocol (MCP).

Installation

Install via Composer:

composer require skylence/laravel-optimize-mcp

Run the installation command and follow the prompts:

php artisan optimize-mcp:install

The installer will:

  • Automatically detect and configure your code editor (Cursor, Claude Code, VS Code, or PhpStorm)
  • Ask if you want HTTP access for staging/production servers
  • Generate a secure token and configuration instructions for remote access

Usage

Once installed, ask your AI assistant to optimize your Laravel project:

"Analyze my Laravel project and help me optimize it"

Your AI will use the installed MCP tools to:

  • Analyze your configuration for performance and security issues
  • Review your project structure and development workflow
  • Recommend useful packages and improvements
  • Provide actionable recommendations with code snippets

Remote Access for Staging/Production

Want to analyze your staging or production environment? The installer can configure this for you automatically, or you can set it up manually by adding these to your .env file:

# Enable secure HTTP access
OPTIMIZE_MCP_AUTH_ENABLED=true

# Generate token: php artisan tinker --execute="echo bin2hex(random_bytes(32))"
OPTIMIZE_MCP_API_TOKEN=your-secure-token-here

Then ask your AI to connect to your remote server:

"Connect to my production Laravel server at https://myapp.com and analyze the .env configuration"

This allows you to check production environment variables, cache/session drivers, and security settings without SSH access.

Database Monitoring & Alerts

Set up automatic database size monitoring with growth tracking and email alerts:

Enable Monitoring

  1. Add to your .env:
OPTIMIZE_MCP_DB_MONITORING=true
OPTIMIZE_MCP_DB_NOTIFICATION_EMAILS=dev@example.com,ops@example.com
OPTIMIZE_MCP_DB_WARNING_THRESHOLD=80
OPTIMIZE_MCP_DB_CRITICAL_THRESHOLD=90
  1. Run migrations:
php artisan migrate
  1. Schedule the monitoring command:

Laravel 11+ / 12 (in bootstrap/app.php):

->withSchedule(function (Schedule $schedule): void {
    $schedule->command('optimize-mcp:monitor-database')
        ->daily()
        ->onOneServer()
        ->when(fn () => config('app.schedule_enabled', true));
})

Laravel 10 and earlier (in app/Console/Kernel.php):

protected function schedule(Schedule $schedule)
{
    // Run database monitoring daily (or hourly, weekly, etc.)
    $schedule->command('optimize-mcp:monitor-database')->daily();
}

Make schedules configurable (recommended):

Add to config/app.php:

'schedule_enabled' => (bool) env('APP_SCHEDULE_ENABLED', true),

Add to .env:

APP_SCHEDULE_ENABLED=true  # Set to false to disable all scheduled tasks

This allows you to easily enable/disable schedules per environment (local, staging, production).

Available Commands

# Check database size manually
php artisan optimize-mcp:database-size

# Run monitoring (logs size, calculates growth, sends alerts)
php artisan optimize-mcp:monitor-database

# Clean up old logs (keeps 90 days by default)
php artisan optimize-mcp:prune-database-logs

Features

  • Automatic Tracking: Logs database size, growth rate, and disk usage
  • Growth Prediction: Estimates when your database will be full based on growth trends
  • Smart Alerts: Email notifications at warning (80%) and critical (90%) thresholds
  • Historical Data: Track size over time to identify growth patterns
  • Cross-Database: Supports MySQL, PostgreSQL, and SQLite

What's Included

  • Configuration Analyzer: Checks your Laravel config for performance and security
  • Database Size Inspector: Monitor database size, growth trends, and disk usage
  • Database Monitoring & Alerts: Automatic size tracking with email notifications
  • Log File Inspector: Check log sizes and rotation configuration (HTTP MCP only)
  • Nginx Config Inspector: Analyze nginx for security and performance (HTTP MCP only)
  • Nginx Config Generator: Generate production-ready nginx configs (HTTP MCP only)
  • Project Structure Analyzer: Reviews your composer scripts, CI/CD, testing setup, and more
  • Package Advisor: Recommends useful packages for your project

LLM Guidelines for AI Assistants

Want your AI assistant to know how to use these MCP tools? Add the Laravel Optimize MCP guidelines to your project's LLM instruction files:

# From the root of your Laravel project
php vendor/skylence/laravel-optimize-mcp/bin/append-guidelines.php CLAUDE.md

# Or for other LLM instruction files
php vendor/skylence/laravel-optimize-mcp/bin/append-guidelines.php .cursorrules
php vendor/skylence/laravel-optimize-mcp/bin/append-guidelines.php .copilot-instructions.md

This appends comprehensive guidelines about:

  • How to use each MCP tool
  • When to use HTTP MCP vs stdio/PHP MCP tools
  • Best practices for security and performance
  • Configuration examples and common solutions

The script will:

  • ✅ Append guidelines to existing files without overwriting
  • ✅ Skip if guidelines are already present
  • ✅ Create the file with guidelines if it doesn't exist

Advanced Configuration

For remote access, HTTP endpoints, and custom tool configuration, see the full documentation.

License

The MIT License (MIT). Please see License File for more information.

skylence/laravel-optimize-mcp 适用场景与选型建议

skylence/laravel-optimize-mcp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 152 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「optimization」 「laravel」 「ai」 「mcp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 skylence/laravel-optimize-mcp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 skylence/laravel-optimize-mcp 我们能提供哪些服务?
定制开发 / 二次开发

基于 skylence/laravel-optimize-mcp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 152
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 19
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-03