SKILL.blade.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ---
  2. name: mcp-development
  3. description: "Use this skill for Laravel MCP development. Trigger when creating or editing MCP tools, resources, prompts, servers, or UI apps in Laravel projects. Covers: artisan make:mcp-* generators, routes/ai.php, Tool/Resource/Prompt/AppResource classes, schema validation, shouldRegister(), OAuth setup, URI templates, read-only attributes, MCP debugging, MCP UI apps, the x-mcp::app Blade component, createMcpApp(), default AppResource handle() auto-infers view from class name, Response::view(), AppMeta/Csp/Permissions/appMeta() configuration, #[RendersApp] attribute, Library enum for CDN libraries (Tailwind, Alpine), and host theming via CSS variables. Use this whenever the user mentions MCP apps, MCP UI, interactive MCP resources, styling MCP apps with Tailwind or Alpine, or building visual interfaces for AI agents."
  4. license: MIT
  5. metadata:
  6. author: laravel
  7. ---
  8. @php
  9. /** @var \Laravel\Boost\Install\GuidelineAssist $assist */
  10. @endphp
  11. # MCP Development
  12. ## Documentation
  13. Use `search-docs` for detailed Laravel MCP patterns and documentation.
  14. For MCP UI apps (interactive HTML resources), read `references/app.md` — it covers the full architecture, host theming CSS variables, tool-to-UI linking patterns, library scripts (Tailwind, Alpine via `Library`), and real-world examples.
  15. ## Basic Usage
  16. Register MCP servers in `routes/ai.php`:
  17. @boostsnippet("Register MCP Server", "php")
  18. use Laravel\Mcp\Facades\Mcp;
  19. Mcp::web();
  20. @endboostsnippet
  21. ### Creating MCP Primitives
  22. ```bash
  23. {{ $assist->artisanCommand('make:mcp-tool ToolName') }} # Create a tool
  24. {{ $assist->artisanCommand('make:mcp-resource ResourceName') }} # Create a resource
  25. {{ $assist->artisanCommand('make:mcp-prompt PromptName') }} # Create a prompt
  26. {{ $assist->artisanCommand('make:mcp-server ServerName') }} # Create a server
  27. {{ $assist->artisanCommand('make:mcp-app-resource DashboardApp') }} # Create a UI app (2 files)
  28. ```
  29. After creating primitives, register them in your server's `$tools`, `$resources`, or `$prompts` properties.
  30. ### Tools
  31. @boostsnippet("MCP Tool Example", "php")
  32. use Illuminate\Json\Schema\JsonSchema;
  33. use Laravel\Mcp\Request;
  34. use Laravel\Mcp\Response;
  35. use Laravel\Mcp\Server\Tool;
  36. class MyTool extends Tool
  37. {
  38. protected string $description = 'Describe what this tool does';
  39. public function schema(JsonSchema $schema): array
  40. {
  41. return [
  42. 'name' => $schema->string()->description('The name parameter')->required(),
  43. ];
  44. }
  45. public function handle(Request $request): Response
  46. {
  47. $request->validate(['name' => 'required|string']);
  48. return Response::text('Hello, '.$request->get('name'));
  49. }
  50. }
  51. @endboostsnippet
  52. ### Registering Primitives in a Server
  53. @boostsnippet("Register Primitives in MCP Server", "php")
  54. use Laravel\Mcp\Server;
  55. class AppServer extends Server
  56. {
  57. protected array $tools = [
  58. \App\Mcp\Tools\MyTool::class,
  59. ];
  60. protected array $resources = [
  61. \App\Mcp\Resources\MyResource::class,
  62. ];
  63. protected array $prompts = [
  64. \App\Mcp\Prompts\MyPrompt::class,
  65. ];
  66. }
  67. @endboostsnippet
  68. ## MCP UI Apps
  69. For MCP UI apps, read `references/app.md` — it covers quick start examples, full architecture, AppMeta/Csp/Permissions, `#[RendersApp]` tool linking, library scripts (Tailwind/Alpine via `Library`), host theming CSS variables, and real-world patterns.
  70. ## Verification
  71. 1. Check `routes/ai.php` for proper registration
  72. 2. Test tool via MCP client
  73. ## Common Pitfalls
  74. - Running `mcp:start` command (it hangs waiting for input)
  75. - Using HTTPS locally with Node-based MCP clients
  76. - Not using `search-docs` for the latest MCP documentation
  77. - Not registering MCP server routes in `routes/ai.php`
  78. - Do not register `ai.php` in `bootstrap.php`; it is registered automatically
  79. - OAuth registration supports custom URI schemes (e.g., `cursor://`, `vscode://`) for native desktop clients via `mcp.custom_schemes` config