Skip to main content
Glama

diff_with_ref

Compare code changes between HEAD and a specified reference branch to analyze differences in a project. Ideal for reviewing PRs or tracking updates in development workflows.

Instructions

Return a summary of the diff between HEAD and the given ref.

You probably want the ref to be the 'base' branch like develop or main, off which PRs are made - and you can likely determine this by viewing the most recently checked out branches.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_nameYes
refYes

Implementation Reference

  • The handler function for the 'diff_with_ref' tool. It computes the git diff between the specified ref and HEAD for the given project, ignoring blank lines and space at EOL, and returns the diff as MCPToolOutput with character limit.
    def diff_with_ref( project_name: str, ref: Annotated[str, Field(max_length=100)], ) -> ToolResponse: """Return a summary of the diff between HEAD and the given ref. You probably want the ref to be the 'base' branch like develop or main, off which PRs are made - and you can likely determine this by viewing the most recently checked out branches. """ project = _get_project_or_error(project_name) repo = Repo(project.git_path) # head = repo.head.commit # compare_from = repo.commit(ref) # diffs = compare_from.diff(head, create_patch=True) # print(repo.git.diff(f"{ref}s...HEAD", ignore_blank_lines=True, ignore_space_at_eol=True)) diff = repo.git.diff( f"{ref}...HEAD", ignore_blank_lines=True, ignore_space_at_eol=True, ) return MCPToolOutput( text=diff, max_chars=deps.settings().default_git_diff_response_max_chars, ).render()
  • MCP tool registration via @mcp.tool() decorator, with additional logging decorator.
    @mcp.tool() @log_inputs_outputs()
  • Input schema defined via type annotations and Annotated Field for parameters.
    def diff_with_ref( project_name: str, ref: Annotated[str, Field(max_length=100)], ) -> ToolResponse:

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/jurasofish/mcpunk'

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