Skip to content

Commit 6ed2205

Browse files
author
cointem
committed
fix:extract OutUser struct to file-level to remove duplication
fix: change method name capitalization to adjust export visibility
1 parent 09fd97b commit 6ed2205

File tree

4 files changed

+21
-29
lines changed

4 files changed

+21
-29
lines changed

docs/remote-server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Below is a table of available toolsets for the remote GitHub MCP Server. Each to
1919
<!-- START AUTOMATED TOOLSETS -->
2020
| Name | Description | API URL | 1-Click Install (VS Code) | Read-only Link | 1-Click Read-only Install (VS Code) |
2121
|----------------|--------------------------------------------------|-------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
22-
| Default | ["Default" toolset](../README.md#default-toolset) | https://api.githubcopilot.com/mcp/ | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) | [read-only](https://api.githubcopilot.com/mcp/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Freadonly%22%7D) |
22+
| all | All available GitHub MCP tools | https://api.githubcopilot.com/mcp/ | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) | [read-only](https://api.githubcopilot.com/mcp/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Freadonly%22%7D) |
2323
| Actions | GitHub Actions workflows and CI/CD operations | https://api.githubcopilot.com/mcp/x/actions | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-actions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Factions%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/actions/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-actions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Factions%2Freadonly%22%7D) |
2424
| Code Security | Code security related tools, such as GitHub Code Scanning | https://api.githubcopilot.com/mcp/x/code_security | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-code_security&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcode_security%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/code_security/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-code_security&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcode_security%2Freadonly%22%7D) |
2525
| Dependabot | Dependabot tools | https://api.githubcopilot.com/mcp/x/dependabot | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-dependabot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdependabot%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/dependabot/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-dependabot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdependabot%2Freadonly%22%7D) |

pkg/github/context_tools.go

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ type OrganizationTeams struct {
107107
Teams []TeamInfo `json:"teams"`
108108
}
109109

110+
type OutUser struct {
111+
Login string `json:"login"`
112+
ID string `json:"id"`
113+
AvatarURL string `json:"avatar_url"`
114+
Type string `json:"type"`
115+
SiteAdmin bool `json:"site_admin"`
116+
}
117+
110118
func GetTeams(getClient GetClientFn, getGQLClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) {
111119
return mcp.NewTool("get_teams",
112120
mcp.WithDescription(t("TOOL_GET_TEAMS_DESCRIPTION", "Get details of the teams the user is a member of. Limited to organizations accessible with current credentials")),
@@ -254,7 +262,7 @@ func GetTeamMembers(getGQLClient GetGQLClientFn, t translations.TranslationHelpe
254262
}
255263
}
256264

257-
func getOrgMembers(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) {
265+
func GetOrgMembers(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) {
258266
return mcp.NewTool("get_org_members",
259267
mcp.WithDescription(t("TOOL_GET_ORG_MEMBERS_DESCRIPTION", "Get member users of a specific organization. Returns a list of user objects with fields: login, id, avatar_url, type. Limited to organizations accessible with current credentials")),
260268
mcp.WithString("org",
@@ -329,17 +337,9 @@ func getOrgMembers(getClient GetClientFn, t translations.TranslationHelperFunc)
329337
return ghErrors.NewGitHubAPIErrorResponse(ctx, "Failed to get organization members", resp, err), nil
330338
}
331339

332-
type outUser struct {
333-
Login string `json:"login"`
334-
ID string `json:"id"`
335-
AvatarURL string `json:"avatar_url"`
336-
Type string `json:"type"`
337-
SiteAdmin bool `json:"site_admin"`
338-
}
339-
340-
var members []outUser
340+
var members []OutUser
341341
for _, u := range users {
342-
members = append(members, outUser{
342+
members = append(members, OutUser{
343343
Login: u.GetLogin(),
344344
ID: fmt.Sprintf("%v", u.GetID()),
345345
AvatarURL: u.GetAvatarURL(),
@@ -352,7 +352,7 @@ func getOrgMembers(getClient GetClientFn, t translations.TranslationHelperFunc)
352352
}
353353
}
354354

355-
func listOutsideCollaborators(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) {
355+
func ListOutsideCollaborators(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) {
356356
return mcp.NewTool("list_outside_collaborators",
357357
mcp.WithDescription(t("TOOL_LIST_OUTSIDE_COLLABORATORS_DESCRIPTION", "List all outside collaborators of an organization (users with access to organization repositories but not members).")),
358358
mcp.WithString("org",
@@ -416,17 +416,9 @@ func listOutsideCollaborators(getClient GetClientFn, t translations.TranslationH
416416
return ghErrors.NewGitHubAPIErrorResponse(ctx, "Failed to list outside collaborators", resp, err), nil
417417
}
418418

419-
type outUser struct {
420-
Login string `json:"login"`
421-
ID string `json:"id"`
422-
AvatarURL string `json:"avatar_url"`
423-
Type string `json:"type"`
424-
SiteAdmin bool `json:"site_admin"`
425-
}
426-
427-
var collaborators []outUser
419+
var collaborators []OutUser
428420
for _, u := range users {
429-
collaborators = append(collaborators, outUser{
421+
collaborators = append(collaborators, OutUser{
430422
Login: u.GetLogin(),
431423
ID: fmt.Sprintf("%v", u.GetID()),
432424
AvatarURL: u.GetAvatarURL(),

pkg/github/context_tools_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ func Test_GetTeamMembers(t *testing.T) {
502502
func Test_GetOrgMembers(t *testing.T) {
503503
t.Parallel()
504504

505-
tool, _ := getOrgMembers(nil, translations.NullTranslationHelper)
505+
tool, _ := GetOrgMembers(nil, translations.NullTranslationHelper)
506506
require.NoError(t, toolsnaps.Test(tool.Name, tool))
507507

508508
assert.Equal(t, "get_org_members", tool.Name)
@@ -577,7 +577,7 @@ func Test_GetOrgMembers(t *testing.T) {
577577
t.Run(tc.name, func(t *testing.T) {
578578
stubFn := tc.stubbedGetClientFn
579579

580-
_, handler := getOrgMembers(stubFn, translations.NullTranslationHelper)
580+
_, handler := GetOrgMembers(stubFn, translations.NullTranslationHelper)
581581

582582
request := createMCPRequest(tc.requestArgs)
583583
result, err := handler(context.Background(), request)
@@ -608,7 +608,7 @@ func Test_GetOrgMembers(t *testing.T) {
608608
func Test_ListOutsideCollaborators(t *testing.T) {
609609
t.Parallel()
610610

611-
tool, _ := listOutsideCollaborators(nil, translations.NullTranslationHelper)
611+
tool, _ := ListOutsideCollaborators(nil, translations.NullTranslationHelper)
612612
require.NoError(t, toolsnaps.Test(tool.Name, tool))
613613

614614
assert.Equal(t, "list_outside_collaborators", tool.Name)
@@ -682,7 +682,7 @@ func Test_ListOutsideCollaborators(t *testing.T) {
682682
t.Run(tc.name, func(t *testing.T) {
683683
stubFn := tc.stubbedGetClientFn
684684

685-
_, handler := listOutsideCollaborators(stubFn, translations.NullTranslationHelper)
685+
_, handler := ListOutsideCollaborators(stubFn, translations.NullTranslationHelper)
686686

687687
request := createMCPRequest(tc.requestArgs)
688688
result, err := handler(context.Background(), request)

pkg/github/tools.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ func DefaultToolsetGroup(readOnly bool, getClient GetClientFn, getGQLClient GetG
314314
toolsets.NewServerTool(GetMe(getClient, t)),
315315
toolsets.NewServerTool(GetTeams(getClient, getGQLClient, t)),
316316
toolsets.NewServerTool(GetTeamMembers(getGQLClient, t)),
317-
toolsets.NewServerTool(getOrgMembers(getClient, t)),
318-
toolsets.NewServerTool(listOutsideCollaborators(getClient, t)),
317+
toolsets.NewServerTool(GetOrgMembers(getClient, t)),
318+
toolsets.NewServerTool(ListOutsideCollaborators(getClient, t)),
319319
)
320320

321321
gists := toolsets.NewToolset(ToolsetMetadataGists.ID, ToolsetMetadataGists.Description).

0 commit comments

Comments
 (0)