> ## Documentation Index
> Fetch the complete documentation index at: https://kawax.biz/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP

> Beschreibt, wie Sie MCP-Server über die Session-Konfiguration und die Server-RPC-API des Laravel Copilot SDK einrichten und verwalten.

## 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](https://github.com/invokable/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.

```php theme={null}
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:

| Status           | Beschreibung                   |
| ---------------- | ------------------------------ |
| `connected`      | Verbunden                      |
| `failed`         | Verbindung fehlgeschlagen      |
| `needs-auth`     | Authentifizierung erforderlich |
| `pending`        | Verbindung ausstehend          |
| `disabled`       | Deaktiviert                    |
| `not_configured` | Nicht konfiguriert             |

## MCP-Server-Konfiguration verwalten (Server-RPC)

Unabhängig von einer Session können Sie MCP-Server-Konfigurationen auf Serverebene verwalten.

```php theme={null}
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'));
```

<Info>
  Aktuelle Informationen finden Sie im [GitHub-Repository](https://github.com/invokable/laravel-copilot-sdk).
</Info>


## Related topics

- [Laravel MCP](/de/mcp.md)
- [Einen MCP-Server mit Laravel bauen](/de/advanced/mcp-server.md)
- [Einen eigenen Agenten für Boost erstellen](/de/advanced/boost-custom-agent.md)
- [Laravel AI SDK](/de/ai-sdk.md)
- [Laravel Boost Custom Agent for PhpStorm with GitHub Copilot](/de/packages/laravel-boost-phpstorm-copilot.md)
