-
Notifications
You must be signed in to change notification settings - Fork 137
Description
Laravel Package Version
1.6.1
Laravel Version
12.21
PHP Version
8.4.11
System Info
macOS 14.1 (M3) with Herd
Description
Problem Description
When using the Laravel Boost MCP server's tinker
tool, changes made to PHP classes are not reflected in subsequent tinker executions. The tinker instance appears to be initialized once when the MCP server starts and
keeps the original class definitions in memory, ignoring any file modifications.
Steps to Reproduce
- Start Laravel Boost MCP server
- Create or modify a model method, for example:
// app/Models/Report.php
public function getAggregatedData(): array
{
// Original implementation
return [
'average' => 100,
'count' => 5
];
}
- Execute the method via MCP tinker tool:
$report = Report::first();
$report->getAggregatedData();
// Returns ['average' => 100, 'count' => 5]
- Modify the method to add new fields:
public function getAggregatedData(): array
{
// Updated implementation
return [
'average' => 100,
'count' => 5,
'total' => 500, // New field added
'minimum' => 50 // New field added
];
}
- Execute the method again via MCP tinker tool:
$report = Report::first();
$report->getAggregatedData();
// Still returns ['average' => 100, 'count' => 5] without new fields
Expected Behavior
The tinker tool should reflect the current state of the code files, showing updated method implementations and class definitions.
Actual Behavior
The tinker tool continues to use the cached/original version of the class that was loaded when the MCP server started, ignoring any file changes.
Workaround
Using php artisan tinker
directly via Bash creates a fresh instance and correctly loads the updated code:
php artisan tinker --execute="
\$report = Report::first();
\$report->getAggregatedData();
"
# Correctly returns all fields including 'total' and 'minimum'
Attempted Solutions That Don't Work
php artisan optimize:clear
opcache_reset()
$model->refresh()
\Illuminate\Support\Facades\Cache::flush()
php artisan cache:clear
php artisan config:clear
Suggested Fix
The MCP tinker tool should either:
- Create a fresh tinker instance for each execution, or
- Provide a way to reload/refresh the class definitions, or
- Implement file watching to automatically reload changed classes
- Add a
--fresh
flag to force reload of all classes
Impact
This issue significantly impacts development workflow as developers need to:
- Restart the entire MCP server to see code changes reflected in tinker
- Resort to using bash commands instead of the convenient MCP tinker tool
- Lose time debugging "phantom" bugs that are actually just cached code
Environment Details
- Using Claude Desktop with Laravel Boost MCP integration
- Laravel application served via Herd
- OPcache enabled in PHP configuration
Steps To Reproduce
In Description