Skip to content

feat: changes_list and changes_get tools - #4

Merged
ryanlitalien merged 1 commit into
mainfrom
feat/1961-changes-tools
Sep 25, 2026
Merged

ryanlitalien merged 1 commit into
mainfrom
feat/1961-changes-tools

Conversation

@ryanlitalien

Copy link
Copy Markdown
Member

Adds MCP tools for changes (commits and changelists across git, Perforce, and Lore), so an agent holding a build's commit_hash from builds_get can find the change it came from.

What

  • changes_list: project_id, plus source (lore|git|perforce), identifier, updated_since, orphaned, limit, cursor. Returns the API's {changes, pagination} response.
  • changes_get: project_id, change_id. An all-digit change_id is the change id from changes_list; anything else (full git SHA, a Perforce build's p4-<n>, lore-<n>) is resolved through the API's exact identifier filter, then the detail (files, approvals, linked builds, latest build, task ids) is returned. An unmatched reference is an error, not an empty result.
  • A 403 insufficient_scope naming read:changes becomes an error that says to run butter auth login again.
  • README tool table and a note on the scope.

Things to look at twice

  • p4- prefix. A Perforce BuildRun stores p4-<n> but its change stores the bare <n>, and the identifier filter is exact and unvalidated, so the prefix is stripped here or the lookup silently returns nothing.
  • Lore vs Perforce share source_type=Changelist server-side; source filters the page by the lore- prefix, so a filtered page can hold fewer than limit rows.
  • Drift to be aware of (not changed here): this package does not have the builds_get_investigation tool or the string/UUID build_id fix that the in-monorepo copy of this server got for the builds read path. builds_get here still declares build_id as a number. Worth a separate sync.

Depends on

The server must allow read:changes on CLI-issued tokens (ButterStack/butter_stack#1961). Tokens issued before that deploy need butter auth login again; a hand-made token from account settings with read:changes works as BUTTERSTACK_API_TOKEN today.

Verification

  • npm test: 9/9 (6 new: argument-to-query mapping, lore split, get by id, get by p4-<n>, unknown commit is an error, 403 reissue hint; the tool-count test now expects fourteen).
  • Ran both tools over stdio against a local ButterStack server with the server change: changes_get p4-207 returned the Perforce change with its linked build, changes_list source=lore returned only the Lore changelist, and a token without read:changes got the reissue error.

No version bump in this PR; a release is needed to publish it.

The changes API (commits and changelists across git, Perforce, and Lore)
had no MCP tool, so an agent holding a build's commit_hash could not find
the change it came from.

- changes_list: source (lore|git|perforce), identifier, updated_since,
  orphaned, limit, cursor. Lore and Perforce share one source type
  server-side and are split here by the lore- identifier prefix.
- changes_get: a change id, or a commit reference (full SHA, p4-<n>,
  lore-<n>) resolved through the exact identifier filter. A Perforce
  build stores p4-<n> while its change stores <n>, so the prefix is
  stripped; an unmatched reference is an error, not an empty result.
- A 403 naming read:changes says to run `butter auth login` again.
@ryanlitalien
ryanlitalien merged commit 342d034 into main Sep 25, 2026
1 check passed
@ryanlitalien
ryanlitalien deleted the feat/1961-changes-tools branch September 25, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant