larafony / mcp-assistant
AI-powered development assistant for Larafony framework - learn the framework, generate code, and build apps with zero friction
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/larafony/mcp-assistant
Requires
- php: >=8.5
- larafony/core: ^2.0
- larafony/docs: ^1.0
Requires (Dev)
- phpstan/phpstan: ^2.1.30
- phpunit/phpunit: ^12.4.0
README
AI-powered development assistant for the Larafony PHP 8.5 framework. Provides scaffolding tools, documentation resources, and learning prompts accessible via Model Context Protocol (MCP).
Quick Start - No Installation Required!
You don't need to clone any repository or install anything locally. Larafony provides a public MCP server that you can connect to directly from your AI assistant.
Connect to Public MCP Server
Add the Larafony MCP server URL to your AI assistant:
https://larafony.com/mcp
This gives you instant access to:
- Complete framework documentation (36 topics)
- Project structure information
- Learning prompts and debugging helpers
AI Assistant Configuration
Claude Desktop
Edit your configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/claude/claude_desktop_config.json
Option A: Remote Server (Recommended)
{
"mcpServers": {
"larafony": {
"url": "https://larafony.com/mcp"
}
}
}
Option B: Local Development Server
{
"mcpServers": {
"larafony": {
"command": "php",
"args": ["/path/to/your/project/bin/larafony", "mcp:start"]
}
}
}
Claude Desktop MCP Documentation
Cursor IDE
Open MCP settings: Ctrl+Shift+P → "Cursor Settings" → MCP section.
Or edit ~/.cursor/mcp.json (global) or .cursor/mcp.json (project):
Option A: Remote Server (Recommended)
{
"mcpServers": {
"larafony": {
"url": "https://larafony.com/mcp"
}
}
}
Option B: Local Development Server
{
"mcpServers": {
"larafony": {
"command": "php",
"args": ["/path/to/your/project/bin/larafony", "mcp:start"]
}
}
}
Claude Code CLI
Option A: Remote Server (Recommended)
claude mcp add larafony --url https://larafony.com/mcp --scope user
Option B: Local Development Server
claude mcp add larafony --scope user -- php /path/to/your/project/bin/larafony mcp:start
Useful commands:
claude mcp list # List all configured servers claude mcp remove larafony # Remove server claude mcp get larafony # Test server connection
Scope options:
--scope local- Current project only (default)--scope project- Shared via.mcp.json--scope user- All your projects
OpenAI Codex
Edit ~/.codex/config.toml:
[mcp.larafony] url = "https://larafony.com/mcp"
Or add via CLI:
codex mcp add larafony --url https://larafony.com/mcp
ChatGPT
ChatGPT does not currently support MCP servers natively. Use Claude Desktop, Cursor, Claude Code, or Codex instead.
Local Installation (For Development)
If you want to run the MCP assistant locally with full scaffolding tools:
Requirements
- PHP 8.5+
- Larafony Core 2.0+
- Composer
Installation
composer require larafony/mcp-assistant
Register the service provider in bootstrap/app.php:
use Larafony\McpAssistant\McpAssistantServiceProvider; $app->withServiceProviders([ // ... other providers McpAssistantServiceProvider::class ]);
Configuration
Create or update config/mcp.php:
<?php return [ 'name' => env('APP_NAME', 'Larafony') . ' Assistant', 'version' => '1.0.0', 'instructions' => 'Larafony PHP 8.5 framework assistant.', 'discovery' => [ 'path' => base_path(), 'dirs' => [ 'src', 'vendor/larafony/mcp-assistant/src/Tools', 'vendor/larafony/mcp-assistant/src/Resources', 'vendor/larafony/mcp-assistant/src/Prompts', ], ], // Disable course hints in learning prompts (for course owners) 'disable_course_hints' => env('MCP_DISABLE_COURSE_HINTS', false), ];
Available Tools (Local Installation Only)
Scaffolding tools require local installation and create files in your project.
| Tool | Description | Parameters |
|---|---|---|
make_controller |
Generate controller with routes | name, resource (bool) |
make_model |
Generate ORM model | name, migration (bool), fillable (string[]) |
make_view |
Generate Blade view | name, layout, title |
make_job |
Generate queueable job | name |
make_migration |
Generate database migration | name, table |
make_command |
Generate console command | name, command_name |
Tool Examples
Create a resource controller:
"Create a PostController with all CRUD methods"
Tool: make_controller
Parameters: { "name": "PostController", "resource": true }
Result: Created src/Controllers/PostController.php with index, show, store, update, destroy methods
Create a model with migration:
"Create a Comment model with migration"
Tool: make_model
Parameters: { "name": "Comment", "migration": true }
Result: Created src/Models/Comment.php and database/migrations/..._create_comments_table.php
Available Resources
Resources are available both on the public server and local installations.
Project Structure
| URI | Name | Description |
|---|---|---|
project://structure |
project-structure |
Complete project directory overview |
project://controllers |
project-controllers |
List of controllers with their routes |
project://models |
project-models |
List of ORM models |
Framework Documentation
Getting Started
| URI | Name | Description |
|---|---|---|
docs://getting-started |
getting-started-docs |
Introduction to Larafony framework |
docs://bootstrap |
bootstrap-docs |
How to bootstrap a Larafony application |
docs://structure |
structure-docs |
Larafony project directory structure |
HTTP Layer
| URI | Name | Description |
|---|---|---|
docs://controllers |
controllers-docs |
Controllers and routing with #[Route] attributes |
docs://middleware |
middleware-docs |
PSR-15 middleware |
docs://http-client |
http-client-docs |
PSR-18 HTTP client |
Views
| URI | Name | Description |
|---|---|---|
docs://views |
views-docs |
Blade views with components |
docs://validation |
validation-docs |
DTO validation |
docs://inertia |
inertia-docs |
Inertia.js + Vue SPAs |
Database
| URI | Name | Description |
|---|---|---|
docs://models |
models-docs |
ORM models with property hooks |
docs://query-builder |
query-builder-docs |
Query builder |
docs://schema-builder |
schema-builder-docs |
Migrations and schema |
Architecture
| URI | Name | Description |
|---|---|---|
docs://container |
container-docs |
PSR-11 dependency injection |
docs://config |
config-docs |
Configuration management |
docs://cache |
cache-docs |
PSR-6 caching |
docs://auth |
auth-docs |
RBAC authorization |
Security
| URI | Name | Description |
|---|---|---|
docs://encryption |
encryption-docs |
Data encryption |
docs://session |
session-docs |
Sessions and cookies |
Utilities
| URI | Name | Description |
|---|---|---|
docs://events |
events-docs |
PSR-14 event system |
docs://logging |
logging-docs |
PSR-3 logging |
Async
| URI | Name | Description |
|---|---|---|
docs://queue |
queue-docs |
Background jobs and queues |
docs://websockets |
websockets-docs |
Real-time communication |
Communication
| URI | Name | Description |
|---|---|---|
docs://mail |
mail-docs |
Email sending |
Debugging
| URI | Name | Description |
|---|---|---|
docs://error-handling |
error-handling-docs |
Error and exception handling |
docs://console-debugging |
console-debugging-docs |
Console debugging |
docs://debugbar |
debugbar-docs |
PHP Debug Bar |
Bridges (Third-party Integrations)
| URI | Name | Description |
|---|---|---|
docs://bridges |
bridges-docs |
Overview of integrations |
docs://bridge-carbon |
bridge-carbon-docs |
Carbon date/time |
docs://bridge-flysystem |
bridge-flysystem-docs |
Flysystem file storage |
docs://bridge-guzzle |
bridge-guzzle-docs |
Guzzle HTTP client |
docs://bridge-monolog |
bridge-monolog-docs |
Monolog logging |
docs://bridge-phpdotenv |
bridge-phpdotenv-docs |
PHP dotenv |
docs://bridge-symfony-mailer |
bridge-symfony-mailer-docs |
Symfony Mailer |
docs://bridge-twig |
bridge-twig-docs |
Twig templates |
docs://bridge-smarty |
bridge-smarty-docs |
Smarty templates |
docs://bridge-debugbar |
bridge-debugbar-docs |
Debug Bar integration |
Available Prompts
Learning Prompts
| Prompt | Description | Parameters |
|---|---|---|
learn_larafony |
Guided topic learning | topic (routing, models, controllers, views, middleware, validation, testing, overview) |
build_feature |
Step-by-step feature building | feature (description of what to build) |
Debugging Prompts
| Prompt | Description | Parameters |
|---|---|---|
debug_error |
Debug error messages | error, file (optional) |
debug_route |
Debug routing issues | path, method, expected (optional) |
debug_model |
Debug ORM/database issues | model, issue |
debug_view |
Debug Blade view issues | view, issue |
Prompt Examples
Learn about models:
"Teach me about Larafony ORM models"
Prompt: learn_larafony
Parameters: { "topic": "models" }
Result: Detailed explanation of property hooks, #[BelongsTo], #[HasMany], #[BelongsToMany], #[CastUsing]
Build a feature:
"Help me build user authentication"
Prompt: build_feature
Parameters: { "feature": "user authentication" }
Result: Step-by-step guidance covering models, controllers, routes, middleware, and views
Larafony Conventions
This assistant understands and follows Larafony conventions:
Routing
use Larafony\Framework\Routing\Advanced\Attributes\Route; class UserController extends Controller { #[Route('/users', 'GET')] public function index(): ResponseInterface { ... } #[Route('/users/<id:\d+>', 'GET')] public function show(int $id): ResponseInterface { ... } }
Models
use Larafony\Framework\Database\ORM\Model; use Larafony\Framework\Database\ORM\Attributes\BelongsTo; use Larafony\Framework\Database\ORM\Attributes\HasMany; class Post extends Model { public ?string $title { get => $this->title ?? null; set { $this->title = $value; $this->markPropertyAsChanged('title'); } } #[BelongsTo(related: User::class, foreign_key: 'user_id')] public ?User $author { get => $this->relations->getRelation('author'); } #[HasMany(related: Comment::class, foreign_key: 'post_id')] public array $comments { get => $this->relations->getRelation('comments'); } }
Views
<x-Layout title="Posts"> <h1>All Posts</h1> @foreach($posts as $post) <x-PostCard :post="$post" /> @endforeach </x-Layout>
Development
Adding New Tools
Create a class in src/Tools/:
<?php namespace Larafony\McpAssistant\Tools; use Mcp\Capability\Attribute\McpTool; use Mcp\Capability\Attribute\Schema; use Mcp\Schema\Content\TextContent; class MyCustomTool { #[McpTool( name: 'my_custom_tool', description: 'Description for AI', )] public function execute( #[Schema(description: 'Parameter description', type: 'string')] string $param, ): TextContent { return new TextContent('Result'); } }
Adding New Resources
Create a class in src/Resources/:
<?php namespace Larafony\McpAssistant\Resources; use Mcp\Capability\Attribute\McpResource; class MyResource { #[McpResource( uri: 'my://resource', name: 'my-resource', // alphanumeric, underscores, hyphens only description: 'Description for AI', mimeType: 'text/plain', )] public function getData(): string // Return string, SDK wraps it { return 'Resource content'; } }
Adding New Prompts
Create a class in src/Prompts/:
<?php namespace Larafony\McpAssistant\Prompts; use Mcp\Capability\Attribute\McpPrompt; use Mcp\Capability\Attribute\Schema; use Mcp\Schema\Content\PromptMessage; use Mcp\Schema\Content\TextContent; use Mcp\Schema\Enum\Role; class MyPrompt { /** * @return array<int, PromptMessage> */ #[McpPrompt( name: 'my_prompt', description: 'Description for AI', )] public function generate( #[Schema(description: 'Input parameter', type: 'string')] string $input, ): array { return [ new PromptMessage( role: Role::User, content: new TextContent("Prompt with {$input}"), ), ]; } }
Running Tests
cd bridges/larafony-mcp-assistant composer test
Learn How It's Built - From Scratch
Interested in how Larafony is built step by step?
Check out my full PHP 8.5 course, where I explain everything from architecture to implementation - no magic, just clean code.
Get it now at masterphp.eu
License
MIT License. Larafony-mcp-assistant is open-sourced software licensed under the MIT license.
Links
- Larafony Framework
- MCP SDK
- Model Context Protocol
- masterphp.eu - Full tutorials and documentation