From 202b95d90f7c08d56e138f49e66535f0fc3ce369 Mon Sep 17 00:00:00 2001 From: Kyrian Obikwelu Date: Thu, 1 May 2025 18:11:53 +0100 Subject: [PATCH 1/2] docs: Update README.md to clarify MCP element definition and usage of invokable classes --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 69218c6..905421a 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ The primary way to configure the MCP server in Laravel is through the `config/mc ### Defining MCP Elements -Define your MCP Tools, Resources, and Prompts as methods within PHP classes, decorated with attributes from the `php-mcp/server` package (`#[McpTool]`, `#[McpResource]`, `#[McpPrompt]`, etc.). +Define your MCP Tools, Resources, and Prompts by decorating methods **or invokable classes** with attributes from the `php-mcp/server` package (`#[McpTool]`, `#[McpResource]`, `#[McpPrompt]`, `#[McpResourceTemplate]`). Place these classes in a directory included in the `discovery.directories` config array (e.g., `app/Mcp/MyTools.php`). @@ -98,8 +98,8 @@ class MyTools } ``` -* **Dependency Injection:** Your classes' constructors will be resolved using Laravel's service container, so you can inject any application dependencies (like the `LoggerInterface` above). -* **Attribute Usage:** Refer to the [`php-mcp/server` README](https://github.com/php-mcp/server/blob/main/README.md#defining-mcp-elements-with-attributes) for detailed information on defining elements and formatting return values. +* **Dependency Injection:** Your classes' constructors (or invokable classes) will be resolved using Laravel's service container, so you can inject any application dependencies (like the `LoggerInterface` above). +* **Attribute Usage:** Refer to the [`php-mcp/server` README](https://github.com/php-mcp/server/blob/main/README.md#attributes-for-discovery) for detailed information on defining elements (both on methods and invokable classes) and formatting return values. ### Automatic Discovery (Development) vs. Manual Discovery (Production) From 44b8217a32cb8031bf2ed8c9000e007a24c33cba Mon Sep 17 00:00:00 2001 From: tsztodd <43433787+tsztodd@users.noreply.github.com> Date: Wed, 7 May 2025 02:16:30 +0800 Subject: [PATCH 2/2] feat: `McpServiceProvider` file and `loadElements` function not found --- README.md | 6 +++--- src/Commands/ListCommand.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 905421a..d278225 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ This package handles: ```bash composer require php-mcp/laravel ``` -2. The `LaravelMcpServiceProvider` will be automatically discovered and registered by Laravel. +2. The `McpServiceProvider` will be automatically discovered and registered by Laravel. 3. Publish the configuration file: ```bash - php artisan vendor:publish --provider="PhpMcp\Laravel\Server\LaravelMcpServiceProvider" --tag="mcp-config" + php artisan vendor:publish --provider="PhpMcp\Laravel\Server\McpServiceProvider" --tag="mcp-config" ``` This will create a `config/mcp.php` file where you can customize the server's behavior. @@ -249,4 +249,4 @@ The MIT License (MIT). Please see [License File](LICENSE) for more information. ## Support & Feedback -Please open an issue on the [GitHub repository](https://github.com/php-mcp/laravel) for bugs, questions, or feedback. \ No newline at end of file +Please open an issue on the [GitHub repository](https://github.com/php-mcp/laravel) for bugs, questions, or feedback. diff --git a/src/Commands/ListCommand.php b/src/Commands/ListCommand.php index cacba79..45b7daf 100644 --- a/src/Commands/ListCommand.php +++ b/src/Commands/ListCommand.php @@ -33,7 +33,7 @@ class ListCommand extends Command */ public function handle(Registry $registry): int { - $registry->loadElements(); // Ensure elements are loaded + $registry->loadElementsFromCache(); // Ensure elements are loaded $type = $this->argument('type'); $outputJson = $this->option('json');