> ## 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

> Leer hoe je MCP-servers configureert en beheert via de sessieconfiguratie en de Server RPC API van de Laravel Copilot SDK.

## MCP

Je kunt MCP-servers gebruiken door ze op te geven in `mcpServers` van de SessionConfig.

Gebruik je Laravel Boost met de Copilot CLI, gebruik dan ook [laravel-boost-copilot-cli](https://github.com/invokable/laravel-boost-copilot-cli).
Het is bekend dat `'type' => 'stdio'` (of `'local'`) en `'tools' => ['*']` verplicht zijn. Zonder deze wordt de server niet als MCP-server herkend.

```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 = 'Welke MCP\'s zijn er geladen? Als laravel-boost beschikbaar is, haal dan de app-informatie op met application-info.';

        warning($prompt);

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

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

## Status van MCP-servers

De status van een MCP-server binnen een session kan de volgende waarden hebben:

| Status           | Beschrijving          |
| ---------------- | --------------------- |
| `connected`      | Verbonden             |
| `failed`         | Verbinding mislukt    |
| `needs-auth`     | Authenticatie vereist |
| `pending`        | Wacht op verbinding   |
| `disabled`       | Uitgeschakeld         |
| `not_configured` | Niet geconfigureerd   |

## MCP-serverconfiguratie beheren (Server RPC)

Los van sessions kun je de configuratie van MCP-servers op serverniveau beheren.

```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;

// Haal de lijst met geconfigureerde MCP-servers op
$result = Copilot::client()->rpc()->mcp()->list();
foreach ($result->servers as $name => $config) {
    dump($name, $config->type, $config->command);
}

// Voeg een MCP-server toe
Copilot::client()->rpc()->mcp()->add(new McpConfigAddRequest(
    name: 'laravel-boost',
    config: new McpServerValue(
        type: 'stdio',
        command: 'php',
        args: ['artisan', 'boost:mcp'],
        tools: ['*'],
    ),
));

// Werk de configuratie van een MCP-server bij
Copilot::client()->rpc()->mcp()->update(new McpConfigUpdateRequest(
    name: 'laravel-boost',
    config: new McpServerValue(
        type: 'stdio',
        command: 'php',
        args: ['artisan', 'boost:mcp', '--verbose'],
        tools: ['*'],
    ),
));

// Verwijder een MCP-server
Copilot::client()->rpc()->mcp()->remove(new McpConfigRemoveRequest(name: 'laravel-boost'));
```

<Info>
  Raadpleeg de [GitHub-repository](https://github.com/invokable/laravel-copilot-sdk) voor de meest actuele informatie.
</Info>


## Related topics

- [Laravel MCP](/nl/mcp.md)
- [Een MCP-server bouwen met Laravel](/nl/advanced/mcp-server.md)
- [Laravel AI-agents ondersteunen nu MCP-servers](/nl/blog/ai-sdk-mcp-client.md)
- [Laravel AI SDK](/nl/ai-sdk.md)
- [Laravel Boost](/nl/boost.md)
