Skip to content

Conversation

@tonytrg
Copy link
Contributor

@tonytrg tonytrg commented Oct 23, 2025

Summary

This PR consolidates repository-related tools in the GitHub MCP server, reducing tool count by 41% (17 → 10 tools) while maintaining all functionality. The refactoring improves semantic organization by grouping related operations under unified tools with method parameters and extracting toolsets into dedicated files following established patterns.

Tool Consolidations

1. file_write (3 → 1 tool)

Consolidates all file modification operations:

  • create_or_update_filefile_write with method: "create" or method: "update"
  • delete_filefile_write with method: "delete"
  • push_filesfile_write with method: "push_files"

Rationale: All three tools perform file modifications in a repository and share core parameters (owner, repo, branch, message).

2. commit_read (2 → 1 tool)

Consolidates commit read operations:

  • get_commitcommit_read with method: "get"
  • list_commitscommit_read with method: "list"

Rationale: Both tools read commit data from a repository and share the same required parameters (owner, repo).

3. tag_read (2 → 1 tool)

Consolidates Git tag operations:

  • list_tagstag_read with method: "list"
  • get_tagtag_read with method: "get"

Rationale: Both tools read Git tag data and share the same required parameters (owner, repo).

4. release_read (3 → 1 tool, moved to dedicated toolset)

Consolidates GitHub release operations into new releases toolset:

  • list_releasesrelease_read with method: "list"
  • get_latest_releaserelease_read with method: "get_latest"
  • get_release_by_tagrelease_read with method: "get_by_tag"

Rationale: Releases are semantically distinct from repository operations and warrant their own toolset, similar to gists, discussions, etc.

⚠️ Change in default toolsets, as releases are moved out and not part of the default toolset. As release handling occurs very infrequently, data shows less than 1% of users ever interact with release tooling.

File Organization Improvements

New Dedicated Files Created

Following the established pattern used by other toolset groups (gists, discussions, etc.):

  1. Releases (extracted from repositories.go):

    • pkg/github/releases.go - Tool definitions for new releases toolset
    • pkg/github/releases_test.go - Comprehensive tests
    • pkg/github/__toolsnaps__/release_read.snap - Tool snapshot
  2. Stargazers (extracted from repositories.go):

    • pkg/github/stargazers.go - Tool definitions (list_starred_repositories, star_repository, unstar_repository)
    • pkg/github/stargazers_test.go - Comprehensive tests
    • Snapshots updated in existing toolsnaps

Tools NOT Consolidated

The following tools remain separate as they operate on distinct entities or lack shared parameters:

  • search_repositories, search_code - Different search use cases with distinct parameters
  • get_file_contents - Requires special raw client handling
  • list_branches - No natural pairing with other branch operations
  • create_repository, fork_repository, create_branch - Operate on different entities (repos vs branches)

Seperate commit_read and tag_read instead of git_read

  1. User intent differs: commits are requested for history/diff/status analysis; tags are requested for version discovery and release/provenance flows.
  2. Workflow coupling: commits frequently pair with get_file_contents or code/search tools; tags pair with release_read and version selection—low overlap in atomic retrieval needs.
  3. Tool routing precision & simplicity: separate, semantically strong tool names reduce mis-selection and validation complexity versus a multi-mode "git object" tool.

Benefits

Better semantic organization: Releases now have dedicated toolset separate from repository operations
Improved code maintainability: Related functionality grouped in dedicated files following established patterns
Clearer tool discovery: Consolidated tools with method parameters are easier to understand and use
Reduced tool count: 41% reduction (17 → 10 tools) in repos read/write operations
No functional changes: Pure refactoring with comprehensive test coverage maintained
Pattern consistency: Follows the same organizational pattern as gists, discussions, and other toolsets

Testing

All existing tests have been maintained and relocated to dedicated test files. Tool snapshots have been updated to reflect the new consolidated structure. No functional behavior has been changed.

@tonytrg tonytrg requested a review from a team as a code owner October 23, 2025 09:22
@Copilot Copilot AI review requested due to automatic review settings October 23, 2025 09:22
Copy link
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

This PR consolidates multiple repository operation tools into unified tools with method-based routing, reducing the total number of exposed tools while maintaining the same functionality.

  • Consolidates commit operations (get_commit, list_commits) into commit_read with "get" and "list" methods
  • Consolidates file write operations (create_or_update_file, delete_file, push_files) into file_write with "create", "update", "delete", and "push_files" methods
  • Consolidates release/tag operations (list_tags, get_tag, list_releases, get_latest_release, get_release_by_tag) into release_read with corresponding methods

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/github/tools.go Updates default toolset to use consolidated tools instead of individual operation tools
pkg/github/repositories.go Implements consolidated tools with method dispatching and refactors individual operations into method handlers
pkg/github/repositories_test.go Updates tests to use new consolidated tool names and adds method parameters to test cases
pkg/github/toolsnaps/*.snap Adds snapshots for new consolidated tools and removes snapshots for deprecated individual tools
README.md Updates documentation to reflect new consolidated tool structure

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


func Test_ListCommits(t *testing.T) {
// Verify tool definition once
// Test for list method is covered in a separate test suite
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

The comment says 'Test for list method is covered in a separate test suite' but the list method tests are actually in the same file immediately following this comment (in Test_CommitRead_List). Update the comment to accurately reflect that the list method tests follow in this same file.

Suggested change
// Test for list method is covered in a separate test suite
// Tests for the list method follow in this file.

Copilot uses AI. Check for mistakes.
}

func Test_DeleteFile(t *testing.T) {
// Test_DeleteFile is removed as the delete_file tool has been consolidated into file_write
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

This comment suggests that tests for the delete file functionality were removed, but the actual delete file tests still exist below in the DeleteFileMethod function (lines 1345-1462). Either remove this misleading comment or clarify that the test function was renamed/reorganized rather than removed.

Suggested change
// Test_DeleteFile is removed as the delete_file tool has been consolidated into file_write
// The original Test_DeleteFile function was removed as the delete_file tool was consolidated into file_write.

Copilot uses AI. Check for mistakes.
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.

2 participants