Home / Blog / Software Development
Software Development

Laravel Agents Can Now Talk to Real MCP Servers

PublishedJun 09 · 2026
Read3 min
Views3
laravel ai mcp php ai sdk
Share
Laravel Agents Can Now Talk to Real MCP Servers

The Laravel AI SDK and MCP package now ship MCP client support — spread a remote server's tools straight into your agent's tools() array and let it open issues, review PRs, or search repos alongside your own tools.

Building an AI agent is easy. Giving it real capabilities — the power to actually do things in other systems — has always been the hard part. The Laravel AI SDK and the Laravel MCP package just made that part dramatically smaller: they now ship MCP client support, so a Laravel agent can connect to any real Model Context Protocol server and borrow its tools with almost no glue code.

As Laravel creator Taylor Otwell put it in announcing the feature: spin up the client, then spread its tools right into your agent's tools() array. Now your agent can open issues, review PRs, and search repos — alongside your own tools.

What actually changed

Until now, the Laravel ecosystem could expose MCP servers — letting external AI clients call into your application. The new release adds the other half of the handshake: the client side. Your own agents can now reach out to MCP servers that someone else runs and use whatever those servers expose, as if those tools were written locally.

The mechanism is the thing that makes it feel effortless. An MCP client's tools() method returns an iterable of tools, and PHP's spread operator drops them straight into your agent's tool list:

use Laravel\Mcp\Client;

public function tools(): iterable
{
    return [
        ...Client::web('https://api.githubcopilot.com/mcp/')
            ->withToken($this->user->github_token)
            ->tools(),
    ];
}

That single spread is the entire integration. The SDK automatically wraps each remote tool so the agent invokes it exactly like a tool you hand-wrote — no custom adapters, no manual schema translation.

Mixing remote and local tools

Because it's just an array, MCP tools and your own application tools live side by side. The agent doesn't know — or care — which is which:

use App\Ai\Tools\RandomNumberGenerator;
use Laravel\Mcp\Client;

public function tools(): iterable
{
    return [
        ...Client::web('https://mcp.example.com')
            ->withToken($token)
            ->tools(),

        new RandomNumberGenerator,
    ];
}

Three ways to connect

The client supports the connection styles you'd expect from a production framework:

  • Remote / HTTPClient::web('https://mcp.example.com')->withToken($token)->tools() for hosted servers like GitHub's Copilot MCP endpoint.
  • Named clientsMcp::client('github')->tools() to reference a server you've pre-configured, keeping endpoints and credentials out of your agent code.
  • Local processesClient::local('php', ['artisan', 'mcp:start'])->tools() to talk to an MCP server running as a separate process on the same machine.

Why this matters

MCP has quickly become the common language for connecting AI models to external tools and data. By baking a client into the framework, Laravel turns that ecosystem into something you reach for in a single line rather than a bespoke integration project. An agent that can file a GitHub issue, query a database server, or drive a third-party API is now a few characters of spread syntax away.

It also keeps the door open both directions: a Laravel app can expose its own MCP server and consume others, making it a natural hub in a larger network of agents and tools.

A note on trust

The convenience cuts both ways. When you spread a remote server's tools into an agent, you're granting that agent — and by extension the model behind it — the ability to act through those tools. Scope your tokens carefully, prefer named clients so credentials aren't scattered across agent classes, and treat third-party MCP servers with the same caution you'd apply to any external dependency that can take actions on your behalf.

Getting it

MCP client support lives in the Laravel AI SDK together with the Laravel MCP package. The AI SDK documentation covers the full picture — agents, structured output, embeddings, streaming, and the MCP client tools shown here — and the MCP client docs cover authentication options like bearer tokens and OAuth.

Source: Laravel AI SDK — MCP Tools documentation

Have a project in mind?

The same team behind these articles builds production platforms every day. Tell us what you're working on.

Let's connect [email protected]