Skip to main content

MCP

Specify MCP servers under mcpServers in SessionConfig to enable them. If you’re using Laravel Boost from the Copilot CLI, also install laravel-boost-copilot-cli. We know that 'type' => 'stdio' (or 'local') and 'tools' => ['*'] are required. Without them, the MCP server is not recognized. args is optional.

MCP Apps (experimental)

In a session with enableMcpApps enabled, use $session->rpc()->mcp()->apps() to work with MCP Apps tools and resources. listTools() returns the tools an app can call, callTool() runs a tool, and readResource() fetches a ui:// resource such as HTML. listTools() and callTool() require originServerName, which identifies the calling server. Use getHostContext() and setHostContext() to read and write host context such as the theme and locale. diagnose() returns the server’s MCP Apps support status.
callTool() returns a free-form MCP result. The SDK provides RPCs for fetching and setting data, but it does not render the fetched HTML or manage iframes. Implement rendering in your application, for example with Livewire or Inertia.

Provide MCP OAuth tokens from the host

When an MCP server requires OAuth authentication, use onMcpAuthRequest to handle authentication in your application. The callback receives an McpAuthRequest and a context array that contains sessionId. Return an McpAuthToken to pass the token to the CLI runtime. Return null or an McpAuthResult with kind: 'cancelled' to cancel authentication.
McpAuthRequest includes requestId, serverName, serverUrl, and reason (initial, refresh, reauth, or upscope). When you set the handler, the SDK automatically subscribes to mcp.oauth_required events. This lets you authenticate in contexts that cannot open a browser, such as web requests, queues, and batches. When you resume a session, pass the same handler in ResumeSessionConfig.

Check MCP OAuth support (Server RPC)

After a remote MCP server requests OAuth authentication, use Server RPC to check whether it supports Dynamic Client Registration (DCR). authorizationServerUrl is returned when the authorization server can be discovered from metadata. If supportsDcr is false, dynamic registration is not available.
resourceMetadataText is the protected resource metadata from the WWW-Authenticate challenge. If you omit it, the authorization server is discovered from the server URL. If you pass sessionId, the destination policy and sandbox proxy of that local session apply. Microsoft Entra ID does not support DCR. If the authorization server is Microsoft, you can use a pre-registered client instead of asking the user for client credentials. These are Server RPCs (Copilot::client()->rpc()). They are a separate namespace from the session RPC $session->rpc()->mcp()->oauth(), which handles login and OAuth requests.

MCP server status

MCP server status inside a session can be one of the following: Each server returned by $session->rpc()->mcp()->listConfigured() may include its observed runtime state as live. Convert it to a typed object with McpConfiguredServerState::fromArray($server['live']). The optional toolsLoaded bool on McpConfiguredServerState indicates whether the current connection has loaded its tool list. When the runtime has not reported it, toolsLoaded is null, so don’t treat a missing value as false.
A connected status alone does not mean the tools are loaded. Listen for the session.mcp_server_tools_loaded event to know when a server’s tool list becomes available. This ephemeral event fires once per connection with data.serverName and data.toolCount, and is not persisted. When cached tools are used, it can arrive before connected.

Managing MCP server configuration (Server RPC)

Independently of sessions, you can manage MCP server configuration at the server level.

Disabled servers when reloading MCP

When you pass configuration to reloadWithConfig(), configuredDisabledServers is the list of servers disabled by settings that your application resolved. Specify it separately from the session-level disabledServers and the CLI’s cliEnabledServers. Settings-based disabling has lower priority than CLI enabling and explicit session disabling, so don’t merge configuredDisabledServers into disabledServers.
For the latest updates, see the GitHub repository.
Last modified on October 19, 2026