Skip to content

feat: check org membership#2473

Closed
cbartz wants to merge 5 commits into
github:mainfrom
cbartz:feat/check-org-membership
Closed

feat: check org membership#2473
cbartz wants to merge 5 commits into
github:mainfrom
cbartz:feat/check-org-membership

Conversation

@cbartz
Copy link
Copy Markdown

@cbartz cbartz commented May 13, 2026

  • Adds a check_org_membership tool that looks up whether a user belongs to a given GitHub organization.
  • Includes unit tests, a tool snapshot, and updates to the README and server configuration docs.

Changes

  • pkg/github/orgs.go + orgs_test.go — tool implementation and tests
  • pkg/github/toolsnaps/check_org_membership.snap — tool schema snapshot
  • pkg/github/tools.go, pkg/github/helper_test.go — registration and test plumbing
  • README.md, docs/server-configuration.md — docs

Copilot AI review requested due to automatic review settings May 13, 2026 14:10
@cbartz cbartz requested a review from a team as a code owner May 13, 2026 14:10
@cbartz cbartz closed this May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new organization membership lookup tool for the GitHub MCP Server, while also introducing broader HTTP authentication and PR mutation guardrail changes.

Changes:

  • Added check_org_membership tool, schema snapshot, registration, and tests.
  • Added PR author allowlist enforcement across many mutating PR-related tools.
  • Added HTTP server-side default token fallback behavior and documentation.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
README.md Documents the new org membership tool plus PR allowlist/default-token behavior.
pkg/utils/token.go Extracts token-type parsing into reusable ParseToken.
pkg/http/server.go Adds HTTP token fallback and PR author allowlist config plumbing.
pkg/http/middleware/token.go Uses a default token when Authorization is missing.
pkg/http/middleware/token_test.go Adds token fallback middleware tests.
pkg/http/handler.go Passes HTTP default token into auth middleware.
pkg/github/tools.go Registers the new org membership tool.
pkg/github/server.go Adds PR author allowlist to MCP server config.
pkg/github/server_test.go Updates test dependency stub for new interface method.
pkg/github/pullrequests.go Enforces PR author allowlist in existing PR mutation handlers.
pkg/github/pullrequests_granular.go Enforces PR author allowlist in granular PR mutation handlers.
pkg/github/pr_author_allowlist.go Adds shared PR author allowlist helpers/enforcement.
pkg/github/pr_author_allowlist_test.go Tests allowlist helper and merge-denial behavior.
pkg/github/orgs.go Implements check_org_membership.
pkg/github/orgs_test.go Tests org membership tool behavior and schema.
pkg/github/issues.go Applies PR author allowlist to comments on PR-backed issues.
pkg/github/issues_test.go Tests PR comment denial via issue comment tool.
pkg/github/helper_test.go Adds org endpoint constants for tests.
pkg/github/dependencies.go Adds allowlist state and API to dependency implementations.
pkg/github/copilot.go Enforces PR author allowlist before requesting Copilot review.
pkg/github/copilot_test.go Tests Copilot review denial for disallowed PR author.
pkg/github/toolsnaps/check_org_membership.snap Adds tool schema snapshot.
internal/ghmcp/server.go Wires allowlist config into stdio server dependencies.
docs/streamable-http.md Documents HTTP server-side default token fallback.
docs/server-configuration.md Documents org lookup and PR author allowlist configuration.
cmd/github-mcp-server/main.go Adds allowlist flag/config parsing and HTTP token fallback config.
Comments suppressed due to low confidence (1)

pkg/github/orgs.go:126

  • This Organizations.Get response is also not closed on the success path. Please close res.Body when it is non-nil, matching the response-handling pattern used elsewhere in the package (for example, pkg/github/search.go:103).
	_, res, err := client.Organizations.Get(ctx, org)
	if err == nil {
		return nil

httpConfig := ghhttp.ServerConfig{
Version: version,
Host: viper.GetString("host"),
Token: viper.GetString("personal_access_token"),
Comment on lines 107 to +108
Metrics(ctx context.Context) metrics.Metrics

rootCmd.PersistentFlags().String("gh-host", "", "Specify the GitHub hostname (for GitHub Enterprise etc.)")
rootCmd.PersistentFlags().Int("content-window-size", 5000, "Specify the content window size")
rootCmd.PersistentFlags().Bool("lockdown-mode", false, "Enable lockdown mode")
rootCmd.PersistentFlags().StringSlice("allowed-pr-authors", nil, "Comma-separated list of pull request author logins allowed for mutating pull request tools")
Comment thread pkg/github/orgs.go
Comment on lines +72 to +88
isMember, res, err := client.Organizations.IsMember(ctx, args.Org, args.Username)
if err != nil {
return ghErrors.NewGitHubAPIErrorResponse(ctx,
"failed to check organization membership",
res,
err,
), CheckOrgMembershipOutput{}, nil
}

isPublicMember, res, err := client.Organizations.IsPublicMember(ctx, args.Org, args.Username)
if err != nil {
return ghErrors.NewGitHubAPIErrorResponse(ctx,
"failed to check public organization membership",
res,
err,
), CheckOrgMembershipOutput{}, nil
}
Comment thread README.md
GITHUB_ALLOWED_PR_AUTHORS='renovate[bot],github-actions[bot]' ./github-mcp-server stdio --toolsets=pull_requests,actions
```

When set, tools such as `merge_pull_request`, `update_pull_request`, review-write tools, and PR branch updates fetch the target PR and reject the call unless `pr.User.Login` is in the allowlist. Read-only PR tools and `create_pull_request` are not restricted. `actions_run_trigger` is not gated by this setting because it targets a ref rather than a PR number.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants