Skip to content

Commit 7c66ef5

Browse files
committed
Merge branch 'fix/run-actions-mcp' of github.com:BinarCode/laravel-restify into fix/run-actions-mcp
2 parents 545d306 + a4f801f commit 7c66ef5

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

src/MCP/Tools/Operations/ActionTool.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,12 @@ public function handle(Request $request): Response
105105
// For show actions with single ID, set the route parameter
106106
if ($id = $mcpRequest->input('id')) {
107107
$mcpRequest->setRouteResolver(function () use ($id) {
108-
return new class($id) {
108+
return new class($id)
109+
{
109110
public function __construct(private $id) {}
110-
public function parameter($key, $default = null) {
111+
112+
public function parameter($key, $default = null)
113+
{
111114
return $key === 'repositoryId' ? $this->id : $default;
112115
}
113116
};

tests/Fixtures/Post/PublishPostAction.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Binaryk\LaravelRestify\Actions\Action;
66
use Binaryk\LaravelRestify\Http\Requests\ActionRequest;
77
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
8-
use Binaryk\LaravelRestify\MCP\Requests\McpRequestable;
98
use Illuminate\Http\JsonResponse;
109
use Illuminate\Support\Collection;
1110

tests/MCP/McpActionsIntegrationTest.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Binaryk\LaravelRestify\Repositories\Repository;
1111
use Binaryk\LaravelRestify\Restify;
1212
use Binaryk\LaravelRestify\Tests\Fixtures\Post\Post;
13-
use Binaryk\LaravelRestify\Tests\Fixtures\Post\PublishInvokablePostAction;
1413
use Binaryk\LaravelRestify\Tests\Fixtures\Post\PublishPostAction;
1514
use Binaryk\LaravelRestify\Tests\Fixtures\User\ActivateAction;
1615
use Binaryk\LaravelRestify\Tests\Fixtures\User\DisableProfileAction;
@@ -88,7 +87,7 @@ public function mcpAllowsActions(): bool
8887
'params' => [
8988
'name' => $actionToolName,
9089
'arguments' => [
91-
'repositories' => '[' . $posts->first()->id . ',' . $posts->last()->id . ']',
90+
'repositories' => '['.$posts->first()->id.','.$posts->last()->id.']',
9291
],
9392
],
9493
]);
@@ -97,7 +96,7 @@ public function mcpAllowsActions(): bool
9796
$responseData = $response->json();
9897

9998
if (isset($responseData['error'])) {
100-
$this->fail('MCP Error: ' . $responseData['error']['message']);
99+
$this->fail('MCP Error: '.$responseData['error']['message']);
101100
}
102101

103102
$this->assertArrayHasKey('result', $responseData);
@@ -169,7 +168,7 @@ public function mcpAllowsActions(): bool
169168
'params' => [
170169
'name' => $actionToolName,
171170
'arguments' => [
172-
'repositories' => '[' . $posts->first()->id . ',' . $posts->last()->id . ']',
171+
'repositories' => '['.$posts->first()->id.','.$posts->last()->id.']',
173172
],
174173
],
175174
]);
@@ -178,7 +177,7 @@ public function mcpAllowsActions(): bool
178177
$responseData = $response->json();
179178

180179
if (isset($responseData['error'])) {
181-
$this->fail('MCP Error: ' . $responseData['error']['message']);
180+
$this->fail('MCP Error: '.$responseData['error']['message']);
182181
}
183182

184183
$this->assertArrayHasKey('result', $responseData);
@@ -252,7 +251,7 @@ public function mcpAllowsActions(): bool
252251
$responseData = $response->json();
253252

254253
if (isset($responseData['error'])) {
255-
$this->fail('MCP Error: ' . $responseData['error']['message']);
254+
$this->fail('MCP Error: '.$responseData['error']['message']);
256255
}
257256

258257
$this->assertArrayHasKey('result', $responseData);
@@ -323,7 +322,7 @@ public function mcpAllowsActions(): bool
323322
$responseData = $response->json();
324323

325324
if (isset($responseData['error'])) {
326-
$this->fail('MCP Error: ' . $responseData['error']['message']);
325+
$this->fail('MCP Error: '.$responseData['error']['message']);
327326
}
328327

329328
$this->assertArrayHasKey('result', $responseData);
@@ -473,7 +472,7 @@ public function mcpAllowsActions(): bool
473472
'params' => [
474473
'name' => $actionToolName,
475474
'arguments' => [
476-
'repositories' => '[' . $posts->first()->id . ']',
475+
'repositories' => '['.$posts->first()->id.']',
477476
'title' => 'Test Title',
478477
'is_active' => true,
479478
],
@@ -484,7 +483,7 @@ public function mcpAllowsActions(): bool
484483
$responseData = $response->json();
485484

486485
if (isset($responseData['error'])) {
487-
$this->fail('MCP Error: ' . $responseData['error']['message']);
486+
$this->fail('MCP Error: '.$responseData['error']['message']);
488487
}
489488

490489
$resultContent = json_decode($responseData['result']['content'][0]['text'], true);

0 commit comments

Comments
 (0)