Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Laravel Boost MCP Tinker tool caches class definitions and doesn't reflect code changes #194

Closed
@cieplik206

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

  1. Start Laravel Boost MCP server
  2. Create or modify a model method, for example:
// app/Models/Report.php
public function getAggregatedData(): array
{
 // Original implementation
 return [
 'average' => 100,
 'count' => 5
 ];
}
  1. Execute the method via MCP tinker tool:
$report = Report::first();
$report->getAggregatedData();
// Returns ['average' => 100, 'count' => 5]
  1. 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
 ];
}
  1. 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:

  1. Create a fresh tinker instance for each execution, or
  2. Provide a way to reload/refresh the class definitions, or
  3. Implement file watching to automatically reload changed classes
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /