fix(mcp): surface command output and run tools in the requested directory#1612
Open
ryzizub wants to merge 1 commit into
Open
fix(mcp): surface command output and run tools in the requested directory#1612ryzizub wants to merge 1 commit into
ryzizub wants to merge 1 commit into
Conversation
…tory The `test`, `packages_get`, and `packages_check_licenses` MCP tools previously returned only an exit code (e.g. 69) and discarded the command output, and appended `directory` as a positional argument instead of using it as the working directory. - Capture the in-process command's mason Logger output via an IOOverrides stdout/stderr redirect (with the Logger constructed inside the zone, since mason pins IOOverrides.current at construction) and return it in CallToolResult.content with isError, so failures are diagnosable. This also keeps non-JSON off the real stdout that carries the MCP JSON-RPC stream. - Apply `directory` as the real working directory for the run and restore it afterwards; remove the positional misuse. - Serialize tool runs so the process-global working-directory switch is safe under concurrent (pipelined) tool calls. - Ignore generated *.vm.json test artifacts. Closes #1611 Refs #1599, #1600 Refs VeryGoodOpenSource/vgv-ai-flutter-plugin#94 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Sorry, I ran into an error while processing your request. Please try again later. |
1 similar comment
Contributor
|
Sorry, I ran into an error while processing your request. Please try again later. |
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.
Status
READY
Description
The very_good_cli MCP
test,packages_get, andpackages_check_licensestools had two problems:"<tool>" failed with exit code 69.— the actual failing tests, compile errors, and logs (written by the in-process masonLoggerto stdout/stderr, which the stdio transport shares with the JSON-RPC stream) never reached the client. Agents saw an opaque exit code and could not diagnose failures.directorydid nothing useful. It was appended as a positional CLI argument; the commands resolve their target from the process current directory, so in a monorepo the tool ran from the wrong place and failed with exit code 66.Changes
IOOverrides.runZoned, constructing the masonLoggerinside the zone (mason pinsIOOverrides.currentat construction, so a Logger built outside would still write to the real stdout). The captured output is returned inCallToolResult.contentwithisErroron success and every failure path, and non-JSON is kept off the real stdout that carries the MCP JSON-RPC stream (per the stdio transport spec).directoryas the real working directory (Directory.current) for the run and restore it infinally; remove the positional misuse.*.vm.jsontest artifacts.Connections
directoryargument as the working directory #1600 / vgv-ai-flutter-plugin feat #70 doesn't work #1599: this PR also reworksdirectoryinto a working-directory switch. The approach here is concurrency-safe (serialized) and additionally surfaces command output — coordinate to avoid duplicate/conflicting changes.testresults blocked the/buildflow).Verification
lib/src/mcp/mcp_server.dartat 100% coverage.dart analyze --fatal-infos --fatal-warningsclean;dart formatclean.testtool: a failing package now returns the real failure output and runs in the requesteddirectory. The concurrency fix is covered by a mutation-proven regression test.Type of Change
🤖 Generated with Claude Code