Cover image
Try Now
2025-03-27

Un servidor de Protocolo de contexto modelo (MCP) que permite la ejecución segura de los comandos artesanales de Laravel a través de Claude y otros clientes de MCP.

3 years

Works with Finder

1

Github Watches

0

Github Forks

1

Github Stars

Laravel Artisan MCP Server

A Model Context Protocol (MCP) server that enables secure execution of Laravel Artisan commands through Claude and other MCP clients. This server acts as a bridge between AI assistants and your local Laravel applications, allowing controlled management of Laravel projects through natural language conversations.

Features

  • Access a single directory containing a Laravel project
  • Automatically locate PHP on your system
  • Execute only whitelisted Artisan commands
  • View all available Artisan commands
  • Secure by design with robust input validation

Examples

Example

Requirements

  • Python 3.10 or higher
  • Laravel project with Artisan CLI
  • PHP installed and accessible in your PATH
  • MCP-compatible client (such as Claude Desktop)

Installation

  1. Clone this repository:

    git clone https://github.com/diggy/laravel-artisan-mcp.git
    cd laravel-artisan-mcp
    
  2. Create a virtual environment:

    uv init
    uv venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
  3. Install dependencies:

    uv add "mcp[cli]"
    

Configuration

The server requires the following environment variables:

  • ARTISAN_DIRECTORY: Absolute path to the Laravel project containing the Artisan executable
  • WHITELISTED_COMMANDS: Comma-separated list of allowed Artisan commands (e.g., route:list,cache:clear,make:controller or any default or custom Commands registered in your Laravel application)

You can provide these variables in several ways:

  1. Directly in the command line:

    ARTISAN_DIRECTORY="/absolute/path/to/your/laravel/project" WHITELISTED_COMMANDS="route:list,cache:clear,make:controller" uv run artisan_mcp_server.py
    
  2. Using a .env file:

    ARTISAN_DIRECTORY=/absolute/path/to/your/laravel/project
    WHITELISTED_COMMANDS=route:list,cache:clear,make:controller
    
  3. In the Claude Desktop configuration (cf. section on Claude Integration below)

Testing with MCP Inspector

The MCP Inspector provides a graphical interface for testing your server before integrating it with Claude:

# Run with direct environment variables
ARTISAN_DIRECTORY="/absolute/path/to/your/laravel/project" WHITELISTED_COMMANDS="route:list,cache:clear,make:controller" uv run mcp dev artisan_mcp_server.py

# Or using an env file
uv run mcp dev artisan_mcp_server.py --env-file .env

Once the Inspector is running:

  1. Open the web interface at http://localhost:5173
  2. Explore the "Resources" tab to see available resources
  3. Test the tools under the "Tools" tab:
    • list_all_artisan_commands: Shows all commands in your Laravel project
    • run_artisan: Executes a specific command (must be whitelisted)

Claude Integration

To use this server with Claude Desktop:

  1. Ensure Claude Desktop is installed

  2. Edit the Claude Desktop configuration file:

    macOS:

    nano ~/Library/Application\ Support/Claude/claude_desktop_config.json
    

    Windows:

    notepad %APPDATA%\Claude\claude_desktop_config.json
    
  3. Add the following configuration (adjust paths as needed):

    {
      "mcpServers": {
        "laravel-artisan": {
          "command": "uv",
          "args": [
            "--directory", 
            "/absolute/path/to/laravel-artisan-mcp",
            "run", 
            "artisan_mcp_server.py"
          ],
          "env": {
            "ARTISAN_DIRECTORY": "/absolute/path/to/your/laravel/project",
            "WHITELISTED_COMMANDS": "route:list,cache:clear,make:controller"
          }
        }
      }
    }
    
  4. Restart Claude Desktop

Available Tools

run_artisan

Executes a whitelisted Artisan command.

Parameters:

  • command: The Artisan command to run (e.g., 'cache:clear')

Example usage in Claude: "Run the route:list command to show all available routes in my Laravel app."

list_all_artisan_commands

Displays all available Artisan commands in the Laravel application.

Example usage in Claude: "Show me all available Artisan commands in my Laravel project."

Available Resources

artisan://commands

Returns a list of all whitelisted commands configured for the server.

Example usage in Claude: "What Artisan commands can I use through you?"

Security Considerations

This server implements several security measures (according to Claude):

  • Directory Isolation: Only accesses the explicitly configured Laravel directory
  • Command Whitelisting: Only executes commands that are specifically allowed
  • Input Validation: Verifies all inputs before execution
  • Error Handling: Prevents sensitive information leakage

Troubleshooting

"ARTISAN_DIRECTORY must be provided in configuration"

The server cannot find the path to your Laravel project. Check that:

  • The environment variable is properly set
  • The directory exists and is accessible

"Artisan not found at: /path/to/artisan"

The specified directory does not contain the Artisan executable. Verify that:

  • The path points to a valid Laravel project directory
  • The Artisan file exists and has executable permissions

"PHP executable not found"

The server cannot find PHP in your PATH. Ensure that:

  • PHP is installed on your system
  • The PHP executable is in your system PATH

Disclaimer

This Laravel Artisan MCP Server is provided as-is, without any warranties or guarantees of any kind. By using this software, you assume all risks associated with its operation. The server has access to execute commands within your Laravel environment, which could potentially impact your application data and functionality. We strongly recommend using this tool only in development or testing environments. Use this server with production Laravel applications only if you fully understand the security implications and have implemented appropriate safeguards. Always maintain proper backups of your Laravel project before allowing AI assistants to execute Artisan commands through this interface. The authors and contributors of this software cannot be held responsible for any damages, data loss, or security breaches that may result from the use or misuse of this tool. You are solely responsible for configuring appropriate command whitelisting and access controls. This software has not undergone formal security auditing and should be considered experimental. Use at your own risk.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

This MCP server was crafted with assistance from Claude, Anthropic's AI assistant (who insisted on adding this humble credit while promising it wouldn't include smiley emoticons or excessive enthusiasm).

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Yasir Eryilmaz
  • AI scriptwriting assistant for short, engaging video content.

  • J. DE HARO OLLE
  • Especialista en juegos de palabras en varios idiomas.

  • Daren White
  • A supportive coach for mastering all Spanish tenses.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • albert tan
  • Japanese education, creating tailored learning experiences.

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • huahuayu
  • Una puerta de enlace de API unificada para integrar múltiples API de explorador de blockchain similar a Esterscan con soporte de protocolo de contexto modelo (MCP) para asistentes de IA.

  • deemkeen
  • Controle su MBOT2 con un combo de potencia: MQTT+MCP+LLM

  • zhaoyunxing92
  • 本项目是一个钉钉 MCP (Protocolo del conector de mensajes )服务 , 提供了与钉钉企业应用交互的 API 接口。项目基于 Go 语言开发 支持员工信息查询和消息发送等功能。 支持员工信息查询和消息发送等功能。

  • pontusab
  • La comunidad de cursor y windsurf, encontrar reglas y MCP

    Reviews

    4 (1)
    Avatar
    user_3zNycRbu
    2025-04-17

    As a devoted user of laravel-artisan-mcp by entanglr, I am thoroughly impressed with its capabilities. This tool has significantly streamlined my development workflow, providing efficient command-line interactions. The integration with Laravel is seamless, and I appreciate the thoughtful design reflected in its functionality. I highly recommend checking it out on GitHub: https://github.com/diggy/laravel-artisan-mcp.