Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created December 4, 2025 03:16
Show Gist options
  • Select an option

  • Save KyMidd/6c887403947d0e35942e81148859ee24 to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/6c887403947d0e35942e81148859ee24 to your computer and use it in GitHub Desktop.
build_github_mcp_client function (old pattern)
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