Movatterモバイル変換


[0]ホーム

URL:


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

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

Open
cointem wants to merge4 commits intogithub:main
base:main
Choose a base branch
Loading
fromcointem:feature/org
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -600,13 +600,24 @@ The following sets of tools are available:
- **get_me** - Get my user profile
- No parameters required

- **get_org_members** - Get organization members
- `org`: Organization login (owner) to get members for. (string, required)
- `page`: Page number for pagination (number, optional)
- `per_page`: Results per page (max 100) (number, optional)
- `role`: Filter by role: all, admin, member (string, optional)

- **get_team_members** - Get team members
- `org`: Organization login (owner) that contains the team. (string, required)
- `team_slug`: Team slug (string, required)

- **get_teams** - Get teams
- `user`: Username to get teams for. If not provided, uses the authenticated user. (string, optional)

- **list_outside_collaborators** - List outside collaborators
- `org`: The organization name (string, required)
- `page`: Page number for pagination (number, optional)
- `per_page`: Results per page (max 100) (number, optional)

</details>

<details>
Expand Down
2 changes: 1 addition & 1 deletiondocs/remote-server.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,7 +19,7 @@ Below is a table of available toolsets for the remote GitHub MCP Server. Each to
<!-- START AUTOMATED TOOLSETS -->
| Name | Description | API URL | 1-Click Install (VS Code) | Read-only Link | 1-Click Read-only Install (VS Code) |
|----------------|--------------------------------------------------|-------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|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) |
|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) |
| 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) |
| 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) |
| 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) |
Expand Down
32 changes: 32 additions & 0 deletionspkg/github/__toolsnaps__/get_org_members.snap
View file
Open in desktop
Original file line numberDiff line numberDiff 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"
}
28 changes: 28 additions & 0 deletionspkg/github/__toolsnaps__/list_outside_collaborators.snap
View file
Open in desktop
Original file line numberDiff line numberDiff 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"
}
181 changes: 181 additions & 0 deletionspkg/github/context_tools.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Copy link

CopilotAIDec 1, 2025

Choose a reason for hiding this comment

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

