-
Notifications
You must be signed in to change notification settings - Fork 6
Add optional headers to restrict GitHub mcp server toolsets #15
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
Conversation
There was a problem hiding this 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 adds support for optional headers in the GitHub MCP server configuration to allow restricting toolsets and control the server's capabilities. This addresses issues where the GitHub MCP server provides too many tools, potentially causing conflicts when used alongside other toolboxes.
- Added optional_headers configuration support to server parameters
- Implemented environment variable substitution for optional headers with graceful fallback when variables are missing
- Enhanced error handling to skip undefined environment variables in optional headers
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| toolboxes/github_official.yaml | Added optional headers for GitHub MCP toolset and readonly mode configuration |
| taskflows/examples/example_large_list_result_iter.yaml | Added example usage setting GITHUB_MCP_TOOLSETS to restrict to pull_requests only |
| mcp_utils.py | Implemented optional_headers processing logic with environment variable substitution and error handling |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
mcp_utils.py
Outdated
| optional_headers[k] = swap_env(v) | ||
| except LookupError as e: | ||
| del optional_headers[k] | ||
| pass |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pass statement after del is redundant and should be removed for cleaner code.
| pass |
mcp_utils.py
Outdated
| except LookupError as e: | ||
| del optional_headers[k] | ||
| pass | ||
| headers.update(optional_headers) |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential AttributeError if headers is None. The code should check if headers exists before calling update(), or initialize it as an empty dict if None.
mcp_utils.py
Outdated
| del optional_headers[k] | ||
| pass |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pass statement after del is redundant and should be removed for cleaner code.
mcp_utils.py
Outdated
| except LookupError as e: | ||
| del optional_headers[k] | ||
| pass | ||
| headers.update(optional_headers) |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential AttributeError if headers is None. The code should check if headers exists before calling update(), or initialize it as an empty dict if None.
| toolboxes: | ||
| - github_official | ||
| env: | ||
| GITHUB_MCP_TOOLSETS: pull_requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| GITHUB_MCP_TOOLSETS: pull_requests | |
| GITHUB_MCP_TOOLSETS: pull_requests # See more available toolsets at: https://github.com/github/github-mcp-server?tab=readme-ov-file#configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only add if you think it's necessary (unfortunately, there seems to be no perfect list with all toolsets - at least not in this simple form)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be more complete docs: https://github.com/github/github-mcp-server/blob/main/docs/remote-server.md as you can see it gets bloated quite a lot compare to the one on readme (default is "all") It is also pretty rubbish in that it doesn't really tells you what header to use. I just have to guest and hope that it is the same as the url
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add the link in the github_official.yaml file instead as that seems to be a better place for it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The github mcp server got too many tools and can cause error when it is used with other toolboxes