Skip to content

Commit c91c4d0

Browse files
committed
extracting into subspecializations for tools
1 parent 69f4f7b commit c91c4d0

File tree

2 files changed

+57
-23
lines changed

2 files changed

+57
-23
lines changed

cmd/github-mcp-server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func init() {
6969
rootCmd.SetVersionTemplate("{{.Short}}\n{{.Version}}\n")
7070

7171
// Add global flags that will be shared by all commands
72-
rootCmd.PersistentFlags().StringSlice("toolsets", github.DefaultTools, "An optional comma separated list of groups of tools to allow")
72+
rootCmd.PersistentFlags().StringSlice("toolsets", github.DefaultTools(), "An optional comma separated list of groups of tools to allow")
7373
rootCmd.PersistentFlags().Bool("dynamic-toolsets", false, "Enable dynamic toolsets")
7474
rootCmd.PersistentFlags().Bool("read-only", false, "Restrict the server to read-only operations")
7575
rootCmd.PersistentFlags().String("log-file", "", "Path to log file")

pkg/github/tools.go

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ type Toolset string
1919
const (
2020
ToolsetContext Toolset = "context"
2121
ToolsetRepos Toolset = "repos"
22+
ToolsetContents Toolset = "contents"
23+
ToolsetReleases Toolset = "releases"
2224
ToolsetIssues Toolset = "issues"
25+
ToolsetSubIssues Toolset = "sub_issues"
2326
ToolsetUsers Toolset = "users"
2427
ToolsetOrgs Toolset = "orgs"
2528
ToolsetPullRequests Toolset = "pull_requests"
29+
ToolsetPullRequestReviews Toolset = "pull_request_reviews"
2630
ToolsetCodeSecurity Toolset = "code_security"
2731
ToolsetSecretProtection Toolset = "secret_protection"
2832
ToolsetDependabot Toolset = "dependabot"
@@ -37,35 +41,33 @@ const (
3741
ToolsetDynamic Toolset = "dynamic"
3842
)
3943

40-
// DefaultTools contains the default toolsets to enable
41-
var DefaultTools = []Toolset{ToolsetContext, ToolsetRepos, ToolsetIssues, ToolsetPullRequests}
44+
// DefaultToolsets contains the default toolsets to enable
45+
var DefaultToolsets = []Toolset{ToolsetContext, ToolsetRepos, ToolsetIssues, ToolsetPullRequests}
46+
47+
// DefaultTools returns the default toolset names as strings for CLI flags
48+
func DefaultTools() []string {
49+
return []string{string(ToolsetContext), string(ToolsetRepos), string(ToolsetIssues), string(ToolsetPullRequests)}
50+
}
4251

4352
func DefaultToolsetGroup(readOnly bool, getClient GetClientFn, getGQLClient GetGQLClientFn, getRawClient raw.GetRawClientFn, t translations.TranslationHelperFunc, contentWindowSize int) *toolsets.ToolsetGroup {
4453
tsg := toolsets.NewToolsetGroup(readOnly)
4554

4655
// Define all available features with their default state (disabled)
4756
// Create toolsets
48-
repos := toolsets.NewToolset(string(ToolsetRepos), "GitHub Repository related tools").
57+
repos := toolsets.NewToolset(string(ToolsetRepos), "GitHub Repository management - search, create, fork, branches, commits, tags").
4958
AddReadTools(
5059
toolsets.NewServerTool(SearchRepositories(getClient, t)),
51-
toolsets.NewServerTool(GetFileContents(getClient, getRawClient, t)),
5260
toolsets.NewServerTool(ListCommits(getClient, t)),
5361
toolsets.NewServerTool(SearchCode(getClient, t)),
5462
toolsets.NewServerTool(GetCommit(getClient, t)),
5563
toolsets.NewServerTool(ListBranches(getClient, t)),
5664
toolsets.NewServerTool(ListTags(getClient, t)),
5765
toolsets.NewServerTool(GetTag(getClient, t)),
58-
toolsets.NewServerTool(ListReleases(getClient, t)),
59-
toolsets.NewServerTool(GetLatestRelease(getClient, t)),
60-
toolsets.NewServerTool(GetReleaseByTag(getClient, t)),
6166
).
6267
AddWriteTools(
63-
toolsets.NewServerTool(CreateOrUpdateFile(getClient, t)),
6468
toolsets.NewServerTool(CreateRepository(getClient, t)),
6569
toolsets.NewServerTool(ForkRepository(getClient, t)),
6670
toolsets.NewServerTool(CreateBranch(getClient, t)),
67-
toolsets.NewServerTool(PushFiles(getClient, t)),
68-
toolsets.NewServerTool(DeleteFile(getClient, t)),
6971
).
7072
AddResourceTemplates(
7173
toolsets.NewServerResourceTemplate(GetRepositoryResourceContent(getClient, getRawClient, t)),
@@ -74,27 +76,51 @@ func DefaultToolsetGroup(readOnly bool, getClient GetClientFn, getGQLClient GetG
7476
toolsets.NewServerResourceTemplate(GetRepositoryResourceTagContent(getClient, getRawClient, t)),
7577
toolsets.NewServerResourceTemplate(GetRepositoryResourcePrContent(getClient, getRawClient, t)),
7678
)
77-
issues := toolsets.NewToolset(string(ToolsetIssues), "GitHub Issues related tools").
79+
80+
contents := toolsets.NewToolset(string(ToolsetContents), "Repository contents - get, create, update, delete files and directories").
81+
AddReadTools(
82+
toolsets.NewServerTool(GetFileContents(getClient, getRawClient, t)),
83+
).
84+
AddWriteTools(
85+
toolsets.NewServerTool(CreateOrUpdateFile(getClient, t)),
86+
toolsets.NewServerTool(PushFiles(getClient, t)),
87+
toolsets.NewServerTool(DeleteFile(getClient, t)),
88+
)
89+
90+
releases := toolsets.NewToolset(string(ToolsetReleases), "GitHub Repository releases - list, get, and manage releases").
91+
AddReadTools(
92+
toolsets.NewServerTool(ListReleases(getClient, t)),
93+
toolsets.NewServerTool(GetLatestRelease(getClient, t)),
94+
toolsets.NewServerTool(GetReleaseByTag(getClient, t)),
95+
)
96+
97+
issues := toolsets.NewToolset(string(ToolsetIssues), "GitHub Issues - create, read, update, comment on issues").
7898
AddReadTools(
7999
toolsets.NewServerTool(GetIssue(getClient, t)),
80100
toolsets.NewServerTool(SearchIssues(getClient, t)),
81101
toolsets.NewServerTool(ListIssues(getGQLClient, t)),
82102
toolsets.NewServerTool(GetIssueComments(getClient, t)),
83103
toolsets.NewServerTool(ListIssueTypes(getClient, t)),
84-
toolsets.NewServerTool(ListSubIssues(getClient, t)),
85104
).
86105
AddWriteTools(
87106
toolsets.NewServerTool(CreateIssue(getClient, t)),
88107
toolsets.NewServerTool(AddIssueComment(getClient, t)),
89108
toolsets.NewServerTool(UpdateIssue(getClient, getGQLClient, t)),
90109
toolsets.NewServerTool(AssignCopilotToIssue(getGQLClient, t)),
91-
toolsets.NewServerTool(AddSubIssue(getClient, t)),
92-
toolsets.NewServerTool(RemoveSubIssue(getClient, t)),
93-
toolsets.NewServerTool(ReprioritizeSubIssue(getClient, t)),
94110
).AddPrompts(
95111
toolsets.NewServerPrompt(AssignCodingAgentPrompt(t)),
96112
toolsets.NewServerPrompt(IssueToFixWorkflowPrompt(t)),
97113
)
114+
115+
subIssues := toolsets.NewToolset(string(ToolsetSubIssues), "Sub-issue management - create, manage, and organize sub-issues").
116+
AddReadTools(
117+
toolsets.NewServerTool(ListSubIssues(getClient, t)),
118+
).
119+
AddWriteTools(
120+
toolsets.NewServerTool(AddSubIssue(getClient, t)),
121+
toolsets.NewServerTool(RemoveSubIssue(getClient, t)),
122+
toolsets.NewServerTool(ReprioritizeSubIssue(getClient, t)),
123+
)
98124
users := toolsets.NewToolset(string(ToolsetUsers), "GitHub User related tools").
99125
AddReadTools(
100126
toolsets.NewServerTool(SearchUsers(getClient, t)),
@@ -103,25 +129,29 @@ func DefaultToolsetGroup(readOnly bool, getClient GetClientFn, getGQLClient GetG
103129
AddReadTools(
104130
toolsets.NewServerTool(SearchOrgs(getClient, t)),
105131
)
106-
pullRequests := toolsets.NewToolset(string(ToolsetPullRequests), "GitHub Pull Request related tools").
132+
pullRequests := toolsets.NewToolset(string(ToolsetPullRequests), "GitHub Pull Request operations - create, read, update, merge").
107133
AddReadTools(
108134
toolsets.NewServerTool(GetPullRequest(getClient, t)),
109135
toolsets.NewServerTool(ListPullRequests(getClient, t)),
110136
toolsets.NewServerTool(GetPullRequestFiles(getClient, t)),
111137
toolsets.NewServerTool(SearchPullRequests(getClient, t)),
112138
toolsets.NewServerTool(GetPullRequestStatus(getClient, t)),
113-
toolsets.NewServerTool(GetPullRequestReviewComments(getClient, t)),
114-
toolsets.NewServerTool(GetPullRequestReviews(getClient, t)),
115139
toolsets.NewServerTool(GetPullRequestDiff(getClient, t)),
116140
).
117141
AddWriteTools(
118-
toolsets.NewServerTool(MergePullRequest(getClient, t)),
119-
toolsets.NewServerTool(UpdatePullRequestBranch(getClient, t)),
120142
toolsets.NewServerTool(CreatePullRequest(getClient, t)),
121143
toolsets.NewServerTool(UpdatePullRequest(getClient, getGQLClient, t)),
122-
toolsets.NewServerTool(RequestCopilotReview(getClient, t)),
144+
toolsets.NewServerTool(MergePullRequest(getClient, t)),
145+
toolsets.NewServerTool(UpdatePullRequestBranch(getClient, t)),
146+
)
123147

124-
// Reviews
148+
pullRequestReviews := toolsets.NewToolset(string(ToolsetPullRequestReviews), "Pull request review operations - create, submit, manage reviews").
149+
AddReadTools(
150+
toolsets.NewServerTool(GetPullRequestReviewComments(getClient, t)),
151+
toolsets.NewServerTool(GetPullRequestReviews(getClient, t)),
152+
).
153+
AddWriteTools(
154+
toolsets.NewServerTool(RequestCopilotReview(getClient, t)),
125155
toolsets.NewServerTool(CreateAndSubmitPullRequestReview(getGQLClient, t)),
126156
toolsets.NewServerTool(CreatePendingPullRequestReview(getGQLClient, t)),
127157
toolsets.NewServerTool(AddCommentToPendingReview(getGQLClient, t)),
@@ -225,10 +255,14 @@ func DefaultToolsetGroup(readOnly bool, getClient GetClientFn, getGQLClient GetG
225255
// Add toolsets to the group
226256
tsg.AddToolset(contextTools)
227257
tsg.AddToolset(repos)
258+
tsg.AddToolset(contents)
259+
tsg.AddToolset(releases)
228260
tsg.AddToolset(issues)
261+
tsg.AddToolset(subIssues)
229262
tsg.AddToolset(orgs)
230263
tsg.AddToolset(users)
231264
tsg.AddToolset(pullRequests)
265+
tsg.AddToolset(pullRequestReviews)
232266
tsg.AddToolset(actions)
233267
tsg.AddToolset(codeSecurity)
234268
tsg.AddToolset(secretProtection)

0 commit comments

Comments
 (0)