Zum Hauptinhalt springen

MCP

Sie können MCP-Server nutzen, indem Sie sie in mcpServers von SessionConfig angeben. Wenn Sie Laravel Boost mit der Copilot CLI verwenden, setzen Sie zusätzlich laravel-boost-copilot-cli ein. Bekannt ist, dass 'type' => 'stdio' (oder 'local') und 'tools' => ['*'] zwingend erforderlich sind. Ohne diese wird der MCP-Server nicht erkannt.
Artisan::command('copilot:mcp', function () {
    $config = new SessionConfig(
        mcpServers: [
            'laravel-boost' => [
                'type' => 'stdio',
                'command' => 'php',
                'args' => ['artisan', 'boost:mcp'],
                'tools' => ['*'],
            ],
        ],
    );

    Copilot::start(function (CopilotSession $session) {
        info('Starting Copilot with Laravel Boost MCP: '.$session->id());

        $prompt = 'どのMCPが読み込まれている? laravel-boostが使える場合はapplication-infoでアプリ情報を取得して。';

        warning($prompt);

        $response = spin(
            callback: fn () => $session->sendAndWait($prompt),
            message: 'Thinking...',
        );

        note($response->content());
    }, config: $config);
});

Status von MCP-Servern

Der Status eines MCP-Servers innerhalb einer Session kann folgende Werte annehmen:
StatusBeschreibung
connectedVerbunden
failedVerbindung fehlgeschlagen
needs-authAuthentifizierung erforderlich
pendingVerbindung ausstehend
disabledDeaktiviert
not_configuredNicht konfiguriert

MCP-Server-Konfiguration verwalten (Server-RPC)

Unabhängig von einer Session können Sie MCP-Server-Konfigurationen auf Serverebene verwalten.
use Revolution\Copilot\Facades\Copilot;
use Revolution\Copilot\Types\Rpc\McpConfigAddRequest;
use Revolution\Copilot\Types\Rpc\McpConfigUpdateRequest;
use Revolution\Copilot\Types\Rpc\McpConfigRemoveRequest;
use Revolution\Copilot\Types\Rpc\McpServerValue;

// Liste der konfigurierten MCP-Server abrufen
$result = Copilot::client()->rpc()->mcp()->list();
foreach ($result->servers as $name => $config) {
    dump($name, $config->type, $config->command);
}

// Einen MCP-Server hinzufügen
Copilot::client()->rpc()->mcp()->add(new McpConfigAddRequest(
    name: 'laravel-boost',
    config: new McpServerValue(
        type: 'stdio',
        command: 'php',
        args: ['artisan', 'boost:mcp'],
        tools: ['*'],
    ),
));

// Konfiguration eines MCP-Servers aktualisieren
Copilot::client()->rpc()->mcp()->update(new McpConfigUpdateRequest(
    name: 'laravel-boost',
    config: new McpServerValue(
        type: 'stdio',
        command: 'php',
        args: ['artisan', 'boost:mcp', '--verbose'],
        tools: ['*'],
    ),
));

// MCP-Server entfernen
Copilot::client()->rpc()->mcp()->remove(new McpConfigRemoveRequest(name: 'laravel-boost'));
Aktuelle Informationen finden Sie im GitHub-Repository.
Zuletzt geändert am 13. Juli 2026