Skip to content

Conversation

andreilungeanu
Copy link
Contributor

@andreilungeanu andreilungeanu commented Aug 27, 2025

Problem

MCP server runs as a long-lived process that inherits environment variables at startup. When users change .env values, child processes spawned for tool execution inherit the parent's stale environment variables instead of reading fresh values from the updated .env file.

Root Cause

MCP server loads .env values into $_ENV at startup
Child processes inherit parent's environment variables
Laravel's LoadEnvironmentVariables doesn't re-read .env if variables already exist in environment
Process isolation alone doesn't solve this due to environment inheritance

Solution

Refresh environment variables ExecuteToolCommand
Fix #130

- Fixes environment variable inheritance issue where long-running MCP server processes pass stale environment variables to child tool execution processes.
Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@andreilungeanu andreilungeanu marked this pull request as ready for review August 27, 2025 08:23
@ashleyhindle
Copy link
Collaborator

Apologies @andreilungeanu , didn't see this and just merged #217 with a similar fix 👌

Thanks for PRing, will keep a closer eye on your future PRs!

@andreilungeanu
Copy link
Contributor Author

Thanks @ashleyhindle No worries at all — glad the issue is fixed either way! Happy to contribute again if I spot anything else.

@andreilungeanu andreilungeanu deleted the fix-env-variables branch August 28, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Boost doesn't detect environment changes
2 participants