Laravel MCP logo

Laravel MCP

by mohamedahmed01

A Laravel package for implementing the Model Context Protocol (MCP) in Laravel applications. This protocol facilitates communication between AI models and Laravel applications through standardized interfaces.

View on GitHub

Last updated: N/A

What is Laravel MCP?

Laravel MCP is a package that provides a standardized way for Laravel applications to communicate with AI models using the Model Context Protocol (MCP). It offers multiple transport options and a comprehensive set of features for managing tools, resources, prompts, progress tracking, and logging.

How to use Laravel MCP?

To use Laravel MCP, install the package via Composer, publish the configuration, and configure the environment variables. Then, you can start the server using the php artisan mcp:serve command. The package provides various classes and facades for registering tools, managing resources, handling prompts, and sending progress updates and logs. Refer to the documentation for detailed usage examples.

Key features of Laravel MCP

  • Multiple Transport Options (HTTP, WebSocket, Stdio)

  • Tool registration and execution

  • Resource management with URI-based access

  • Template-based prompt system

  • Real-time progress tracking

  • Structured logging system

Use cases of Laravel MCP

  • Building AI-powered applications with Laravel

  • Integrating AI models into existing Laravel projects

  • Creating code review assistants

  • Developing tools for analyzing and processing data

FAQ from Laravel MCP

What is the Model Context Protocol (MCP)?

MCP is a protocol that facilitates communication between AI models and applications through standardized interfaces.

What are the system requirements for Laravel MCP?

PHP 8.1+, Laravel 10.x, Composer 2.x, OpenSSL, PDO, Mbstring, XML, Ctype, JSON PHP Extensions, ReactPHP, and ext-json.

How do I register a custom tool?

Use the MCP::tool() method to register a tool with parameters and a callback function to handle the tool call.

How do I manage resources?

Use the MCP::resource() method to register a resource with a URI pattern and a callback function to handle resource requests.

How do I send progress updates?

Use the MCP::sendProgress() method to send real-time progress updates with a token and total progress.