Skip to content

Commit 522a5da

Browse files
committed
fix: docs
1 parent 19ed1ab commit 522a5da

File tree

3 files changed

+645
-120
lines changed

3 files changed

+645
-120
lines changed

README.md

Lines changed: 165 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -7,150 +7,236 @@
77
<a href="https://packagist.org/packages/binaryk/laravel-restify"><img src="https://poser.pugx.org/binaryk/laravel-restify/license.svg" alt="License"></a>
88
</p>
99

10-
The first Laravel API library for Ai Agents and Humans with the same codebase.
10+
# Unified Laravel API Layer for Humans and AI
1111

12-
Restify is a customizable Laravel [JSON:API](https://jsonapi.org) and MCP Server library.
12+
**One Codebase. REST for Humans, MCP for AI Agents.**
1313

14-
<div>
15-
<a href="https://restifytemplates.com">
16-
<img alt="Save weeks of API development" src="/docs-v2/static/starter-kit.png">
17-
</a>
18-
</div>
14+
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.
1915

20-
## ⚡ Laravel Restify Templates - Save Weeks of Development
16+
## 🚀 The Power of One Codebase
2117

22-
Looking to 10x your API development speed? Check out our production-ready API templates at [RestifyTemplates.com](https://restifytemplates.com). Get complete authentication, roles & permissions, team management, and more - all built on Laravel Restify. Zero configuration needed. Deploy in minutes instead of weeks.
18+
Traditional API development requires separate implementations for different consumers. Laravel Restify changes that:
2319

24-
## Installation
20+
- **👥 Humans** get full-featured JSON:API endpoints
21+
- **🤖 AI Agents** get structured MCP (Model Context Protocol) servers
22+
- **🔒 Same Rules** - All authentication, authorization, and policies apply to both
23+
- **📝 One Definition** - Write your repository once, serve everywhere
24+
25+
## Key Features
26+
27+
- **JSON:API Endpoints** - Full [JSON:API](https://jsonapi.org) specification compliance
28+
- **MCP Server Generation** - Automatic AI agent interfaces with tool definitions
29+
- **Unified Authorization** - Laravel policies protect both human and AI access
30+
- **Search & Filtering** - Powerful query capabilities for all consumers
31+
- **Authentication** - Laravel Sanctum integration for secure access
32+
- **GraphQL Support** - Auto-generated GraphQL schemas
33+
- **Field Validation** - Consistent validation rules across all interfaces
2534

26-
You can install the package via composer:
35+
## Installation
2736

2837
```bash
2938
composer require binaryk/laravel-restify
3039
```
3140

32-
## Playground
33-
34-
You can find a playground in the [Restify Demo GitHub repository](https://github.com/BinarCode/restify-demo).
35-
36-
## Videos
37-
38-
If you are a visual learner, checkout [our video course](https://www.binarcode.com/learn/restify) for the Laravel Restify.
39-
40-
## Quick start
41-
42-
Setup package:
41+
## Quick Start
4342

43+
**1. Setup the package:**
4444
```bash
4545
php artisan restify:setup
4646
```
4747

48-
Generate repository:
49-
48+
**2. Create your first repository:**
5049
```bash
51-
php artisan restify:repository Dream --all
50+
php artisan restify:repository PostRepository --all
5251
```
5352

54-
Now you have the REST CRUD over dreams and this beautiful repository:
55-
56-
<p align="center"><img src="/docs-v2/static/tile.png"></p>
53+
**3. Enable MCP for AI agents (optional):**
5754

58-
Now you can go into Postman and check it out:
55+
Add to your `config/ai.php`:
56+
```php
57+
use Binaryk\LaravelRestify\MCP\RestifyServer;
58+
use Laravel\Mcp\Facades\Mcp;
5959

60-
```bash
61-
GET: http://laravel.test/api/restify/dreams
60+
Mcp::web('restify', RestifyServer::class)
61+
->middleware(['auth:sanctum'])
62+
->name('mcp.restify');
6263
```
6364

64-
```bash
65-
POST: http://laravel.test/api/restify/dreams
66-
```
65+
**That's it!** Your API now serves both:
6766

67+
**For Humans (JSON:API):**
6868
```bash
69-
GET: http://laravel.test/api/restify/dreams/1
69+
GET /api/restify/posts
70+
POST /api/restify/posts
71+
PUT /api/restify/posts/1
72+
DELETE /api/restify/posts/1
7073
```
7174

75+
**For AI Agents (MCP):**
7276
```bash
73-
PUT: http://laravel.test/api/restify/dreams/1
77+
GET /mcp/restify # Tool definitions and capabilities
7478
```
7579

76-
```bash
77-
DELETE: http://laravel.test/api/restify/dreams/1
78-
```
80+
## Example Repository
7981

80-
## 🤖 AI-Powered Development with MCP
82+
```php
83+
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
84+
use Binaryk\LaravelRestify\Repositories\Repository;
85+
use Binaryk\LaravelRestify\Attributes\Model;
8186

82-
Transform your existing Laravel Restify API into an **MCP-enabled powerhouse in minutes**! Laravel Restify's Model Context Protocol integration allows AI agents to interact directly with your API resources through structured tool interfaces.
87+
#[Model(Post::class)]
88+
class PostRepository extends Repository
89+
{
90+
public function fields(RestifyRequest $request): array
91+
{
92+
return [
93+
field('title')->rules('required', 'string', 'max:255'),
94+
textarea('content')->rules('required'),
95+
field('author')->readonly(),
96+
datetime('published_at')->nullable(),
97+
];
98+
}
99+
}
100+
```
83101

84-
> **🔥 Transform Your API in Minutes!** Add one trait to your Repository class and register one route - that's it! Your entire API becomes AI-agent accessible with full security and authorization intact.
102+
This single definition automatically provides:
103+
- ✅ JSON:API CRUD endpoints with validation
104+
- ✅ MCP tools for AI agents with the same validation
105+
- ✅ Authorization policies applied to both interfaces
106+
- ✅ Search and filtering capabilities for all consumers
85107

86-
**Quick Setup (2 steps):**
108+
## One Codebase, Two Outputs
87109

88-
1. **Add the trait to your Repository:**
89-
```php
90-
use Binaryk\LaravelRestify\MCP\Concerns\HasMcpTools;
110+
Here's what you get from one repository definition:
91111

92-
class PostRepository extends Repository
112+
### For Humans (JSON:API Response)
113+
```bash
114+
GET /api/restify/posts
115+
```
116+
117+
```json
93118
{
94-
use HasMcpTools; // ✨ This enables MCP for this resource
119+
"data": [
120+
{
121+
"id": "1",
122+
"type": "posts",
123+
"attributes": {
124+
"title": "Laravel Restify Guide",
125+
"content": "Build APIs fast...",
126+
"published_at": "2024-01-15"
127+
}
128+
}
129+
],
130+
"links": {
131+
"self": "/api/restify/posts",
132+
"next": "/api/restify/posts?page=2"
133+
}
95134
}
96135
```
97136

98-
2. **Register the MCP server in `routes/ai.php`:**
99-
```php
100-
use Laravel\Mcp\Facades\Mcp;
101-
use Binaryk\LaravelRestify\MCP\RestifyServer;
137+
### For AI Agents (MCP Tool Definition)
138+
```bash
139+
GET /mcp/restify # Tool definitions for AI agents
140+
```
102141

103-
Mcp::web('restify', RestifyServer::class)->middleware(['auth:sanctum']);
142+
```json
143+
{
144+
"tools": [
145+
{
146+
"name": "posts-index-tool",
147+
"description": "Retrieve a paginated list of Post records from the posts repository with filtering, sorting, and search capabilities.",
148+
"inputSchema": {
149+
"type": "object",
150+
"properties": {
151+
"page": {
152+
"type": "number",
153+
"description": "Page number for pagination"
154+
},
155+
"perPage": {
156+
"type": "number",
157+
"description": "Number of posts per page"
158+
},
159+
"search": {
160+
"type": "string",
161+
"description": "Search term to filter posts by title or content"
162+
},
163+
"sort": {
164+
"type": "string",
165+
"description": "Sorting criteria (e.g., sort=title or sort=-published_at for descending)"
166+
},
167+
"title": {
168+
"type": "string",
169+
"description": "Filter by exact match for title (e.g., title=Laravel). Accepts negation with -title=value"
170+
},
171+
"published_at": {
172+
"type": "string",
173+
"description": "Filter by publication date (e.g., published_at=2024-01-15)"
174+
}
175+
}
176+
}
177+
}
178+
]
179+
}
104180
```
105181

106-
**That's it!** Your API is now AI-agent ready with automatic tool generation for CRUD operations, actions, and getters.
182+
**All generated from this simple repository:**
183+
```php
184+
#[Model(Post::class)]
185+
class PostRepository extends Repository
186+
{
187+
use HasMcpTools;
188+
189+
public function fields(RestifyRequest $request): array
190+
{
191+
return [
192+
field('title')->required()->matchable(),
193+
field('content'),
194+
field('published_at')->rules('date')->matchable(),
195+
];
196+
}
197+
}
198+
```
107199

108200
## Restify Boost
109201

110-
Laravel Restify provides an MCP (Model Context Protocol) server designed for developers working with Laravel Restify APIs. This server enables AI agents to access documentation, create repositories, actions, and getters through structured tools.
111-
112-
**Repository**: [https://github.com/BinarCode/laravel-restify-boost](https://github.com/BinarCode/laravel-restify-boost)
202+
**Laravel Restify Boost** is a development companion that provides MCP server capabilities to help you build Restify APIs faster with AI assistance.
113203

114-
### Features
204+
**Repository:** [laravel-restify-boost](https://github.com/BinarCode/laravel-restify-boost)
115205

116-
- **Documentation Access**: Query Laravel Restify documentation directly
117-
- **Repository Generation**: Create new repositories with proper structure
118-
- **Action Creation**: Generate custom actions for your API resources
119-
- **Getter Development**: Build custom getters for data retrieval
120-
- **Code Examples**: Get contextual code examples and best practices
121-
122-
### Installation
206+
**Features:**
207+
- Documentation access for AI agents
208+
- Repository and action generation assistance
209+
- Code examples and best practices
210+
- Integration with Claude Desktop and other AI tools
123211

212+
**Installation:**
124213
```bash
125214
composer require --dev binarcode/laravel-restify-boost
126-
php artisan restify-boost:install
127215
```
128216

129-
### Usage with AI Agents
217+
## Templates
130218

131-
Configure your AI agent (Claude Desktop, etc.) to use the MCP server for enhanced Laravel Restify development assistance.
219+
Need a production-ready starting point? Check out [Restify Templates](https://restifytemplates.com) for complete API starter kits with authentication, permissions, and team management.
132220

133-
## Usage
221+
## Resources
134222

135-
See the [official documentation](https://restify.binarcode.com).
223+
- **[Documentation](https://restify.binarcode.com)** - Complete guides and API reference
224+
- **[Demo Repository](https://github.com/BinarCode/restify-demo)** - Working example
225+
- **[Video Course](https://www.binarcode.com/learn/restify)** - Visual learning resource
136226

137-
### Testing
227+
## Testing
138228

139-
``` bash
229+
```bash
140230
composer test
141231
```
142232

143-
### Changelog
144-
145-
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
146-
147233
## Contributing
148234

149235
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
150236

151-
### Security
237+
## Security
152238

153-
If you discover any security related issues, please email [email protected] or [message me on twitter](https://twitter.com/LupacescuEuard) instead of using the issue tracker.
239+
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
154240

155241
## Credits
156242

@@ -160,5 +246,4 @@ If you discover any security related issues, please email eduard.lupacescu@binar
160246

161247
## License
162248

163-
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
164-
249+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

0 commit comments

Comments
 (0)