fix: apply MCP directory argument as the working directory#1600
Open
jmadren wants to merge 1 commit into
Open
Conversation
The `directory` argument on the `test`, `packages_get`, and `packages_check_licenses` MCP tools was appended as a positional CLI argument. Those commands resolve their target package from `Directory.current` and treat positionals as test/target paths, so the value never changed where the command ran. In a monorepo the tools therefore executed from the MCP server's current directory (commonly a folder with no `pubspec.yaml`) and failed with exit code 66, regardless of whether a relative or absolute `directory` was supplied. Apply `directory` by switching `Directory.current` for the duration of the run and restoring it in a `finally` afterwards. Relative paths resolve against the server's current directory, matching the intent of the `path`/`directory` parameter from VeryGoodOpenSource/vgv-ai-flutter-plugin#70. A non-existent directory now surfaces a clear tool error instead of a confusing exit code. Refs VeryGoodOpenSource/vgv-ai-flutter-plugin#70 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
Thank you @jmadren for the fix and contribution! Let me take a look and test and i will get back to you 💙 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
directoryargument on thetest,packages_get, andpackages_check_licensesMCP tools was appended as a positional CLI argument. Those commands resolve their target package fromDirectory.currentand treat positionals as test/target paths, so the value never changed where the command ran. In a monorepo the tools therefore executed from the MCP server's current directory (commonly a folder with nopubspec.yaml) and failed with exit code 66, regardless of whether a relative or absolutedirectorywas supplied.Type of Change
Fix
Apply
directoryby switchingDirectory.currentfor the duration of the run and restoring it in afinallyafterwards. Relative paths resolve against the server's current directory, matching the intent of thepath/directoryparameter from VeryGoodOpenSource/vgv-ai-flutter-plugin#70. A non-existent directory now surfaces a clear tool error instead of a confusing exit code.Refs VeryGoodOpenSource/vgv-ai-flutter-plugin#70