/ Annuaire / Playground / Laravel MCP
● Officiel laravel ⚡ Instantané

Laravel MCP

par laravel · laravel/mcp

Laravel's official MCP package — define MCP tools as classes, expose Eloquent models and Artisan commands to Claude with first-party auth/middleware.

Laravel MCP turns any Laravel app into an MCP server. Tools are PHP classes you register in a service provider; the package handles JSON-RPC, schema generation, and transport. You get to reuse your auth, policies, and middleware.

Pourquoi l'utiliser

Fonctionnalités clés

Démo en direct

Aperçu en pratique

prêt

Installer

Choisissez votre client

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "laravel-mcp": {
      "command": "php",
      "args": [
        "artisan",
        "mcp:start"
      ],
      "_doc": "Run inside a Laravel project after `composer require laravel/mcp` and `php artisan mcp:install`."
    }
  }
}

Ouvrez Claude Desktop → Settings → Developer → Edit Config. Redémarrez après avoir enregistré.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "laravel-mcp": {
      "command": "php",
      "args": [
        "artisan",
        "mcp:start"
      ],
      "_doc": "Run inside a Laravel project after `composer require laravel/mcp` and `php artisan mcp:install`."
    }
  }
}

Cursor utilise le même schéma mcpServers que Claude Desktop. La config projet l'emporte sur la globale.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "laravel-mcp": {
      "command": "php",
      "args": [
        "artisan",
        "mcp:start"
      ],
      "_doc": "Run inside a Laravel project after `composer require laravel/mcp` and `php artisan mcp:install`."
    }
  }
}

Cliquez sur l'icône MCP Servers dans la barre latérale Cline, puis "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "laravel-mcp": {
      "command": "php",
      "args": [
        "artisan",
        "mcp:start"
      ],
      "_doc": "Run inside a Laravel project after `composer require laravel/mcp` and `php artisan mcp:install`."
    }
  }
}

Même format que Claude Desktop. Redémarrez Windsurf pour appliquer.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "laravel-mcp",
      "command": "php",
      "args": [
        "artisan",
        "mcp:start"
      ]
    }
  ]
}

Continue utilise un tableau d'objets serveur plutôt qu'une map.

~/.config/zed/settings.json
{
  "context_servers": {
    "laravel-mcp": {
      "command": {
        "path": "php",
        "args": [
          "artisan",
          "mcp:start"
        ]
      }
    }
  }
}

Ajoutez dans context_servers. Zed recharge à chaud à la sauvegarde.

claude mcp add laravel-mcp -- php artisan mcp:start

Une seule ligne. Vérifiez avec claude mcp list. Supprimez avec claude mcp remove.

Cas d'usage

Usages concrets : Laravel MCP

Expose Eloquent models as MCP tools

👤 Developers ⏱ ~15 min intermediate

Quand l'utiliser : You want Claude to query/update your domain data through your existing policies.

Déroulement
  1. Install
    composer require laravel/mcp; php artisan mcp:install✓ Copié
    → Service provider + config published
  2. Define tool
    Create OrderLookupTool extends McpTool, type-hint $orderId; return Order::findOrFail($orderId).✓ Copié
    → Tool registered
  3. Run
    php artisan mcp:start; connect Claude.✓ Copié
    → Claude lists your tool and can call it

Résultat : Claude reads/writes your domain data via your existing authorization.

Wrap Artisan commands as MCP tools

👤 Developers ⏱ ~15 min intermediate

Quand l'utiliser : You want Claude to run safe maintenance tasks (cache clear, queue retry).

Déroulement
  1. Whitelist
    In config/mcp.php, list the Artisan commands you allow.✓ Copié
    → Whitelist saved
  2. Call
    From Claude: "Run artisan queue:retry all".✓ Copié
    → Command runs; output streamed back

Résultat : Operational tasks become Claude-callable, scoped to a whitelist.

Combinaisons

Associez-le à d'autres MCPs pour un effet X10

laravel-mcp + github

Deploy MCP server alongside your Laravel app via Forge/Vapor

Combine laravel-mcp with github: Deploy MCP server alongside your Laravel app via Forge/Vapor✓ Copié
laravel-mcp + sentry

Errors raised inside tools surface in your existing Sentry pipeline

Combine laravel-mcp with sentry: Errors raised inside tools surface in your existing Sentry pipeline✓ Copié

Outils

Ce que ce MCP expose

OutilEntréesQuand appelerCoût
php-class tools (see docs) Each tool you register is dispatched via Laravel container with normal middleware 1 call

Coût et limites

Coût d'exécution

Quota d'API
Bound by your DB and rate limits
Tokens par appel
Whatever your tool returns
Monétaire
Free package; your hosting costs apply
Astuce
Paginate model returns; large Eloquent dumps blow tokens fast

Sécurité

Permissions, secrets, portée

Portées minimales : app-defined gates/policies
Stockage des identifiants : Sanctum/Passport tokens via Laravel auth
Sortie de données : Local app only
Ne jamais accorder : skip your normal authorization checks in tools

Dépannage

Erreurs courantes et correctifs

Tool not appearing in client

Restart mcp:start; tools register at boot. Check service provider is loaded.

JSON Schema wrong

Ensure PHP type hints — int $id, not $id. Use attributes for descriptions.

Alternatives

Laravel MCP vs autres

AlternativeQuand l'utiliserCompromis
fastmcp (Python)Stack is PythonNo Eloquent integration
csharp-sdkStack is .NETDifferent ecosystem

Plus

Ressources

📖 Lire le README officiel sur GitHub

🐙 Voir les issues ouvertes

🔍 Parcourir les 400+ serveurs MCP et Skills