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
| github_mcp_client = build_github_mcp_client(...) | |
| tools.append(github_mcp_client) |
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
| github_mcp_client, github_tools = build_github_mcp_client(...) | |
| github_tools = add_prefix_to_mcp_tools(github_tools, "github") | |
| tools.extend(github_tools) |
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
| # Build client | |
| github_mcp_client = MCPClient(...) | |
| # Return it unstarted | |
| return github_mcp_client |
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
| # Build client | |
| github_mcp_client = MCPClient(...) | |
| # Manually start it | |
| github_client = github_mcp_client.__enter__() | |
| # Extract tools | |
| all_github_tools = github_client.list_tools_sync() | |
| # Return tuple | |
| return github_mcp_client, all_github_tools |
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
| # MCPClient filters declaratively | |
| TOOLS_PREFIX = "github" | |
| READ_ONLY_PREFIXES = ["download_", "get_", "list_", "search_"] | |
| github_mcp_client = MCPClient( | |
| lambda: streamablehttp_client(...), | |
| tool_filters={ | |
| "allowed": [lambda tool: tool.tool_name.startswith(tuple( | |
| f"{TOOLS_PREFIX}_{p}" for p in READ_ONLY_PREFIXES | |
| ))] | |
| }, |
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
| # Manually loop and filter | |
| 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) |
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
| # MCPClient handles it | |
| github_mcp_client = MCPClient( | |
| lambda: streamablehttp_client(...), | |
| prefix="github", | |
| ) |
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
| # Wrap every tool manually | |
| github_tools = add_prefix_to_mcp_tools(github_tools, "github") |
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
| # Build GitHub MCP client with only read-only tools | |
| github_mcp_client, github_tools = build_github_mcp_client( | |
| secrets_json["GITHUB_TOKEN"], "read_only" | |
| ) | |
| opened_clients["GitHub"] = github_mcp_client | |
| # Prefix tool names | |
| github_tools = add_prefix_to_mcp_tools(github_tools, "github") | |
| # Extend tools list | |
| tools.extend(github_tools) |
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__() |
NewerOlder