Created
December 4, 2025 03:16
-
-
Save KyMidd/6c887403947d0e35942e81148859ee24 to your computer and use it in GitHub Desktop.
build_github_mcp_client function (old pattern)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def build_github_mcp_client(github_token, mode="read_only"): | |
| # Build client | |
| github_mcp_client = MCPClient( | |
| lambda: streamablehttp_client( | |
| "https://api.githubcopilot.com/mcp/", | |
| headers={"Authorization": f"Bearer {github_token}"}, | |
| ) | |
| ) | |
| # Manually start the client | |
| github_client = github_mcp_client.__enter__() | |
| # Extract all tools | |
| all_github_tools = github_client.list_tools_sync() | |
| # Filter for read-only tools | |
| if mode == "read_only": | |
| filtered_tools = [] | |
| for tool in all_github_tools: | |
| tool_name = tool.tool_spec["name"] | |
| if tool_name.startswith(("download_", "get_", "list_", "search_")): | |
| filtered_tools.append(tool) | |
| return github_mcp_client, filtered_tools | |
| return github_mcp_client, all_github_tools |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment