- Notifications
You must be signed in to change notification settings - Fork3.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 ourterms of service andprivacy 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 fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
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"` | ||||||
| } | ||||||
Comment on lines +110 to +116 CopilotAI | ||||||
| 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")), | ||||||
CopilotAI | ||||||
| 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")), |
CopilotAIDec 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 andGetDiscussionComments indiscussions.go).
CopilotAIDec 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 toOutUser is duplicated betweenGetOrgMembers (lines 340-349) andListOutsideCollaborators (lines 419-428). Consider extracting this into a helper function (e.g.,convertToOutUser) following the pattern used inminimal_types.go (seeconvertToMinimalUser) to improve maintainability and reduce code duplication.
CopilotAIDec 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 inget_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.")), |
CopilotAIDec 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 andGetDiscussionComments indiscussions.go).
Uh oh!
There was an error while loading.Please reload this page.