Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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 deletions README.md
Original file line number Diff line number Diff 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 deletion docs/remote-server.md
Original file line number Diff line number Diff 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 deletions pkg/github/__toolsnaps__/get_org_members.snap
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"
}
28 changes: 28 additions & 0 deletions pkg/github/__toolsnaps__/list_outside_collaborators.snap
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"
}
181 changes: 181 additions & 0 deletions pkg/github/context_tools.go
Original file line number Diff line number Diff 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 Down Expand 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 thread
cointem marked this conversation as resolved.

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 Down Expand 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")),
Comment thread
cointem marked this conversation as resolved.
Outdated
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 thread
cointem marked this conversation as resolved.
Outdated
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 thread
cointem marked this conversation as resolved.
Outdated

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).")),
Comment thread
cointem marked this conversation as resolved.
Outdated
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 thread
cointem marked this conversation as resolved.
Outdated
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