- Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: Add get organization members and list all outside collaborators of an organization #1508
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| { | ||
| "annotations": { | ||
| "title": "Get organization members", | ||
| "readOnlyHint": true | ||
| }, | ||
| "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", | ||
| "inputSchema": { | ||
| "properties": { | ||
| "org": { | ||
| "description": "Organization login (owner) to get members for.", | ||
| "type": "string" | ||
| }, | ||
| "page": { | ||
| "description": "Page number for pagination", | ||
| "type": "number" | ||
| }, | ||
| "per_page": { | ||
| "description": "Results per page (max 100)", | ||
| "type": "number" | ||
| }, | ||
| "role": { | ||
| "description": "Filter by role: all, admin, member", | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "org" | ||
| ], | ||
| "type": "object" | ||
| }, | ||
| "name": "get_org_members" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| "annotations": { | ||
| "title": "List outside collaborators", | ||
| "readOnlyHint": true | ||
| }, | ||
| "description": "List all outside collaborators of an organization (users with access to organization repositories but not members).", | ||
| "inputSchema": { | ||
| "properties": { | ||
| "org": { | ||
| "description": "The organization name", | ||
| "type": "string" | ||
| }, | ||
| "page": { | ||
| "description": "Page number for pagination", | ||
| "type": "number" | ||
| }, | ||
| "per_page": { | ||
| "description": "Results per page (max 100)", | ||
| "type": "number" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "org" | ||
| ], | ||
| "type": "object" | ||
| }, | ||
| "name": "list_outside_collaborators" | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| | @@ -2,10 +2,14 @@ package github | |||||
| | ||||||
| import ( | ||||||
| "context" | ||||||
| "fmt" | ||||||
| "strings" | ||||||
| "time" | ||||||
| | ||||||
| ghErrors "github.com/github/github-mcp-server/pkg/errors" | ||||||
| "github.com/github/github-mcp-server/pkg/translations" | ||||||
| "github.com/go-viper/mapstructure/v2" | ||||||
| "github.com/google/go-github/v79/github" | ||||||
| "github.com/mark3labs/mcp-go/mcp" | ||||||
| "github.com/mark3labs/mcp-go/server" | ||||||
| "github.com/shurcooL/githubv4" | ||||||
| | @@ -103,6 +107,14 @@ type OrganizationTeams struct { | |||||
| Teams []TeamInfo `json:"teams"` | ||||||
| } | ||||||
| | ||||||
| type OutUser struct { | ||||||
| Login string `json:"login"` | ||||||
| ID string `json:"id"` | ||||||
| AvatarURL string `json:"avatar_url"` | ||||||
| Type string `json:"type"` | ||||||
| SiteAdmin bool `json:"site_admin"` | ||||||
| } | ||||||
| | ||||||
| func GetTeams(getClient GetClientFn, getGQLClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { | ||||||
| return mcp.NewTool("get_teams", | ||||||
| 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")), | ||||||
| | @@ -249,3 +261,172 @@ func GetTeamMembers(getGQLClient GetGQLClientFn, t translations.TranslationHelpe | |||||
| return MarshalledTextResult(members), nil | ||||||
| } | ||||||
| } | ||||||
| | ||||||
| func GetOrgMembers(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { | ||||||
| return mcp.NewTool("get_org_members", | ||||||
| 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")), | ||||||
| ||||||
| 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")), | |
| 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, site_admin. Limited to organizations accessible with current credentials")), |
Copilot AI Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These intermediate variable assignments (lines 297-300) are unnecessary and reduce code clarity. The params struct fields (params.Org, params.Role, etc.) can be used directly throughout the function, which is the pattern followed by other tools in the codebase (e.g., GetDiscussion and GetDiscussionComments in discussions.go).
Copilot AI Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conversion logic from *github.User to OutUser is duplicated between GetOrgMembers (lines 340-349) and ListOutsideCollaborators (lines 419-428). Consider extracting this into a helper function (e.g., convertToOutUser) following the pattern used in minimal_types.go (see convertToMinimalUser) to improve maintainability and reduce code duplication.
Copilot AI Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tool description should explicitly list all returned fields for consistency with other tools in the codebase. Consider adding "Returns a list of user objects with fields: login, id, avatar_url, type, site_admin" to match the pattern used in get_org_members and provide clarity about the response structure.
| mcp.WithDescription(t("TOOL_LIST_OUTSIDE_COLLABORATORS_DESCRIPTION", "List all outside collaborators of an organization (users with access to organization repositories but not members).")), | |
| mcp.WithDescription(t("TOOL_LIST_OUTSIDE_COLLABORATORS_DESCRIPTION", "List all outside collaborators of an organization (users with access to organization repositories but not members). Returns a list of user objects with fields: login, id, avatar_url, type, site_admin.")), |
Copilot AI Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These intermediate variable assignments (lines 383-385) are unnecessary and reduce code clarity. The params struct fields (params.Org, params.PerPage, params.Page) can be used directly throughout the function, which is the pattern followed by other tools in the codebase (e.g., GetDiscussion and GetDiscussionComments in discussions.go).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
OutUserstruct should useint64for theIDfield instead ofstringto maintain consistency with the existingMinimalUserstruct inminimal_types.go. The existing pattern usesID int64 \json:"id,omitempty"`throughout the codebase. The conversion logic inGetOrgMembers(line 344) andListOutsideCollaborators(line 423) should be updated fromfmt.Sprintf("%v", u.GetID())to justu.GetID()`.