git_diff_unstaged
View unstaged changes in your Git working directory to review modifications before committing them.
Instructions
Shows changes in the working directory that are not yet staged
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | ||
| context_lines | No |
Implementation Reference
- Core handler function that executes `git diff --unified` for unstaged changes.def git_diff_unstaged(repo: git.Repo, context_lines: int = DEFAULT_CONTEXT_LINES) -> str: return repo.git.diff(f"--unified={context_lines}")
- Pydantic schema defining input parameters: repo_path (required) and context_lines (optional, defaults to 3).class GitDiffUnstaged(BaseModel): repo_path: str context_lines: int = DEFAULT_CONTEXT_LINES
- src/git/src/mcp_server_git/server.py:292-296 (registration)Registers the 'git_diff_unstaged' tool with the MCP server in list_tools(), providing name, description, and input schema.Tool( name=GitTools.DIFF_UNSTAGED, description="Shows changes in the working directory that are not yet staged", inputSchema=GitDiffUnstaged.model_json_schema(), ),
- MCP server call_tool implementation that handles invocation of git_diff_unstaged, formats the diff output as TextContent, and returns it.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}" )]
- src/git/src/mcp_server_git/server.py:97-97 (registration)Enum value in GitTools defining the canonical tool name 'git_diff_unstaged'.DIFF_UNSTAGED = "git_diff_unstaged"