larafony/mcp-assistant
Composer 安装命令:
composer require larafony/mcp-assistant
包简介
AI-powered development assistant for Larafony framework - learn the framework, generate code, and build apps with zero friction
README 文档
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
larafony/mcp-assistant 适用场景与选型建议
larafony/mcp-assistant 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「scaffolding」 「assistant」 「learning」 「ai」 「code-generation」 「mcp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 larafony/mcp-assistant 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 larafony/mcp-assistant 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 larafony/mcp-assistant 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple and elegant tools for build web application.
Magento MCP AI Assistant - A powerful AI assistant for Magento 2 that helps with store data queries and management
PHP framework for handling workflows and conversational services like Amazon Alexa
2020 PHP: A showcase and classroom for the cutting edge features of PHP 8
An introduction to machine learning in Rubix ML using the famous Iris dataset and the K Nearest Neighbors classifier.
Zego Server Assistant
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 37
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-23