| Install | |
|---|---|
composer require binaryk/laravel-restify |

One Codebase. REST for Humans, MCP for AI Agents.
Laravel Restify turns your Eloquent models into both JSON:API endpoints and MCP servers -- automatically. Build once, and instantly serve APIs that work seamlessly for developers, apps, and AI agents.
Traditional API development requires separate implementations for different consumers. Laravel Restify changes that:
composer require binaryk/laravel-restify
1. Setup the package:
php artisan restify:setup
2. Create your first repository:
php artisan restify:repository PostRepository --all
3. Enable MCP for AI agents (optional):
Add to your config/ai.php:
use Binaryk\LaravelRestify\MCP\RestifyServer;
use Laravel\Mcp\Facades\Mcp;
Mcp::web('restify', RestifyServer::class)
->middleware(['auth:sanctum'])
->name('mcp.restify');
That's it! Your API now serves both:
For Humans (JSON:API):
GET /api/restify/posts
POST /api/restify/posts
PUT /api/restify/posts/1
DELETE /api/restify/posts/1
For AI Agents (MCP):
GET /mcp/restify # Tool definitions and capabilities
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
use Binaryk\LaravelRestify\Repositories\Repository;
use Binaryk\LaravelRestify\Attributes\Model;
#[Model(Post::class)]
class PostRepository extends Repository
{
public function fields(RestifyRequest $request): array
{
return [
field('title')->rules('required', 'string', 'max:255'),
textarea('content')->rules('required'),
field('author')->readonly(),
datetime('published_at')->nullable(),
];
}
}
This single definition automatically provides:
Here's what you get from one repository definition:
GET /api/restify/posts
{
"data": [
{
"id": "1",
"type": "posts",
"attributes": {
"title": "Laravel Restify Guide",
"content": "Build APIs fast...",
"published_at": "2024-01-15"
}
}
],
"links": {
"self": "/api/restify/posts",
"next": "/api/restify/posts?page=2"
}
}
GET /mcp/restify # Tool definitions for AI agents
{
"tools": [
{
"name": "posts-index-tool",
"description": "Retrieve a paginated list of Post records from the posts repository with filtering, sorting, and search capabilities.",
"inputSchema": {
"type": "object",
"properties": {
"page": {
"type": "number",
"description": "Page number for pagination"
},
"perPage": {
"type": "number",
"description": "Number of posts per page"
},
"search": {
"type": "string",
"description": "Search term to filter posts by title or content"
},
"sort": {
"type": "string",
"description": "Sorting criteria (e.g., sort=title or sort=-published_at for descending)"
},
"title": {
"type": "string",
"description": "Filter by exact match for title (e.g., title=Laravel). Accepts negation with -title=value"
},
"published_at": {
"type": "string",
"description": "Filter by publication date (e.g., published_at=2024-01-15)"
}
}
}
}
]
}
All generated from this simple repository:
#[Model(Post::class)]
class PostRepository extends Repository
{
use HasMcpTools;
public function fields(RestifyRequest $request): array
{
return [
field('title')->required()->matchable(),
field('content'),
field('published_at')->rules('date')->matchable(),
];
}
}
Laravel Restify Boost is a development companion that provides MCP server capabilities to help you build Restify APIs faster with AI assistance.
Repository: laravel-restify-boost
Features:
Installation:
composer require --dev binarcode/laravel-restify-boost
Need a production-ready starting point? Check out Restify Templates for complete API starter kits with authentication, permissions, and team management.
composer test
Please see CONTRIBUTING for details.
If you discover any security related issues, please email eduard.lupacescu@binarcode.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.