Expose bounded AST diff summaries in MCP results#1069
Open
thromel wants to merge 1 commit into
Open
Conversation
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.
Why
The MCP tools can already report detected refactorings, but that is often not enough for an agent reviewing a change. For many refactorings, the Git diff is the wrong first view: moved or extracted code turns into a large delete/add block, and the agent has to read a lot before it knows where the structural edits are.
This PR adds a bounded
astDiffsfield to MCP results. It gives clients a small AST-level index of the change: file pairs, mapping/action counts, counts by action type, sampled actions, line ranges, update values, and move metadata.Changes
McpAstDiffResult.astDiffsfrom analysis tools for file contents, worktrees, commits, pull requests, and directories.maxAstDiffsandmaxActionsPerAstDiff;maxAstDiffs=0omits the payload.-1for offsets and linestargetFilePathplus separatemoveGroupIddocumentation/mcp.md.What this gives MCP clients
A client can use RefactoringMiner as the first pass in review: see which file pairs changed structurally, which action types dominate, and which nodes deserve source inspection. It does not try to prove a refactoring is safe. It gives the agent a better map before it opens files.
Validation
./gradlew test --tests org.refactoringminer.mcp.RefactoringMinerMcpServiceTest --tests org.refactoringminer.mcp.RefactoringMinerMcpToolsTest --tests org.refactoringminer.mcp.WebDiffBrowserLauncherTest --no-daemon --console=plain./gradlew shadowJar mcpSmoke --no-daemon --console=plaingit diff --checkastDiffsastDiffson this RefactoringMiner branchmaxAstDiffs=0maxRefactorings=1.5is rejected with an errorRelated to #1058.