Skip to content

feat: Add search commit tool#2284

Open
Not-Dhananjay-Mishra wants to merge 5 commits intogithub:mainfrom
Not-Dhananjay-Mishra:search-commit
Open

feat: Add search commit tool#2284
Not-Dhananjay-Mishra wants to merge 5 commits intogithub:mainfrom
Not-Dhananjay-Mishra:search-commit

Conversation

@Not-Dhananjay-Mishra
Copy link
Copy Markdown

@Not-Dhananjay-Mishra Not-Dhananjay-Mishra commented Apr 3, 2026

Summary

Added a new search_commits tool to the GitHub MCP server, allowing users and LLMs to search for commits across repositories using specialized GitHub search syntax

Why

This provides a missing capability for high-impact commit discovery and debugging that isn't possible with the existing list_commits tool
Fixes #2283

What changed

  • Implemented SearchCommits
  • Added the tool handler and MinimalSearchCommitsResult struct
  • Registered the new tool in pkg/github/tools.go

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

Prompts tested (tool changes only)

  • Search for all commits in the 'github/github-mcp-server' repository that mention 'vulnerability' or 'fix' in the last 6 months
  • Find all commits authored by 'github' across the organization that were committed after 2024-01-01.
  • Find the most recent commit that modified the search.go file with a message containing 'refactor'.
  • Search for commits in 'owner/repo' that are tagged with '[RELEASE]' to summarize recent major changes.

Security / limits

  • No security or limits impact
  • 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

Note: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.

Lint & tests

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

Docs

  • Not needed
  • Updated (README / docs / examples)

@Not-Dhananjay-Mishra Not-Dhananjay-Mishra requested a review from a team as a code owner April 3, 2026 07:26
@Not-Dhananjay-Mishra Not-Dhananjay-Mishra changed the title Search commit feat: Add search commit tool Apr 3, 2026
@Not-Dhananjay-Mishra
Copy link
Copy Markdown
Author

Not-Dhananjay-Mishra commented Apr 3, 2026

Here are some example use case :
Screenshot 2026-04-03 at 6 26 23 PM
Screenshot 2026-04-03 at 6 40 57 PM

Copy link
Copy Markdown

@marknilsn marknilsn left a comment

Choose a reason for hiding this comment

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

Nice addition. search_commits feels like a real gap-filler between list_commits and broader search, and the implementation/result shape look reasonable to me. Non-blocking thought: we may eventually want a short note about commit-search query expectations or caveats, but I don’t see that as a blocker here.

Copilot AI review requested due to automatic review settings April 21, 2026 12:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new MCP tool to the GitHub MCP Server for searching commits via GitHub’s commit search API, filling a capability gap vs. list_commits.

Changes:

  • Added search_commits tool implementation (SearchCommits) including minimal response shaping.
  • Registered the new tool in the global tool inventory.
  • Added tests and a new toolsnap snapshot for the tool schema.

Reviewed changes

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

Show a summary per file
File Description
pkg/github/tools.go Registers SearchCommits in AllTools so it’s exposed by the server.
pkg/github/search.go Implements the new search_commits tool and maps GitHub API results to minimal output.
pkg/github/minimal_types.go Adds MinimalSearchCommitsResult output type.
pkg/github/search_test.go Adds schema/toolsnap verification and handler behavior tests for search_commits.
pkg/github/helper_test.go Adds mock route constant for /search/commits.
pkg/github/toolsnaps/search_commits.snap Adds schema snapshot for the new tool.

Comment thread pkg/github/tools.go
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new search_commits MCP tool to the GitHub MCP Server, enabling commit discovery via GitHub’s commit search syntax and returning a trimmed/minimal result payload.

Changes:

  • Implemented SearchCommits tool handler and response shaping into MinimalSearchCommitsResult.
  • Registered search_commits in the overall tool inventory.
  • Added unit tests + toolsnap snapshot, and updated README tool documentation.

Reviewed changes

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

Show a summary per file
File Description
pkg/github/tools.go Registers the new SearchCommits tool in the server tool list.
pkg/github/search.go Implements the search_commits tool schema + handler calling GitHub Search Commits API and emitting minimal output.
pkg/github/minimal_types.go Adds MinimalSearchCommitsResult output type for commit search responses.
pkg/github/search_test.go Adds toolsnap verification and handler behavior tests for search_commits.
pkg/github/helper_test.go Adds the /search/commits endpoint constant used by HTTP mocking helpers.
pkg/github/toolsnaps/search_commits.snap New snapshot for the search_commits tool schema.
README.md Documents the new tool in the generated tools section.

Comment thread pkg/github/search.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new search_commits MCP tool to the GitHub MCP server, enabling commit searches via GitHub’s commit search syntax and returning a trimmed, structured result.

Changes:

  • Implemented SearchCommits tool handler using client.Search.Commits(...) with pagination support.
  • Added MinimalSearchCommitsResult output type and associated unit tests + toolsnap snapshot.
  • Registered the tool in the global tool inventory and documented it in the README.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/github/tools.go Registers SearchCommits in AllTools so it’s available to the server/toolsets/docs generator.
pkg/github/search.go Implements the search_commits tool schema and handler logic.
pkg/github/minimal_types.go Adds MinimalSearchCommitsResult trimmed output struct for commit search responses.
pkg/github/search_test.go Adds tool snapshot + behavior tests (success/error) for search_commits.
pkg/github/helper_test.go Adds mocked endpoint constant for /search/commits to support tests.
pkg/github/toolsnaps/search_commits.snap New toolsnap capturing the tool’s schema/metadata for regression protection.
README.md Documents the new tool and its parameters/scopes in the generated tools section.

@Not-Dhananjay-Mishra
Copy link
Copy Markdown
Author

@SamMorrowDrums, Can you take a look?
sorry for the ping

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.

Tool Request : Search Commit Tool

3 participants