img
AboutContactBlogGet in touch

5 min read

Getting Started with Laravel MCP: Build AI-Ready Servers for Your Laravel Apps

Interested in generating passive income? Join our partnership program and receive a commission on each new client referral. Learn more.

laravel mcp server
AI is no longer something developers experiment with on the side, it’s quickly becoming part of how we write, test, and even reason about code. And in the Laravel ecosystem, that shift isn’t happening quietly. The framework itself is evolving to make AI a first-class citizen in our workflow.

After introducing Laravel Boost, which brought AI assistance right into the development process, the Laravel team has taken an even bigger step with the Model Context Protocol (MCP) Server, a new open standard that lets your Laravel app talk to AI systems directly. It lets you expose your app’s functionality, routes, data, or logic as callable tools for AI clients like ChatGPT and Claude.

In this guide, we’ll look at what Laravel MCP is, how to install it, and how it connects your Laravel app to the growing world of AI integrations.

What is Laravel MCP?

At its core, Laravel MCP is about connection - between your application and the intelligent systems that are rapidly becoming part of everyday development. It’s a framework for building Model Context Protocol (MCP) servers right inside Laravel, turning your app into something AI clients can understand and interact with.

In practical terms, it gives developers a familiar Laravel-style way to:

  • Expose parts of their application - routes, logic, or data - to AI assistants.

  • Define structured tools, prompts, and resources that AI systems can safely use.

  • Integrate directly with local or web-based AI clients like ChatGPT, Claude, or Cursor.

Once configured, the workflow feels naturally Laravel-esque: clean syntax, expressive attributes, and a focus on developer experience.

Installation guide

Setting up Laravel MCP is straightforward and feels consistent with the rest of the Laravel ecosystem. In just a few steps, you can have an MCP server running and ready to communicate with AI clients.

Install MCP via Composer:

composer require laravel/mcp

Then, publish the default MCP routes:

php artisan vendor:publish --tag=ai-routes

This will create a routes/ai.php file. You’ll define your MCP servers there - these are the AI-accessible gateways to your app.

To create a server, use the make command:

php artisan make:mcp-server WeatherServer

This generates a new class in app/Mcp/Servers. It includes everything you need - from version info and LLM instructions to registered tools, resources, and prompts.

To make it available to AI clients, register it in routes/ai.php:

use App\Mcp\Servers\WeatherServer;
use Laravel\Mcp\Facades\Mcp;

Mcp::web('/mcp/weather', WeatherServer::class);

Exploring the Core Features

Laravel MCP revolves around three key building blocks:

  1. Tools
    Reusable actions that AI can call. These can do anything - from generating invoices to fetching weather data.
  2. Resources
    Static or dynamic content (like files, docs, or guidelines) that AI clients can read or reference.
  3. Prompts
    Predefined templates for consistent, structured AI interactions - perfect for standardized responses or reviews.

💡 Example: You could define a GetCurrentWeatherTool that accepts a location parameter, validates it, fetches data from an API, and returns a readable summary - all callable by any MCP client.

Smart Features & Integrations

One of the most useful aspects of Laravel MCP is how it aligns perfectly with Laravel’s design philosophy - expressive syntax, strong validation.

Highlights:

  • Works out of the box with Laravel Sanctum or Passport for authentication. 
  • Full support for dependency injection inside tools
  • JSON Schema builder for defining input validation.
  • Streaming responses via Server-Sent Events (SSE).
  •  Conditional registration so tools appear only when relevant.

It is worth noting that Laravel MCP’s philosophy matches that of LarAgent - both use structured AI-to-code interaction models. While MCP exposes tools to external AI clients, LarAgent focuses on running AI agents within Laravel. 

Together, they form a full ecosystem for both hosting and consuming intelligent agents.

Insights from Use

In practice, Laravel MCP feels like an extension of Laravel itself as it should be. The developer experience is familiar - make:mcp-tool, make:mcp-resource, and make:mcp-prompt feel just like Artisan’s core commands.

The ai.php routes file is another nice touch. You can assign middleware to MCP routes just as you would with your web routes - whether it’s auth:sanctum, throttle, or any custom middleware you rely on. It makes integrating security and access control into your AI endpoints feel effortless.

One of the features we’re most excited about is how Laravel MCP supports unit testing with PEST. You can write tests for your Tools, Resources, and Prompts just like you would for any other part of your app - the easiest way to ensure your MCP server behaves exactly as expected.

One small learning curve is designing meaningful schemas for AI - tools perform best when their inputs are clear and well-typed. Also, default validation error messages aren’t clear enough for AI Agents as feedback, so we had to define custom error messages for each property in schema.

Once that’s done, AI assistants interact naturally with your Laravel app: they can fetch resources, call methods, and even stream results returning the “Generator” instance.

Conclusion

Laravel MCP isn’t just another addition to the framework - it’s Laravel stepping confidently into the AI era. As intelligent systems become a bigger part of how we build and use software, MCP gives our applications a common language to communicate with them.

It stays true to Laravel’s spirit: clean syntax, clear structure, and developer experience at the center. Defining tools, resources, and prompts feels intuitive, and the built-in schema validation ensures every interaction between your app and AI clients remains safe and predictable.

Whether you’re building your own LarAgent-powered assistant or connecting your product to ChatGPT, Laravel MCP makes integration predictable, elegant, and future-proof.

img

Meet the authors

We are a 200+ people agency and provide product design, software development, and creative growth marketing services to companies ranging from fresh startups to established enterprises. Our work has earned us 100+ international awards, partnerships with Laravel, Vue, Meta, and Google, and the title of Georgia’s agency of the year in 2019 and 2021.

img
Contact us