TheOutUser struct should useint64 for theID field instead ofstring to maintain consistency with the existingMinimalUser struct 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()`.

Copilot uses AI. Check for mistakes.

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")),
Expand DownExpand Up@@ -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")),
Copy link

CopilotAIDec 1, 2025

Choose a reason for hiding this comment

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

The tool description claims to return "login, id, avatar_url, type" but the implementation also returnssite_admin. The description should be updated to includesite_admin in the list of returned fields for accuracy.

Suggested change
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 uses AI. Check for mistakes.
mcp.WithString("org",
mcp.Description(t("TOOL_GET_ORG_MEMBERS_ORG_DESCRIPTION", "Organization login (owner) to get members for.")),
mcp.Required(),
),
mcp.WithString("role",
mcp.Description("Filter by role: all, admin, member"),
),
mcp.WithNumber("per_page",
mcp.Description("Results per page (max 100)"),
),
mcp.WithNumber("page",
mcp.Description("Page number for pagination"),
),
mcp.WithToolAnnotation(mcp.ToolAnnotation{
Title: t("TOOL_GET_ORG_MEMBERS_TITLE", "Get organization members"),
ReadOnlyHint: ToBoolPtr(true),
}),
),
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
// Decode params into struct to support optional numbers
var params struct {
Org string `mapstructure:"org"`
Role string `mapstructure:"role"`
PerPage int32 `mapstructure:"per_page"`
Page int32 `mapstructure:"page"`
}
if err := mapstructure.Decode(request.Params.Arguments, &params); err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
org := params.Org
role := params.Role
perPage := params.PerPage
page := params.Page
Comment on lines +297 to +300
Copy link

CopilotAIDec 1, 2025

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).

Copilot uses AI. Check for mistakes.
if org == "" {
return mcp.NewToolResultError("org is required"), nil
}

// Defaults
if perPage <= 0 {
perPage = 30
}
if perPage > 100 {
perPage = 100
}
if page <= 0 {
page = 1
}
client, err := getClient(ctx)
if err != nil {
return mcp.NewToolResultErrorFromErr("failed to get GitHub client", err), nil
}

// Map role string to REST role filter expected by GitHub API ("all","admin","member").
roleFilter := ""
if role != "" && strings.ToLower(role) != "all" {
roleFilter = strings.ToLower(role)
}

// Use Organizations.ListMembers with pagination (page/per_page)
opts := &github.ListMembersOptions{
Role: roleFilter,
ListOptions: github.ListOptions{
PerPage: int(perPage),
Page: int(page),
},
}

users, resp, err := client.Organizations.ListMembers(ctx, org, opts)
if err != nil {
return ghErrors.NewGitHubAPIErrorResponse(ctx, "Failed to get organization members", resp, err), nil
}

var members []OutUser
for _, u := range users {
members = append(members, OutUser{
Login: u.GetLogin(),
ID: fmt.Sprintf("%v", u.GetID()),
AvatarURL: u.GetAvatarURL(),
Type: u.GetType(),
SiteAdmin: u.GetSiteAdmin(),
})
}
Comment on lines +340 to +349
Copy link

CopilotAIDec 1, 2025

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.

Copilot uses AI. Check for mistakes.

return MarshalledTextResult(members), nil
}
}

func ListOutsideCollaborators(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) {
return mcp.NewTool("list_outside_collaborators",
mcp.WithDescription(t("TOOL_LIST_OUTSIDE_COLLABORATORS_DESCRIPTION", "List all outside collaborators of an organization (users with access to organization repositories but not members).")),
Copy link

CopilotAIDec 1, 2025

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.

Suggested change
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 uses AI. Check for mistakes.
mcp.WithString("org",
mcp.Description(t("TOOL_LIST_OUTSIDE_COLLABORATORS_ORG_DESCRIPTION", "The organization name")),
mcp.Required(),
),
mcp.WithNumber("per_page",
mcp.Description("Results per page (max 100)"),
),
mcp.WithNumber("page",
mcp.Description("Page number for pagination"),
),
mcp.WithToolAnnotation(mcp.ToolAnnotation{
Title: t("TOOL_LIST_OUTSIDE_COLLABORATORS_TITLE", "List outside collaborators"),
ReadOnlyHint: ToBoolPtr(true),
}),
),
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
// Decode params into struct to support optional numbers
var params struct {
Org string `mapstructure:"org"`
PerPage int32 `mapstructure:"per_page"`
Page int32 `mapstructure:"page"`
}
if err := mapstructure.Decode(request.Params.Arguments, &params); err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
org := params.Org
perPage := params.PerPage
page := params.Page
Comment on lines +383 to +385
Copy link

CopilotAIDec 1, 2025

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).

Copilot uses AI. Check for mistakes.
if org == "" {
return mcp.NewToolResultError("org is required"), nil
}

// Defaults
if perPage <= 0 {
perPage = 30
}
if perPage > 100 {
perPage = 100
}
if page <= 0 {
page = 1
}

client, err := getClient(ctx)
if err != nil {
return mcp.NewToolResultErrorFromErr("failed to get GitHub client", err), nil
}

// Use Organizations.ListOutsideCollaborators with pagination
opts := &github.ListOutsideCollaboratorsOptions{
ListOptions: github.ListOptions{
PerPage: int(perPage),
Page: int(page),
},
}

users, resp, err := client.Organizations.ListOutsideCollaborators(ctx, org, opts)
if err != nil {
return ghErrors.NewGitHubAPIErrorResponse(ctx, "Failed to list outside collaborators", resp, err), nil
}

var collaborators []OutUser
for _, u := range users {
collaborators = append(collaborators, OutUser{
Login: u.GetLogin(),
ID: fmt.Sprintf("%v", u.GetID()),
AvatarURL: u.GetAvatarURL(),
Type: u.GetType(),
SiteAdmin: u.GetSiteAdmin(),
})
}

return MarshalledTextResult(collaborators), nil
}
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp