Skip to content

GITHUB_TOOLSETS - GITHUB_ is protected for env vars within Github itself #439

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
intel352 opened this issue May 26, 2025 · 8 comments
Closed
Labels
bug Something isn't working

Comments

@intel352
Copy link

Describe the bug

When attempting to configure Github MCP behavior for my repository, if I set the env var GITHUB_TOOLSETS, I get an error from Github's UI that GITHUB_ is protected.

Expected vs actual behavior

Either the naming of the env var should be updated so that it doesn't start with GITHUB_, or else the documentation should be updated to provide some sort of workaround.

@intel352 intel352 added the bug Something isn't working label May 26, 2025
@williammartin
Copy link
Collaborator

Can you say a little bit more about what outcome you're trying to achieve here? I think you're maybe trying to set a variable or a secret on your repository settings, but I'm not sure why you are doing that. A little more information would help in coming up with a solution, thanks.

@intel352
Copy link
Author

intel352 commented May 26, 2025 via email

@williammartin
Copy link
Collaborator

In the bigger picture, are you trying to use this in actions? If so, in the workflow file you don't need to use the same name for github variables and env vars. You can say:

env:
        GITHUB_TOOLSETS: ${{ vars.MCP_TOOLSETS }}

Though I appreciate we may still want to do work here (one idea might be to allow you to set an env var that sets the entire env var prefix dynamically).

@intel352
Copy link
Author

intel352 commented May 26, 2025 via email

@timrogers
Copy link

@intel352 Hey there! 👋 With Copilot coding agent, the GitHub MCP Server is enabled by default with all read-only tools turned on.

There is a way customize the list of allowlisted tools - but this isn't documented at the moment.

To customize the list of allowlist tools, you'll need to overwrite the default MCP configuration with your own.

You can do that by adding an MCP configuration to your repository using the instructions here. You may want to change the args (to remove --read-only) and/or the tools:

// Remove all comments when you paste this into the MCP config input
{
  "mcpServers": {
    "github-mcp-server": {
      // Leave this blank and we will overwrite it automatically with the correct command
      "command": "",
      // Optionally allow read-write tools by removing the `--read-only` arg
      "args": ["stdio", "--read-only"],
      // Use the GitHub access token provided by Copilot coding agent with read access to the current repo 
      "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "GITHUB_PERSONAL_ACCESS_TOKEN" },
     // Customize the tools exposed to the agent
      "tools": ["*"]
    }
  }
}

By default, the token provided to the GitHub MCP Server only has read-only access to the current repository. You can pass a custom token with different permissions by following the instructions here.

@intel352
Copy link
Author

@timrogers Excellent, that helps! The documentation I found didn't have any sample configuration.

One thing, your example is referencing GITHUB_PERSONAL_ACCESS_TOKEN as an env value, which is useful for the existing read-only token, right?
But the documentation you linked says to add a custom token as COPILOT_MCP_GITHUB_PERSONAL_ACCESS_TOKEN. Do I need to remap GITHUB_PERSONAL_ACCESS_TOKEN to COPILOT_MCP_GITHUB_PERSONAL_ACCESS_TOKEN in that env map, or is COPILOT_MCP_GITHUB_PERSONAL_ACCESS_TOKEN explicitly looked for by the tool?

Or is COPILOT_MCP_GITHUB_PERSONAL_ACCESS_TOKEN stripped of it's prefix (COPILOT_MCP) to become GITHUB_PERSONAL_ACCESS_TOKEN?

@timrogers
Copy link

@intel352 You can just use the existing env mapping I show above and everything should work.

Just a heads up that you should be careful about providing a token with read-write access, and even moreso if you create a token which allows access to multiple repositories. The agent will use tools without prompting you - which is why we default to read-only tools, and only the current repo.

@intel352
Copy link
Author

@timrogers good callout, I made sure to scope the token for protection. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants