Laravel Restify - Build APIs for Humans & AI Agents
Open Source โข Laravel Package โข MIT Licensed
Build APIs for<br>Humans & AI<br>Simultaneously
Transform your Laravel Eloquent models into JSON:API endpoints and MCP servers automatically.<br>Zero boilerplate. Pure results. Future-ready architecture.
Start Building Explore Code
terminal<br>composer require binaryk/laravel-restifyinstall
Input<br>// 1. Create your repository<br>class PostRepository extends Repository<br>public static string $model = Post::class;<br>// 2. Enable MCP for AI agents<br>Mcp::web('restify', RestifyServer::class);
Output
REST API<br>GET/api/restify/posts<br>POST/api/restify/posts<br>PATCH/api/restify/posts/{id}<br>DELETE/api/restify/posts/{id}
MCP TOOLS<br>๐ค posts-index-tool<br>๐ค posts-create-tool<br>๐ค posts-update-tool<br>๐ค posts-delete-tool
Zero Config
๐<br>JSON:API
๐ค<br>AI Ready
๐<br>Laravel Native
Package Overview<br>See Laravel Restify<br>In Action<br>A quick walkthrough of the package, what it does, and how it helps you expose Laravel models as APIs without the usual boilerplate.
๐ค AI-Powered Installation<br>Install with AI<br>Copy this prompt and paste it into Claude, ChatGPT, or any AI assistant
Install with AI<br>Copy prompt<br>## Install Laravel Restify in my Laravel project
Please help me install and set up Laravel Restify, a package that transforms Laravel Eloquent models into JSON:API endpoints and MCP servers for AI agents.
### Step 1: Install the package
Run this command in your terminal:
```shell<br>composer require binaryk/laravel-restify<br>```
### Step 2: Run the setup command
After installation, scaffold the API structure:
```shell<br>php artisan restify:setup<br>```
This command will:<br>- Publish the `config/restify.php` configuration file<br>- Create `providers/RestifyServiceProvider` and register it<br>- Create the `app/Restify` directory for repositories<br>- Generate an abstract `app/Restify/Repository.php` base class<br>- Scaffold `app/Restify/UserRepository` for immediate use<br>- Create `routes/ai.php` with commented MCP server configuration
### Step 3: Run migrations
Complete the setup by running migrations:
```shell<br>php artisan migrate<br>```
### Step 4: Test the API
Your API is now ready! Test it with:
```bash<br>GET /api/restify/users?perPage=10&page=1<br>```
### Step 5 (Optional): Enable MCP Server for AI Agents
To make your API accessible to AI agents like Claude Desktop:
1. Add the MCP server to your `config/ai.php` file:
```php<br>use Binaryk\LaravelRestify\MCP\RestifyServer;<br>use Laravel\Mcp\Facades\Mcp;
Mcp::web('restify', RestifyServer::class)<br>->middleware(['auth:sanctum'])<br>->name('mcp.restify');<br>```
2. Enable MCP tools in your repositories by adding the `HasMcpTools` trait:
```php<br>use Binaryk\LaravelRestify\MCP\Concerns\HasMcpTools;
#[Model(User::class)]<br>class UserRepository extends Repository<br>use HasMcpTools; // Enables MCP tools for AI agents
public function fields(RestifyRequest $request): array<br>return [<br>field('name')->required(),<br>field('email')->required(),<br>];<br>```
### Next Steps
After installation, please help me:<br>- Understand what was created during setup<br>- Learn how to create my first repository<br>- Test the API endpoints<br>- Optionally configure authentication with Sanctum
For more information, visit the Laravel Restify documentation at https://restify.binarcode.com
This prompt will guide an AI assistant to help you install and set up Laravel Restify in your project.
One Codebase, Infinite Possibilities<br>Write Once,<br>Deploy Everywhere<br>Transform your Laravel models into production-ready APIs and AI-compatible servers with zero configuration. The future of API development is here.
json-api.json
JSON:API Compliant<br>Automatically generates endpoints that follow JSON:API specifications with proper relationships, pagination, filtering, and sparse fieldsets.
"data": {<br>"id": "1",<br>"type": "posts",<br>"attributes": {<br>"title": "Laravel Restify",<br>"published_at": "2024-01-15"<br>},<br>"relationships": {<br>"author": {<br>"data": {"id": "1", "type": "users"}
PostPolicy.php
Policy-Based Auth<br>Built-in integration with Laravel's authorization system. Use policies for fine-grained access control on every endpoint.
class PostPolicy<br>public function index(User $user)<br>return $user->can('view posts');
public function store(User $user)<br>return $user->hasRole('admin');
api-request.http
Smart Filtering<br>Complex queries, sorting, filtering, and search across relationships without any extra configuration.
GET /api/restify/posts?<br>filter[title]=Laravel&<br>filter[status]=published&<br>sort=-created_at&<br>include=author,comments&<br>page[size]=10
routes/web.php
AI Agent Ready<br>Generate Model Context Protocol servers that allow AI agents to interact with your APIs using structured, type-safe tools.
// Enable MCP for AI agents<br>Mcp::web('restify', RestifyServer::class)<br>->middleware(['auth:sanctum'])<br>->name('mcp.restify');
UserRepository.php
Zero Configuration<br>Start building in seconds. Just create a repository class pointing to your model and you're ready.
class UserRepository extends Repository<br>public static...