-
Notifications
You must be signed in to change notification settings - Fork 9.1k
feat(mcp-server-git): Add context_lines to git_diff* tools #1326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…INES - Introduced `GIT_DIFF_CONTEXT_LINES` environment variable to customize the number of context lines shown in git diff output. - Updated `git_diff_unstaged`, `git_diff_staged`, and `git_diff` functions to utilize the new context line setting. - Enhanced README.md to document the new environment variable and its implications.
a4df44e to
ba54c9d
Compare
|
(Oof: I clicked the "update with rebase" button next to "This branch is out-of-date with the base branch" in GitHub, and it did terrible things. I just reverted with a second force-push). @olaservo anything I can do to expedite? (It really does substantively improve Claude's code reviews quality!) |
|
Hi @mceachen just getting to this now, sorry for the miss on the earlier tag. Should the |
|
Adding more from discord convo for visibility: to clarify, I think it makes sense to make this something that can get set as an optional parameter. So re: my env variable question I was more thinking that when the parameter isn't being set, does it make sense for the default to be configurable in the server config. |
olaservo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, will leave the environment variable option as a future enhancement since the default is already the same as the git default.
feat(mcp-server-git): Add context_lines to git_diff* tools
context_linesparameter togit_diff_unstaged,git_diff_staged, andgit_difffunctionsDescription
Server Details
gitgit_diff_unstaged,git_diff_staged, andgit_diff.Motivation and Context
The standard unified git diff only includes 3 lines of context. When Claude is being asked to review pending changes, it is blind to the remainder of any touched file unless the lines of context are increased.
At the limit, a
context_linesvalue that is the same size of your largest source file means every touched file gets automatically included in the context. Claude seems to handle this with aplomb and provides strictly better git review guidance. ChatGPT 4o seems to get distracted by the larger diff contexts, so YMMV.How Has This Been Tested?
MCP Inspector and vscode/copilot
Breaking Changes
No--by default, no behavior changes with this PR.
Users simply add a reference to setting "context_lines" in their prompt.
Types of changes
Checklist
Additional context
The first commit used an environment variable. The current PR uses a proper parameter, which is more flexible and seems to be more idiomatic.