Skip to content

Commit 52d6c91

Browse files
authored
Merge pull request #108 from laravel/improve-tinker-usage-with-model-creation
tool: tinker: try to nudge away from creating test users ahead of time
2 parents 44f6eff + a857fa4 commit 52d6c91

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

src/Mcp/Tools/Tinker.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
class Tinker extends Tool
1515
{
16-
public function shouldRegister(): bool
17-
{
18-
return app()->environment() === 'local';
19-
}
20-
2116
public function description(): string
2217
{
23-
return 'Execute PHP code in the Laravel application context, similar to artisan tinker. Most useful for debugging issues, checking if functions exists, and testing code snippets. Returns the output of the code, as well as whatever is "returned" using "return".';
18+
return <<<'DESCRIPTION'
19+
Execute PHP code in the Laravel application context, like artisan tinker.
20+
Use this for debugging issues, checking if functions exist, and testing code snippets.
21+
You should not create models directly without explicit user approval. Prefer Unit/Feature tests using factories for functionality testing. Prefer existing artisan commands over custom tinker code.
22+
Returns the output of the code, as well as whatever is "returned" using "return".
23+
DESCRIPTION;
2424
}
2525

2626
public function schema(ToolInputSchema $schema): ToolInputSchema

tests/Feature/Mcp/Tools/TinkerTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,6 @@ function getToolResultData(ToolResult $result): array
151151
expect($tool->shouldRegister())->toBeTrue();
152152
});
153153

154-
test('should not register in non-local environment', function () {
155-
$tool = new Tinker;
156-
157-
// Test in production environment
158-
app()->detectEnvironment(function () {
159-
return 'production';
160-
});
161-
162-
expect($tool->shouldRegister())->toBeFalse();
163-
});
164-
165154
test('uses custom timeout parameter', function () {
166155
$tool = new Tinker;
167156
$result = $tool->handle(['code' => 'return 2 + 2;', 'timeout' => 10]);

0 commit comments

Comments
 (0)