Skip to main content
Glama

Compare refs

compare_refs
Read-onlyIdempotent

Compare two Git refs to see how many commits one is ahead of or behind the other, and list those commits newest first.

Instructions

Compare two refs (branches, tags or commits): how many commits "head" is ahead of and behind "base", and which commits those are, newest first. Useful for "how far behind main is my branch?" or "what is on this branch that is not released yet?".

Input Schema

NameRequiredDescriptionDefault
baseYesRef to compare against, e.g. "main" or a tag.
headNoRef to compare, e.g. a branch.HEAD
repoNoRepo name or path; defaults to the first configured repo.
limitNoMaximum number of results.

Output Schema

NameRequiredDescriptionDefault
baseYes
headYes
repoYesName of the repository that was queried.
aheadYesCommits reachable from head but not from base.
behindYesCommits reachable from base but not from head.
statusYes
truncatedYesTrue if either commit list was cut off by the limit.
baseCommitYesFull hash that "base" resolved to.
headCommitYesFull hash that "head" resolved to.
aheadCommitsYesCommits only in head, newest first.
behindCommitsYesCommits only in base, newest first.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv0.5.0
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum number of results (1-100)."New value: +"Maximum number of results."
    • changedInput schema / properties / repo / description
      Previous value: -"Repository name or absolute path from the allowlist. Defaults to the first configured repo."New value: +"Repo name or path; defaults to the first configured repo."
    • removedOutput schema / properties / aheadCommits / items / properties / hash
      Removed value: -{
      -  "type": "string"
      -}
    • addedOutput schema / properties / aheadCommits / items / properties / shortHash / description
      Added value: +"Abbreviated hash; usable wherever a ref is accepted."
    • changedOutput schema / properties / aheadCommits / items / required
      Previous value: -[
      -  "hash",
      -  "shortHash",
      -  "author",
      -  "date",
      -  "subject"
      -]New value: +[
      +  "shortHash",
      +  "author",
      +  "date",
      +  "subject"
      +]
    • removedOutput schema / properties / behindCommits / items / properties / hash
      Removed value: -{
      -  "type": "string"
      -}
    • addedOutput schema / properties / behindCommits / items / properties / shortHash / description
      Added value: +"Abbreviated hash; usable wherever a ref is accepted."
    • changedOutput schema / properties / behindCommits / items / required
      Previous value: -[
      -  "hash",
      -  "shortHash",
      -  "author",
      -  "date",
      -  "subject"
      -]New value: +[
      +  "shortHash",
      +  "author",
      +  "date",
      +  "subject"
      +]
  2. First observedv0.2.0

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint/idempotentHint/destructiveHint=false, so the safety profile is covered. The description adds behavior beyond that: the result is a directional divergence computation (head ahead of / behind base) with the actual commit list in newest-first order. It stops short of noting the effect of the limit default or how large divergences are truncated.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, zero filler: the first defines the operation and its output shape front-loaded, the second supplies motivating examples. Nothing is repeated from the schema or annotations.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present the description need not enumerate return fields, yet it still summarizes the key result (ahead/behind counts and commit identities). Safety is covered by annotations and the remaining four parameters are fully documented in the schema, so nothing an agent needs to invoke this correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description still adds real meaning by disambiguating the direction of the comparison — head is measured ahead of and behind base — which the schema's terse "Ref to compare against" / "Ref to compare" phrasings do not make explicit.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (compare) and resource (two refs: branches, tags, commits) and specifies exactly what is produced: ahead/behind counts plus the specific commits, newest first. This is functionally distinct from every sibling (list_tags, stale_branches, commit_search), so an agent can route to it without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete triggering scenarios ("how far behind main is my branch?", "what is on this branch that is not released yet?"), which tells the agent when this tool is the right choice. It does not, however, name alternatives or state when-not to use it versus siblings like stale_branches or list_tags.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.