Skip to content

Add path, since and until to list_commits#2260

Merged
SamMorrowDrums merged 2 commits into
github:mainfrom
Luc45:add-path-since-until-to-list-commits
Mar 24, 2026
Merged

Add path, since and until to list_commits#2260
SamMorrowDrums merged 2 commits into
github:mainfrom
Luc45:add-path-since-until-to-list-commits

Conversation

@Luc45

@Luc45 Luc45 commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Add three optional filter parameters (path, since, until) to list_commits, exposing existing GitHub API capabilities that the go-github library already supports but the MCP tool did not wire up.

Why

Monorepo workflows need to scope commit history to a specific subdirectory (e.g. projects/plugins/boost in a Jetpack monorepo with 50+ products). Without path, the tool returns all commits across the entire repository. Without since/until, date-range queries require fetching everything and filtering client-side, wasting context window.

Fixes #197

What changed

  • Added path, since, until schema properties to list_commits (same pattern as existing author parameter)
  • Added parameter extraction and wiring to CommitsListOptions.Path, .Since, .Until
  • Time parsing uses the existing parseISOTimestamp helper (shared with list_issues and list_gists)
  • Added 4 test cases: path filter, since+until, combined path+since+author, invalid timestamp error
  • Updated toolsnap and regenerated docs

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed — three new optional input parameters (path, since, until) added to list_commits. No breaking changes; existing calls work identically.
  • New tool added

Prompts tested (tool changes only)

  • "Show me commits in the src/utils directory"
  • "List commits from the last month"
  • "What commits were made to projects/plugins/boost between January and March 2025?"
  • "Show commits by username in the docs/ folder since 2025-01-01"

Security / limits

  • No security or limits impact — read-only filter parameters passed through to the existing GitHub API. No new data exposure; results are a subset of what list_commits already returns.
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed
  • Updated (README / docs / examples)
Luc45 added 2 commits March 24, 2026 15:48
Add three optional parameters to the list_commits tool that map to
existing GitHub API query parameters:

- path: filter commits to those touching a specific file or directory
- since: only commits after this date (ISO 8601)
- until: only commits before this date (ISO 8601)

These parameters are already supported by the go-github library's
CommitsListOptions struct but were not exposed by the MCP tool.

The path filter is particularly useful for monorepo workflows where
commit history needs to be scoped to a specific project subdirectory.

Time parsing uses the existing parseISOTimestamp helper (shared with
list_issues and list_gists) which accepts both YYYY-MM-DDTHH:MM:SSZ
and YYYY-MM-DD formats.

Closes github#197
@Luc45 Luc45 requested a review from a team as a code owner March 24, 2026 19:31
Copilot AI review requested due to automatic review settings March 24, 2026 19:31
@Luc45

Luc45 commented Mar 24, 2026

Copy link
Copy Markdown
Contributor Author

❯ List commits in github/github-mcp-server that touched pkg/github/repositories.go

image

Result:

image

❯ List commits in https://github.com/github/github-mcp-server that touched pkg dir this month - Expected to use path and since

image

Result:

image

@JoannaaKL @SamMorrowDrums Would it be possible to ask someone to review this? I'm asking directly because I see two prior PRs for this (#783, #1928) that went unreviewed for months and were closed by the stale bot. @williammartin commented on #197: "Totally makes sense. Would definitely accept a PR for this." — this is a straightforward change and should be quick to review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional GitHub API filters to the list_commits MCP tool so callers can scope commit history by path and/or a time window, improving usability for monorepos and incident/time-range investigations.

Changes:

  • Extended list_commits input schema with optional path, since, and until parameters.
  • Wired the new parameters into github.CommitsListOptions (including ISO timestamp parsing via the shared parseISOTimestamp helper).
  • Added/updated unit tests, toolsnap snapshot, and README docs to reflect the schema change.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pkg/github/repositories.go Adds path/since/until params to the list_commits tool and maps them to GitHub API list options.
pkg/github/repositories_test.go Adds schema assertions and behavioral tests validating query param wiring and timestamp validation.
pkg/github/toolsnaps/list_commits.snap Updates the tool schema snapshot for the new optional properties.
README.md Regenerates tool documentation to include the new parameters.
Comment thread pkg/github/repositories.go

@SamMorrowDrums SamMorrowDrums left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You make a good case! Love it. Thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants