Skip to content

tool: tinker: try to nudge away from creating test users ahead of time #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Mcp/Tools/Tinker.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

class Tinker extends Tool
{
public function shouldRegister(): bool
{
return app()->environment() === 'local';
}

public function description(): string
{
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".';
return <<<'DESCRIPTION'
Execute PHP code in the Laravel application context, like artisan tinker.
Use this for debugging issues, checking if functions exist, and testing code snippets.
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.
Returns the output of the code, as well as whatever is "returned" using "return".
DESCRIPTION;
}

public function schema(ToolInputSchema $schema): ToolInputSchema
Expand Down
11 changes: 0 additions & 11 deletions tests/Feature/Mcp/Tools/TinkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,6 @@ function getToolResultData(ToolResult $result): array
expect($tool->shouldRegister())->toBeTrue();
});

test('should not register in non-local environment', function () {
$tool = new Tinker;

// Test in production environment
app()->detectEnvironment(function () {
return 'production';
});

expect($tool->shouldRegister())->toBeFalse();
});

test('uses custom timeout parameter', function () {
$tool = new Tinker;
$result = $tool->handle(['code' => 'return 2 + 2;', 'timeout' => 10]);
Expand Down