Skip to content

Commit e060b1a

Browse files
authored
customizing description for tools (#682)
* fix: fixing fields that should be displayed on mcp index * Fix styling * fix: customizing description for tools --------- Co-authored-by: binaryk <[email protected]>
1 parent c0f3c86 commit e060b1a

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

src/MCP/Tools/Operations/StoreTool.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ public function name(): string
3636

3737
public function description(): string
3838
{
39-
$uriKey = $this->repository->uriKey();
40-
$modelName = class_basename($this->repository::guessModelClassName());
41-
42-
return "Create a new {$modelName} record in the {$uriKey} repository with the provided data.";
39+
return $this->repository::description(app(McpStoreRequest::class));
4340
}
4441

4542
public function schema(JsonSchema $schema): array

src/MCP/Tools/Operations/UpdateTool.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ public function name(): string
3636

3737
public function description(): string
3838
{
39-
$uriKey = $this->repository->uriKey();
40-
$modelName = class_basename($this->repository::guessModelClassName());
41-
42-
return "Update an existing {$modelName} record by ID in the {$uriKey} repository with the provided data.";
39+
return $this->repository::description(app(McpUpdateRequest::class));
4340
}
4441

4542
public function schema(JsonSchema $schema): array

src/Repositories/Repository.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Binaryk\LaravelRestify\Http\Requests\RepositoryStoreBulkRequest;
1717
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
1818
use Binaryk\LaravelRestify\MCP\Requests\McpRequestable;
19+
use Binaryk\LaravelRestify\MCP\Requests\McpStoreRequest;
20+
use Binaryk\LaravelRestify\MCP\Requests\McpUpdateRequest;
1921
use Binaryk\LaravelRestify\Models\Concerns\HasActionLogs;
2022
use Binaryk\LaravelRestify\Models\CreationAware;
2123
use Binaryk\LaravelRestify\Repositories\Concerns\InteractsWithAttachers;
@@ -288,6 +290,20 @@ public function subtitle(): ?string
288290
*/
289291
public static function description(RestifyRequest $request): string
290292
{
293+
if ($request instanceof McpStoreRequest) {
294+
$uriKey = static::uriKey();
295+
$modelName = class_basename(static::guessModelClassName());
296+
297+
return "Create a new {$modelName} record in the {$uriKey} repository with the provided data.";
298+
}
299+
300+
if ($request instanceof McpUpdateRequest) {
301+
$uriKey = static::uriKey();
302+
$modelName = class_basename(static::guessModelClassName());
303+
304+
return "Update an existing {$modelName} record by ID in the {$uriKey} repository with the provided data.";
305+
}
306+
291307
$modelName = class_basename(self::guessModelClassName());
292308
$table = self::newModel()->getTable();
293309

0 commit comments

Comments
 (0)