git_diff_unstaged
View uncommitted changes in your working directory that are not yet staged for Git. Specify a repository path and optional context lines to see diff output.
Instructions
Shows changes in the working directory that are not yet staged
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | ||
| context_lines | No |
Implementation Reference
- The core handler function for git_diff_unstaged - runs 'git diff --unified=<context_lines>' to show unstaged changes in the working directory.
def git_diff_unstaged(repo: git.Repo, context_lines: int = DEFAULT_CONTEXT_LINES) -> str: return repo.git.diff(f"--unified={context_lines}") - Pydantic model (schema) defining the input parameters for git_diff_unstaged: repo_path (str) and optional context_lines (int, default=3).
class GitDiffUnstaged(BaseModel): repo_path: str context_lines: int = DEFAULT_CONTEXT_LINES - src/git/src/mcp_server_git/server.py:320-330 (registration)Tool registration in the list_tools() function, declaring the tool name (git_diff_unstaged), description, input schema from GitDiffUnstaged, and annotations marking it as read-only/idempotent.
Tool( name=GitTools.DIFF_UNSTAGED, description="Shows changes in the working directory that are not yet staged", inputSchema=GitDiffUnstaged.model_json_schema(), annotations=ToolAnnotations( readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False, ), ), - src/git/src/mcp_server_git/server.py:490-495 (registration)Tool invocation handler in call_tool() - dispatches 'git_diff_unstaged' name to call git_diff_unstaged() with the repo and context_lines argument.
case GitTools.DIFF_UNSTAGED: diff = git_diff_unstaged(repo, arguments.get("context_lines", DEFAULT_CONTEXT_LINES)) return [TextContent( type="text", text=f"Unstaged changes:\n{diff}" )] - Enum definition mapping the tool name string 'git_diff_unstaged' to the GitTools.DIFF_UNSTAGED member.
class GitTools(str, Enum): STATUS = "git_status" DIFF_UNSTAGED = "git_diff_unstaged"