Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Split up tooling utility #1273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
tonytrg merged 3 commits into main from tonytrg/make-toolset-functionality-public
Oct 21, 2025
Merged

Conversation

@tonytrg
Copy link
Contributor

@tonytrg tonytrg commented Oct 21, 2025
edited
Loading

Closes:

Splits up the toolset functionality into sub functions, as they were not really reusable.

@tonytrg tonytrg force-pushed the tonytrg/make-toolset-functionality-public branch from 64fffaa to 5346e05 Compare October 21, 2025 11:11
@tonytrg tonytrg force-pushed the tonytrg/make-toolset-functionality-public branch from b2cb714 to 0a0873f Compare October 21, 2025 12:34
@tonytrg tonytrg changed the title (削除) make cleanToolsets public (削除ここまで) (追記) Split up tooling utility (追記ここまで) Oct 21, 2025
@tonytrg tonytrg marked this pull request as ready for review October 21, 2025 12:57
@tonytrg tonytrg requested a review from a team as a code owner October 21, 2025 12:57
@Copilot Copilot AI review requested due to automatic review settings October 21, 2025 12:57
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 refactors toolset utility functions by splitting them from the server package into the github package. The refactoring extracts CleanToolsets, AddDefaultToolset, RemoveToolset, and ContainsToolset as public utility functions, making them reusable across the codebase while simplifying the server initialization logic.

Key changes:

  • Moved toolset manipulation utilities from internal/ghmcp/server.go to pkg/github/tools.go as public functions
  • Simplified server initialization by composing smaller utility functions instead of one monolithic cleanToolsets function
  • Added comprehensive test coverage for the new utility functions in pkg/github/tools_test.go

Reviewed Changes

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

File Description
pkg/github/tools.go Adds four new public utility functions for toolset manipulation: CleanToolsets, AddDefaultToolset, RemoveToolset, and ContainsToolset
pkg/github/tools_test.go Introduces comprehensive test suite covering all new utility functions with various edge cases
internal/ghmcp/server.go Refactors server initialization to use new github package utilities, replacing the monolithic cleanToolsets function
internal/ghmcp/server_test.go Removes tests for the deleted cleanToolsets function (now covered in pkg/github/tools_test.go)

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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@kerobbi kerobbi left a comment

Choose a reason for hiding this comment

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

lgtm!

return result
}

func ContainsToolset(tools []string, toCheck string) bool {
Copy link
Contributor

@JoannaaKL JoannaaKL Oct 21, 2025

Choose a reason for hiding this comment

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

Can we actually operate on maps everywhere? Right now this function is O(N) because it needs to iterate over all tools in the array, with a map it'd be an O(1). You'd need to refactor CleanToolsets to achieve that

Copy link
Contributor

@JoannaaKL JoannaaKL Oct 21, 2025

Choose a reason for hiding this comment

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

Or at least CleanToolsets could return a map and an array

Copy link
Contributor Author

@tonytrg tonytrg Oct 21, 2025
edited
Loading

Choose a reason for hiding this comment

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

we are passing lists everywhere, also the libraries expect lists too.

As the tool lists are pretty small we have a neglible performance gain and would have to transform the lists into maps which is more costly probably.

But the biggest hit would be having now to manage transformations between lists and maps everywhere in the codebase where these functions are used, if the utils are maps then they couldnt be used in all the places currently(they are lists everywhere).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/github/github-mcp-server/pull/1273/files#diff-efffdb5f6c0e96b376f9f02d7a887ea629058c21a95e161981c5c08e41f12e0cR109 example we would transform it into a map and then back to a list. iterating through the list is the lesser evil

@tonytrg tonytrg merged commit c019595 into main Oct 21, 2025
16 checks passed
@tonytrg tonytrg deleted the tonytrg/make-toolset-functionality-public branch October 21, 2025 13:57
Copy link

@StefanXhunga StefanXhunga left a comment

Choose a reason for hiding this comment

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

Hello everyone, thank you for support

Copy link

@StefanXhunga StefanXhunga left a comment

Choose a reason for hiding this comment

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

Hello everyone, thank you for support

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

Reviewers

@JoannaaKL JoannaaKL JoannaaKL left review comments

Copilot code review Copilot Copilot left review comments

@kerobbi kerobbi kerobbi approved these changes

+1 more reviewer

@StefanXhunga StefanXhunga StefanXhunga left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /