Skip to main content
Glama

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
NameRequiredDescriptionDefault
repo_pathYes
context_linesNo

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
  • 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}" )]
  • Enum value in GitTools defining the canonical tool name 'git_diff_unstaged'.
    DIFF_UNSTAGED = "git_diff_unstaged"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/modelcontextprotocol/git'

If you have feedback or need assistance with the MCP directory API, please join our Discord server