Skip to content

Conversation

@JoannaaKL
Copy link
Contributor

@JoannaaKL JoannaaKL commented Nov 7, 2025

This pull request introduces a special operating mode for the GitHub MCP server that if enabled will only return content from users with push access to the repository.

Lockdown mode is disabled by default and can be enabled through a console flag lockdown-mode.
This pr only adds lockdown mode to GetIssue function, it will be applied to remaining tools in follow up pull requests.

If lockdown is enabled and user requests an issue that was added by user without push access it will return an error:
CleanShot 2025-11-07 at 13 39 15@2x

To enable use a flag run ./cmd/github-mcp-server stdio --lockdown-mode=true
Based on #428

Copilot AI review requested due to automatic review settings November 7, 2025 10:12
@JoannaaKL JoannaaKL requested a review from a team as a code owner November 7, 2025 10:12
Copy link
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

This PR introduces a lockdown mode feature for the GitHub MCP Server that restricts access to issue details based on repository visibility and user permissions. When enabled, the feature allows access only to users with push access on public repositories, while private repositories remain unrestricted.

Key Changes

  • Added a new lockdown package with functions to check repository privacy and user permissions via GitHub GraphQL API
  • Integrated lockdown checks into the IssueRead tool's GetIssue method
  • Added FeatureFlags struct and CLI flag to enable/disable lockdown mode

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pkg/lockdown/lockdown.go New package implementing lockdown logic with GraphQL-based permission checks
pkg/github/feature_flags.go New feature flags struct to control lockdown behavior
pkg/github/issues.go Integration of lockdown checks in GetIssue function
pkg/github/issues_test.go Test cases for lockdown mode scenarios (private repo and insufficient permissions)
pkg/github/tools.go Updated DefaultToolsetGroup to accept and pass feature flags
internal/ghmcp/server.go Wired lockdown configuration through server setup
cmd/github-mcp-server/main.go Added CLI flag for lockdown mode
cmd/github-mcp-server/generate_docs.go Updated docs generation to pass empty feature flags

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 58 to 71
// Check if the user has push access
hasPush := false
for _, edge := range query.Repository.Collaborators.Edges {
login := string(edge.Node.Login)
if strings.EqualFold(login, username) {
permission := string(edge.Permission)
// WRITE, ADMIN, and MAINTAIN permissions have push access
hasPush = permission == "WRITE" || permission == "ADMIN" || permission == "MAINTAIN"
break
}
}

return hasPush, nil
}
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

When the GraphQL query returns no collaborators (empty Edges array), the function returns false without distinguishing between "user not found" and "user has no push access". This could happen if the user is not a collaborator or if the repository query parameter doesn't match. Consider adding logging or a more specific error message to help diagnose why a user was denied access in lockdown mode.

Copilot uses AI. Check for mistakes.
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